Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Remove stacking from line chart

Open mvahsen opened this issue 9 years ago • 3 comments

Hi ,

I have a stacked bar chart with two line charts. The second line chart is also beeing stacked on top of the first line chart but I need it without stacking.

The basis from the chart is from this post tried already to explicit set the option stacking false but it has no effect:

var barChartData = {
            labels: dates,
            datasets: [{
                type: 'bar',
                label: 'chart1',
                data: data1
            }, {
                type: 'bar',
                label: 'chart2',
                backgroundColor: "rgba(153, 217, 127, 0.6)",
                borderColor: "rgba(25, 216, 0, 1)",
                data: data2,
            },  {
                type: 'line',
                label: 'lineChart1',
                data: lineData1,
                borderWidth: 1,
                fill: false,
                options: {
                  legend: {
                    display: false
                  },
                  scales: {
                        xAxes: [{
                            stacked: false,
                        }],
                        yAxes: [{
                            stacked: false
                        }]
                    }
                }
            },  {
                type: 'line',
                label: 'lineChart2',
                data: lineData2,
                fill: false,
                options: {
                scales: {
                        xAxes: [{
                            stacked: false,
                        }],
                        yAxes: [{
                            stacked: false
                        }]
                    }
                }
            }, 
            ]
        };

mvahsen avatar Mar 22 '17 17:03 mvahsen

@mvahsen since stacking is per axis, one way to deal with this is to put the line charts on another axis and then make that axis not stack

etimberg avatar Mar 23 '17 02:03 etimberg

@mvahsen doing what you are requesting shouldn't be a problem. Perhaps you just don't have the correct options configured (I did not look at them closely). Here is an example.

jordanwillis avatar Mar 23 '17 18:03 jordanwillis

Closing as out of date

etimberg avatar May 02 '17 00:05 etimberg