sgratzl / chartjs-chart-boxplot

Chart.js Box Plots and Violin Plot Charts
https://www.sgratzl.com/chartjs-chart-boxplot/
MIT License
101 stars 23 forks source link

Scale issue #122

Closed aspirew closed 1 month ago

aspirew commented 1 month ago

I cannot scale chart properly for following configuration:

    const chartConfig: ChartConfiguration<"boxplot"> = {
        type: 'boxplot',
        data: {
            labels: ["column"],
            datasets: [
                {
                    label: "labels",
                    data: [[1,2,3], [3,4,1], []],
                    borderColor: colors[0],
                    backgroundColor: colors[0],
                }
            ]
        },
        options: {
            minStats: 'whiskerMin',
            maxStats: 'whiskerMax',    
        }
    };

I expect chart to start at 1 and end on 3. Looks like it remains with default configuration:

image

sgratzl commented 1 month ago

I think two things are happening here

e.g.

window.onload = () => {
  const ctx = document.getElementById("canvas").getContext("2d");
    new Chart(ctx, {
        type: 'boxplot',
        data: {
            labels: ["column"],
            datasets: [
                {
                    label: "labels",
                    data: [[1,2,3,3,3,3, 10]],
                }
            ]
        },
        options: {
            minStats: 'whiskerMin',
            maxStats: 'whiskerMax',
            scales: {
              y: {
                beginAtZero: false
              }
            }
        },
    });

};

results in

image

aspirew commented 1 month ago

Yes, it affects all the data so you need to keep an eye on that. It also didnt work for me without 'beginAtZero' property, looks much better now. Thank you, great project :)