【问题标题】:Jqplot line chart multiple seriesjqplot折线图多系列
【发布时间】:2013-08-06 04:57:21
【问题描述】:
[[["09251A0428",90],["10251A0547",37]],[["09251A0428",4],["10251A0547",54]]]

以上数据包含两个系列。每个系列的 x 值相同。如果 x 值是数字,jqplot 将正常显示带有两个系列的折线图。但我们需要在 x 轴上显示字符串,并为每个字符串显示对应的系列值。

jqplot的多系列折线图如何在xaxis上设置字符串?

【问题讨论】:

    标签: jqplot


    【解决方案1】:

    我根据您提供的数据为您准备了一个示例: JsFiddle link

    $.jqplot.config.enablePlugins = true;
    var chartData = [[["09251A0428",90],["10251A0547",37]],[["09251A0428",4],["10251A0547",54]]];
    
    
    function PlotChart(chartData) {
    
        var plot2 = $.jqplot('chart1', chartData, {
            title: 'Mouse Cursor Tracking',
            seriesDefaults: {
    
                pointLabels: {
                    show: true
                }
            },
            axes: {
                xaxis: {
                    pad: 1,
                    // a factor multiplied by the data range on the axis to give the            
                    renderer: $.jqplot.CategoryAxisRenderer,
                    // renderer to use to draw the axis,     
                    tickOptions: {
                        formatString: '%b %#d'
                    }
                },
                yaxis: {
    
                }
            },
            highlighter: {
                sizeAdjust: 7.5
            },
            cursor: {
                show: true
            }
        });
    }
    
    PlotChart(chartData);
    

    【讨论】:

    • 谢谢,renderer: $.jqplot.CategoryAxisRenderer是可能的