I'm trying to create a column graph in Highcharts of the following nature:
X Axis: Time in seconds Y Axis: how many times the particular time value appears.
In other words, I want to be able to have the following data series entered in:
[50,50,30]
and it should create a column chart开发者_高级运维 with the following values:
x: 30, y: 1 x: 50, y: 2
Is this type of functionality possible in Highcharts?
Thank you!
It is possible but it's not directly related to highcharts.
You just have to create a javascript snippet before calling highcharts functions to spliut your data in the format you want and then use it in highcharts (series and totals/values). No charting library will do that work for you.
the javascript snippet should look like this :
var options = {
chart: {
renderTo: 'container',
defaultSeriesType: 'column'
},
title: {
text: 'Fruit Consumption'
},
xAxis: {
categories: []
},
yAxis: {
title: {
text: 'Units'
}
},
series: []
};
var items = [50,30,50];
var series = {
data: []
};
var notfound;
items.sort();
for(var i=0; i < items.length; i++) {
notfound= true;
for(var j=0; j < options.xAxis.categories.length && notfound; j++) {
if (items[i] === options.xAxis.categories[j]) {
notfound= false;
}
}
if (notfound) {
options.xAxis.categories.push(items[i]);
series.data[j]= 1;
} else {
series.data[j]++;
}
}
$(document).ready(function() {
var chart = new Highcharts.Chart(options);
}
Something like this. I hope it helps.
Regards
精彩评论