I would like to show labels on each series of the stacked bar.Any idea please. I have been looking with no luck. For example if you have blue series text will be blue on the series of the stacked bar and so on.
It should be something like that as you can see in the image :
Here is my code:-
<div id="placeholder" style="width:600px;height:300px;"></div>
var data = [
{label: 'foo', color:'red', data: [[1,300], [2,300], [3,300], [4,300], [5,300]]},
{label: 'bar', color:'blue', data: [[1,800], [2,600], [3,400], [4,200], [5,0]]},
{label: 'baz', color:'yellow', data: [[1,100], [2,200], [3,300], [4,400], [5,500]]},
];
$.plot($("#placeholder"), data, {
series: {
stack: 1,
bars: {
show: true,
lineWidth: 1,
barWidth: 0.8,
order: 1,
fill: true,
label: {
show: true,
radius:0.7,
formatter: function(label, series) {
var result =[ <?php echo $red; ?> ,<?php echo $blue; ?> ,<?php
echo $yellow; ?>
];
if ( label == "red")
{
return '<div style="font-size:13px; text-align:center; left:-340px; top:-338px;
position:absolute; color:white;">'+label+'<br/>'+(result[0])+'</div>';
}
else if (label == "blue")
{
return '<div style="font-size:13px; text-align:center; left:-343px; top:-228px;
position:absolute; color:white;">'+label+'<br/>'+(result[1])+'</div>';
}
else if (label == "yellow")
{
return '<div style="font-size:13px; text-align:center; left:-325px; top:-220px;
position:absolute; color:white;">'+label+'<br/>'+(result[2])+'</div>';
}
},
background: {
opacity: 0.8,
}
}
},
yaxis : {
min : 0,
tickLength: 0
} ,
xaxis: {
tickLength: 0,
axisLabel: "Date",
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: 'Arial',
axisLabelPadding: 3,
color: "#838383",
timeformat: "%b/%y"
}
}
});