I am drawing a highchart as-
options.series.push({ name: this.SubCity, data: this.Data });
where data is an array for series data.
I also have an array for xAxis Categeries as-
Categ['Jan-Mar', 'Apr-Jun', 'Jul-Sep', 'Oct-Dec']
my chart is drawing correctly but problem with the xAxis categories is I don't know how to set categories dynamically .
for more clarity i am adding some code-
var PriceTrend = JSON.parse(Data);
var AvgRate = new Array();
var Categories = new Array();
$(PriceTrend).each(function (index)
{
MaxRate.push(this.Max);
MinRate.push(this.Min);
AvgRate.push((this.Max + this.Min) / 2);
Categories.push(this.Quarter);
});
TrendData.push({ SeriesID: SeriesID, Data: AvgRate, Visible: true, SubCity: SubCity, Categ: Categories });
DisplayTrend();
function DisplayTrend()
{
options.series = [];
$(TrendData).each(function (Index)
{
if (this.Visible)
{
options.series.push({ name: this.SubCity, data: this.Data });
}
});
chart = new Highcharts.Chart(options);
}
You are looking for the Axis.update()
method.
Highcharts.charts[0].xAxis[0].update({categories:['some','new','categories']}, true);
Here's an example.
Yes you can do it since only fiew months. http://api.highcharts.com/highcharts#Chart.addAxis() http://jsfiddle.net/wvaGt
chart.addAxis({ // Secondary yAxis
id: 'rainfall-axis',
title: {
text: 'Rainfall'
},
lineWidth: 2,
lineColor: '#08F',
opposite: true
});
chart.addSeries({
name: 'Rainfall',
type: 'column',
color: '#08F',
yAxis: 'rainfall-axis',
data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
});
Hope it will help someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With