mmssaann
mmssaann

Reputation: 1507

jqplot dateaxisrender is not rendering the dates given + jquery

I am unable to use DateAxisRender for jqplot correctly.

The requirement is we have to show appointment dates in x axis, and number of patients in y axis. The dates are fixed and they come from server, we have to plot same dates in x axis.

The example dates are:

s1 = [['01-May-08', 1], ['10-May-08', 4], ['25-May-08', 2], ['30-May-08', 6]];

$.jqplot(grphOneID, [s1], YI.getGraphOpts(YAxisLbl)).replot();

 getGraphOpts: function (YAxisLbl) {

        $.jqplot.config.enablePlugins = true;
        var optsObj =
            {
                series: [{
                    pointLabels: {
                        xpadding: 8,
                        escapeHTML: false
                    },
                    rendererOptions: {
                        smooth: true
                    }
                }],

                axes: {
                    yaxis: {
                        ticks: m_CompositeReport.stdYLbls,
                        label: YAxisLbl,
                        tickOptions: {
                            formatString: '%d'
                        }
                },
                    xaxis: {
                        renderer: $.jqplot.DateAxisRenderer,
                        label: 'Shop',
                        tickOptions: {
                            formatString: "%#m/%#d/%y"
                        },
                        numberTicks: 4
                    }
                },
                seriesColors: m_CompositeReport.stdColors.reverse()
            }
        return optsObj;
    },

After plotting the graph, the dates are messed up. They are coming as '4/30/08', '5/7/08', '5/14/08', '5/21/08', '5/28/08', '6/4/08'.

Why is it like this? Pls advise what am doing wrong here.

Thanks in advance...

Upvotes: 0

Views: 110

Answers (1)

Gyandeep
Gyandeep

Reputation: 13538

use formatString inside xaxis carefully as it makes the difference when it comes to display of dates.

formatString: "%#m/%#d/%y"

You can choose different formatString from this link: http://www.jqplot.com/docs/files/plugins/jqplot-dateAxisRenderer-js.html

Upvotes: 1

Related Questions