Search code examples
chartsjqplotstacked

100 % stacked bar chart JQPlot


I have the below code for drawing a JQPlot bar chart. Now I want all the bars to be at the same height and display the colors in percentages. Couldn't seem to find an example. Please help!!

Current graph

enter image description here

Expected result

enter image description here

var s3 = [11, 28, 22, 47, 11, 11];
var s1 = [0, 6, 3, 0, 0, 0];
var s2 = [1, 0, 3, 0, 0, 0];
var dataArray = [s3, s1, s2];
var ticks = ['John', 'Tumm', 'Wen', 'Ken', 'Dolly'];

var options = {
    title: 'Title ',
    stackSeries: true,
    seriesColors: ["#eb4b3d", "#ffc800", "#009149"],
    seriesDefaults: {
        renderer: $.jqplot.BarRenderer,
        pointLabels: {
            show: true
        },
        rendererOptions: {
            barWidth: 25,
            varyBarColor: true,
        },
    },
    axes: {
        xaxis: {
            // renderer: $.jqplot.CategoryAxisRenderer,
            //  
            renderer: $.jqplot.CategoryAxisRenderer,
            ticks: ticks,
        },
        yaxis: {
            //autoscale: true,
            //label: 'Application Count',
            min: 0,
            tickInterval: 5,
            max: 50
        }
    },
    axesDefaults: {
        tickRenderer: $.jqplot.CanvasAxisTickRenderer,
        tickOptions: {
            angle: -30,
            fontSize: '10pt'
        }
    }
};

var plot = $.jqplot('chartDivId', dataArray, options);

Solution

  • The problem is resolved now!! Its all about supplying the data though arrays(S1,S2,S3) in percentages!!