Changement labels
by Tenobaal
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<input id="checkbox" type="checkbox" name="choix1" value="1">glace vanille</input>
JavaScript
function dataLabelsDisplay(bool, chart) {
for (var i = 0; i < chart.series.length; i++) {
if (bool) chart.series[i].update({
dataLabels: {
enabled: true
}
}, false)
else chart.series[i].update({
dataLabels: {
enabled: false
}
}, false)
}
chart.redraw();
}
function stackedLabelsDisplay(bool, chart) {
if (bool) chart.axes[1].stackTotalGroup.show();
else chart.axes[1].stackTotalGroup.hide();
}
$(function () {
var myChart;
$('#checkbox').click(function () {
var interuptor = $("#checkbox")[0].checked;
myChart.yAxis[0].update({ stackLabels: {formatter: function(){return 2}}})
});
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Stacked column chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
},
stackLabels: {
enabled: true,
formatter: function(){
return 22
},
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
legend: {
align: 'right',
x: -30,
verticalAlign: 'top',
y: 25,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
formatter: function () {
return '<b>' + this.x + '</b><br/>' + this.series.name + ': '...