javascript - 2 bars stacked and 1 unstacked in the same x axis CHARTJS -
i'm trying combined chart title says. mean when have 3q15 in x axis want 2 bars 1 after other, first 1 stacked other , second 1 unstacked. here have picture of want chartjs:
<script> var randomscalingfactor = function() { return math.round(math.random() * 10000); }; </script> <h3 style="text-align:center;font-weight:900">online</h3> <canvas id="mychart6" ></canvas> <div id="js-legend" class="chart-legend"></div> <script> var barchartdata = { labels: ["ene-16", "feb-16", "mar-16", "abr-16", "may-16", "jun-16", "jul-16", "ago-16", "set-16", "oct-16", "nov-16", "dic-16"], datasets: [{ type: 'bar', label: 'logística', backgroundcolor: "rgba(0,255,0,0.6)", data: [randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor()], yaxisid: 'y-axis-1' }, { type: 'bar', label: 'equipamiento', backgroundcolor: "rgba(255,0,0,0.6)", data: [randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor()], yaxisid: 'y-axis-1' }, { type: 'bar', label: 'equipamiento1', backgroundcolor: "rgba(130,130,130,1)", data: [randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor()], yaxisid: 'y-axis-1' }, { type: 'line', label: 'equipamiento2', backgroundcolor: "rgba(0,0,100,0.6)", data: [randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor(), randomscalingfactor()], yaxisid: 'y-axis-1', fill: false }] }; window.onload = function() { var ctx = document.getelementbyid("mychart6").getcontext("2d"); window.mybar = new chart(ctx, { type: 'bar', data: barchartdata, options: { tooltips: { mode: 'label' }, responsive: true, scales: { yaxes: [{ stacked: true, id: "y-axis-1", position: "left", display:true }, { stacked: true, id: "y-axis-2", gridlines:{ display: false }, position: "right", display:true }] } } }); };
and i'm getting this, don't know how make stick first 2 bars , make got separated 3rd bar desired chart.
any great! i'm getting little desperate new chart js. i'm using chart js 2.2.2 http://www.chartjs.org/ .
i hope can give me tip. thanks!
Comments
Post a Comment