frappe / charts

Simple, responsive, modern SVG Charts with zero dependencies
https://frappe.io/charts
MIT License
14.94k stars 718 forks source link

stacked bars bug for negative value #147

Open joshreeder opened 6 years ago

joshreeder commented 6 years ago

Expected Behaviour

negative value bar shows below 0 line

Actual Behaviour

negative value bar shows same as positive value bar - above 0 line

screen shot 2018-04-02 at 4 29 56 pm screen shot 2018-04-02 at 4 30 23 pm
scmmishra commented 4 years ago

Unable to replicate the bug, can you provide more info

jdecourval commented 3 years ago

To replicate, just try to show two stacked bar datasets with one having negative values.

Here is an example that shows the issue on version 1.6.1:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="module">
    import {Chart} from './static/scripts/frappe-charts.esm.js';

    const data = {
        labels: ["12am-3am", "3am-6pm", "6am-9am", "9am-12am",
            "12pm-3pm", "3pm-6pm", "6pm-9pm", "9am-12am"
        ],
        datasets: [
            {
                name: "Dataset 1",
                values: [18, 40, 30, 35, 8, 52, 17, -4],
            },
            {
                name: "Dataset 2",
                values: [-10, -15, -2, 0, 0, -10, -60, -30],
            }
        ]
    }

    new Chart("#chart", {
        title: "My Awesome Chart",
        data: data,
        type: 'bar',
        height: 250,
        colors: ['#7cd6fd', '#743ee2'],
        barOptions: {'stacked': true}
    })
</script>
<div id="chart"></div>
</body>
</html>

Screenshot_2021-04-22_22-16-40

ivands commented 2 years ago

I can confirm. This is an issue. Hope it will be fixed soon.