Search code examples
jqplot

Simple chart lines don't show up


$(document).ready(function(){
    var line0 =['2008-06-30 8:00AM', '2008-06-30 9:00AM', '2008-06-30 10:00AM', '2008-06-30 11:00AM', '2008-06-30 12:00PM' ];
    var line2=[4, 6.5, 5.7, 9, 8.2];
    var line3=[5, 5.5, 7.7, 11, 7.2];

    var t1=[91.51,91.74,91.62,91.40,91.51];

    var plot1 = $.jqplot('chartdiv4', [t1], {
        title: 'Concern vs. Occurrance',
        seriesDefaults:{renderer:$.jqplot.BarRenderer},
//        axesDefaults: {
//            tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
//            tickOptions: {
//                angle: -30,
//                fontSize: '10pt'
//            }
//        },

        axes: {
            xaxis: {
                renderer: $.jqplot.DateAxisRenderer,
                ticks: line0, 
                tickOptions: {formatString:'%r'},
            },
            yaxis: {label: "Y Axis"}
        }
    })
});
</script>

I'm hopping for another set of eyes on this. I can't get this chart to plot. I'm making myself crazy looking at it. I made a jsfiddle here: http://jsfiddle.net/Rich_Strle/gSQsL/3/

If I comment out all of the chart options the lines plot. When I add ticks and options the ticks will show up but no lines.


Solution

  • If you are using the DateAxisRenderer it looks as though each data point must be of the form [date, value]. See http://www.jqplot.com/tests/date-axes.php.

    This worked for me:

    var data = [];
    
    for(var i = 0; i < t1.length; i++){
        data.push([line0[i], t1[i]]);
    }
    
    var plot1 = $.jqplot('chartdiv4', [data], { ....