javascript - How to change tool tip using High Charts -
i have created chart using high chart compare expected time & arrival time of patient.
however, having issue label
of columns; displaying time in milliseconds
.
the screen shot below shows issue:
how change label display time in format (h:m:s)
code:
<script type="text/javascript"> function drawchart(){ var chart = new highcharts.chart({ chart: { renderto: 'divforchart', type:'column', }, xaxis: { name:'patients', categories: [<?php echo "'".$names[0]."'"; for($i = 1; $i < sizeof($names); $i++){ echo ",'".$names[$i]."'"; } ?>] }, yaxis: { type: 'datetime', datetimelabelformats: { //force formats hour:minute:second second: '%h:%m:%s', minute: '%h:%m:%s', hour: '%h:%m:%s', day: '%h:%m:%s', week: '%h:%m:%s', month: '%h:%m:%s', year: '%h:%m:%s' }, min: <?php echo "date.utc(".gmdate("y,m,d,h",strtotime($mindate)).")";?> }, series: [ { name: 'arrival time', data: [<?php echo "['".$names[0]."',date.utc(".gmdate("y,m,d,h,i,s",strtotime($arrival_time[0])).")]"; for($i = 1; $i < sizeof($names); $i++){ echo " ,['".$names[$i]."',date.utc(".gmdate("y,m,d,h,i,s",strtotime($arrival_time[$i])).")]"; } ?>] }, { name: 'expected time', data: [<?php echo "['".$names[0]."',date.utc(".gmdate("y,m,d,h,i,s",strtotime($expected_time[0])).")]"; for($i = 1; $i < sizeof($names); $i++){ echo " ,['".$names[$i]."',date.utc(".gmdate("y,m,d,h,i,s",strtotime($expected_time[$i])).")]"; } ?>] } ] }); } </script> </head> <body onload="drawchart()"> <div id="divforchart" style="height: 400px"></div> </body>
by of it, referring tooltip, not datalabel. can use formatter function format date properly:
http://api.highcharts.com/highcharts#tooltip.formatter
(if in fact talking datalabel, can same thing still: http://api.highcharts.com/highcharts#plotoptions.series.datalabels.formatter )
i think default numberformat y axis value, want instead use dateformat function in formatter:
http://api.highcharts.com/highcharts#highcharts.dateformat%28%29
if need implementing, create jsfiddle ( http://jsfiddle.net/ ) , post back
Comments
Post a Comment