javascript - jqplot tooltip Content Editor -


i m facing problem in displaying tool tip jq plot bar chart jqplot code is

<script class="code" type="text/javascript">  $(document).ready(function(){     var s1 = [0,10,20,30,40,50,60,70,80,90,100];     var s2 = [-100,-90,-80,-70,-60,-50,-40,-30,-20,-10,-0];     var ticks = ['01-jun','02-jun','03s-jun','04-jun','05-jun','06-jun','07-jun','08-jun','09-jun','10-jun'];     var plot1 = $.jqplot('chart1', [s1, s2], {         animate: !$.jqplot.use_excanvas,         stackseries: true,         seriesdefaults:{             renderer:$.jqplot.barrenderer,             rendereroptions: {filltozero: true, barpadding: 10,barmargin: 15},             pointlabels: { show: true }         },         series: [                 { color: '#68ba38',label:'uptime' },                 { color: 'red',label:'downtime' },                 { label:'abcd' }         ],         legend: {             show: true,             placement: 'outsidegrid'         },         axes: {             // use category axis on x axis , use our custom ticks.             xaxis: {                 pad: 1,                 renderer: $.jqplot.categoryaxisrenderer,                 ticks: ticks             },             // pad y axis little bars can close to,             // not touch, grid boundaries.  1.2 default padding.             yaxis: {                 pad: 1,                 min:-100,                 max: 100,             }         },         highlighter:{         show:true,         tooltipcontenteditor:tooltipcontenteditor     },     }); }); function tooltipcontenteditor(str, seriesindex, pointindex, plot) {     // display series_label, x-axis_tick, y-axis value     return plot.series[seriesindex]["label"] + ", " + plot.data[seriesindex][pointindex]; }   </script> 

its displaying tooltip this: uptime,20 or downtime,-20

i want display tooltip contain tick value like: 01-jun

had question myself, used firefox's web developer tools examine plot object in tooltipcontenteditor function find x-axis labels are. in plot.options.axes.xaxis.ticks. code want data point's x-axis label is:

plot.options.axes.xaxis.ticks[pointindex] 

this x-axis label point index in question.

my complete code callback function use is:

function tooltipcontenteditor(str, seriesindex, pointindex, plot) {     return plot.series[seriesindex]["label"] + ": " + plot.options.axes.xaxis.ticks[pointindex] + ", " + plot.data[seriesindex][pointindex]; } 

this shows series label, x-axis tick label, data point value.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -