【问题标题】:jqPlot line chart's pointlabels are shown in wrong placejqPlot 折线图的点标签显示在错误的位置
【发布时间】:2013-09-24 13:51:46
【问题描述】:

我正在使用 jqPlot 的折线图,其中应显示过去 12 个月的数据。如果当前月份是 9 月,则 X 轴将显示 2012 年 8 月至 2013 年 9 月。但是,我有从 2013 年 1 月开始的数据。因此,这些线将从图表中间开始,直到最近可用月份的数据。

问题:线条从正确的位置开始,但指针没有相应移动。尽管线条正确显示,但指针从图表的开头显示。

问题:如何移动应该在点上的指针?

更新:似乎是 jqPlot 中的已知问题 (issue log)

var json= {    
        title: '' 
        ,stackSeries: false   
        ,captureRightClick: true    
        ,seriesDefaults:{      
            //renderer:$.jqplot.BarRenderer      
            rendererOptions: {                            
                highlightMouseDown: true                             
            }      
            ,pointLabels: {
                show: true
                ,formatString: '%.1f'
                ,seriesLabelIndex:null
                ,hideZeros:true
            }
            ,markerOptions: {
                show: true,    

                style: 'filledCircle',  
            }  
        }  
            ,series: [
                {label: 'A', color:'#FDC12E'}
                ,{label: 'B', color:'#C9198D'}
                ,{label: 'C', color:'#56B9F9'}
                ,{label: 'D', color: '#F1683C'}
                                    ,{label: 'E', color: '#000000'}
            ]

            ,axes: {      
                xaxis: {          
                    tickOptions:{angle:-45}
                    ,tickRenderer: $.jqplot.CanvasAxisTickRenderer
                    ,renderer: $.jqplot.CategoryAxisRenderer
                    ,ticks: []
                },      
                yaxis: {   
                    labelRenderer: $.jqplot.CanvasAxisLabelRenderer
                    ,padMin: 0
                    ,pad: 1.05
                    ,min: 0
                    ,tickOptions:{formatString: '%.0f'},
                } 
            }    
            ,legend: {
                show: true 
                ,location: 's'
                ,placement: 'outsideGrid'
            }
            ,highlighter:{
                show: true
                ,tooltipLocation: 's'
                ,yvalues: 2
                ,bringSeriesToFront:true
                ,showMarker:false
                ,tooltipAxes: 'y'
                ,formatString: "%n%s"
            }
            ,cursor:{
                show: true
                ,zoom:true
                ,showTooltip:false
                ,constrainZoomTo: 'y'
            }
            ,grid:{
                background: '#f8f8f8'
            }               

【问题讨论】:

    标签: jqplot linechart


    【解决方案1】:

    我找到了一种解决方法,直到 jqPlot 修复了他们的错误。显然将breakOnNull: true 添加到seriesDefaults 解决了这个问题。这可用于 pointLabels 或 JSON 部分中的 highlighter

    【讨论】:

    • 否则您可以指定 xaxis 的最小值和/或最大值:参见second example here
    • 我担心最小值/最大值因为空值而不起作用。
    • 因此您可以在绘制扫描数据的图表之前进行预处理,并保留除空值外的最小值和最大值
    猜你喜欢
    • 2012-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多