anychart.onDocumentReady(function() {
var dataSet = anychart.data.set([
['Battery_SOC_Current leakage out of limit', 2, 4, 9, 0, 0],
['CLI_Read_Battery_SOC_Current out of limit', 2, 0, 0, 0, 0],
['I2C1 enable SOC power fail', 1, 1, 3, 1, 1],
['IO failure', 0, 0, 1, 1, 0],
['MLB damage', 0, 1, 0, 0, 0],
['No communication', 4, 1, 0, 6, 1],
['QT1/IO failure', 0, 0, 0, 0, 6],
['VOC value high and smell', 1, 0, 0, 0, 0]
var firstSeriesData = dataSet.mapAs({
var secondSeriesData = dataSet.mapAs({
var thirdSeriesData = dataSet.mapAs({
var fourthSeriesData = dataSet.mapAs({
var fifthSeriesData = dataSet.mapAs({
var chart = anychart.bar();
chart.yScale().stackMode('percent');
chart.title('By Failure Mode');
chart.yAxis(0).labels().format('{%Value}%');
var setupSeriesLabels = function(series, name) {
series.name(name).stroke('3 #fff 1');
series.hovered().stroke('3 #fff 1');
chart.labels().position("center");
chart.labels().fontFamily("Helvetica");
chart.labels().fontSize(20);
chart.labels().fontDecoration("underline");
chart.labels().fontWeight(600);
series.labels().fontColor("#663399");
series = chart.bar(firstSeriesData);
setupSeriesLabels(series, 'PKG101HNF');
series = chart.bar(secondSeriesData);
setupSeriesLabels(series, 'PKG201HNG');
series = chart.bar(thirdSeriesData);
setupSeriesLabels(series, 'PKR501HNI');
series = chart.bar(fourthSeriesData);
setupSeriesLabels(series, 'PKR601HNJ');
series = chart.bar(fifthSeriesData);
setupSeriesLabels(series, 'PKR101HNG');
chart.legend().enabled(true).fontSize(14).padding([0, 0, 15, 0]);
chart.interactivity().hoverMode('by-x');
chart.tooltip().displayMode('union').valuePrefix('$');
chart.container('container');