2

我正在尝试绘制折线图,​​我正在使用 CategoryAxisRenderer。我想指定ticks选项内的刻度

代码链接:jsfiddle

$.jqplot.config.enablePlugins = true;
var chartData = [["19-Jan-2012", 2.61], ["20-Jan-2012", 5.00], ["21-Jan-2012", 6.00]];

function PlotChart(chartData, extraDays) {


    var plot2 = $.jqplot('chart1', [chartData], {
        title: 'Mouse Cursor Tracking',
        seriesDefaults: {
            renderer: $.jqplot.LineRenderer,

            pointLabels: {
                show: true
            }
        },
        axes: {
            xaxis: {
                pad: 1,            
                renderer: $.jqplot.CategoryAxisRenderer 
                ,ticks:["19-Jan-2012","20-Jan-2012","21-Jan-2012"]

            },
            yaxis: {
                tickOptions: {
                    formatString: '$%.2f'
                }
            }
        },
        highlighter: {
            sizeAdjust: 7.5
        },
        cursor: {
            show: true
        }
    });
}

PlotChart(chartData, 3);

如果我注释掉该ticks选项,上面的代码可以正常工作。但是ticks激活选项后,它不会在图表上显示线条。

4

1 回答 1

1

我将数据更改为var chartData = [ 2.61, 5.00, 6.00];
现在可以正常工作请参阅示例

代码

$.jqplot.config.enablePlugins = true;
var chartData = [ 2.61, 5.00, 6.00];

function PlotChart(chartData, extraDays) {


    var plot2 = $.jqplot('chart1', [chartData], {
        title: 'Mouse Cursor Tracking',
        seriesDefaults: {
            renderer: $.jqplot.LineRenderer,

            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,  
               ticks:["19-Jan-2012","20-Jan-2012","21-Jan-2012"]

            },
            yaxis: {
                tickOptions: {
                    formatString: '$%.2f'
                }
            }
        },
        highlighter: {
            sizeAdjust: 7.5
        },
        cursor: {
            show: true
        }
    });
}

PlotChart(chartData, 3);
于 2013-06-19T03:00:44.407 回答