Reputation: 1296
I'm working on a simple project, and I'm trying to create a chart. Everything works perfectly except the fact that the legend is not showing the series name. This is the fiddle.
HTML:
<div id="container" style="height: 400px"></div>
Code:
var myData = [{
"name": "Beginning Farmer",
"y": 1,
"color": "#FAD252"
}, {
"name": "Organic",
"y": 1,
"color": "#B5C442"
}, {
"name": "Whole Farm",
"y": 2,
"color": "#EB2F65"
}];
$(function() {
$('#container').highcharts({
chart: {
type: 'column'
},
xAxis: {
categories: myData[0]
},
series: [{
data: myData,
}]
});
});
What am I missing here? Thanks!
Upvotes: 0
Views: 2589
Reputation: 1296
Actually all I needed to do was to change the format of the object array myData to:
var myData = [{
"name": "Beginning Farmer",
"data": [1],
"color": "#FD31B4"
}, {
"name": "Organic",
"data": [1],
"color": "#A7DC7B"
}, {
"name": "Whole Farm",
"data": [2],
"color": "#67ABDA"
}];
And then:
In the series
option, just change it to:
series: myData,
Upvotes: 0
Reputation: 337714
To set that value in the legend each series needs a name
property:
series: [{
name: 'Foo',
data: myData,
}]
Upvotes: 4