I'm trying to make a simple highcharts column graph. The documentation on the highcharts website is more complex than I need and I just can't figure out how to use a simple array for the y axis. This is my code so far.
var species=[Acer rubrum,Tsuga canadensis,Pinus strobus];
var counts=[17746,10384,9986];
Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: 'Top 10 Species'
},
subtitle: {
text: 'by basal area'
},
xAxis: {
categories: species,
title: {
text: 'Species'
}
},
yAxis: {
min: 0
},
series: [{ name: null, data: topSpecies }]
});
}
This gives me the correct species listed along the x-axis, but I want the counts along the y and currently it is blank and there are no columns. Any help is appreciated!
Thank you.
You have used the wrong variable for series data. Use counts instead of topSpecies.
var species = ['Acer rubrum', 'Tsuga canadensis', 'Pinus strobus'];
var counts = [17746, 10384, 9986];
Highcharts.chart('container', {
...,
series: [{
name: null,
data: counts
}]
});
Live demo: http://jsfiddle.net/BlackLabel/yfesv93x/
API Reference: https://api.highcharts.com/highcharts/series.column.data
Well for starters you haven't assigned your Y-axis any categories.
yAxis: {
categories: counts,
},
see the fiddle. https://jsfiddle.net/odrga0hL/3/