Print value on bar graph chart?

I created a histogram using highcharts.js . I added the device name as the y axis and data packets in bytes for the x axis. How to add device contact time in bars of a bar chart. I have contact time with the device in array.i want - is this a way of printing, is it the time value on the histogram?

+6
source share
2 answers

You can do this by enabling dataLabels and customizing them. You will also need to format your data in a certain way:

 $(function () { $('#container').highcharts({ chart: { type:'bar', }, xAxis: { categories: ['Device 1', 'Device 2'] }, plotOptions: { series: { dataLabels: { enabled: true, formatter:function() { return this.point.t; } } } }, series: [{ data: [{y:29.9,t:"12:45"}, {y:71.5,t:"14:45"}] }] }); }); 

http://jsfiddle.net/NPSEf/

The data in this example has an additional field defined by "t" that contains the time you want to display in the panel. In the dataLabel formatting function, you can reference all the data at each point, including "t", using this.point.t.

+9
source

Please share your code ...

You were looking for this ...

call the openData () function from your data in the highcharts series

 series: [{ name: 'BarName', data: openData() }] 

openData () function

 function openData() { var fromDate =$('#startDate').val(); var toDate = $('#expireDate').val(); if(fromDate == '' || toDate == '' ){ // return false; } var data = 'fromDate='+fromDate+'&toDate='+toDate; $.ajax({ url: 'apAppOpenChart.php', data: data, success: function(data) { var chartData=[]; var retdata = jQuery.parseJSON(data); var length =retdata.length; for(var i=0; i<length; i++){ var jsDate = new Date(retdata[i][0]*1000); var datejs = jsDate.getFullYear()+','+jsDate.getMonth()+','+jsDate.getDate(); } chart.series[0].setData(retdata); chart.redraw(); }, cache: false }); } 
+3
source

All Articles