frappe / charts

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

Multi axis capability #160

Closed madmoizo closed 2 years ago

madmoizo commented 6 years ago

You talked about multi axis in https://github.com/frappe/charts/issues/93

But there is no reference to it in the doc, so I have a proposal:

{
    xAxis: [{
       id: 'bottom-axis',
       title: 'Time'
       position: 'bottom'
    }],
    yAxis: [
        {
            id: 'left-axis',
            position: 'left',
            title: 'Rate',
            unit: ['point', 'points'], // array with [singular, plural] or simple string for both
            // tooltipUnit: unit as default value 
            // tickUnit: unit as default value 
        },
        {
            id: 'right-axis',
            position: 'right',
            title: 'Price',
            unit: '$'
        }
    ],

    labels: [
        {
            axisID: "bottom-axis",  // refer to a xAxis id
            values: ["12am-3am", "3am-6am", "6am-9am", "9am-12pm", "12pm-3pm", "3pm-6pm", "6pm-9pm", "9pm-12am"]
       }
    ],

    datasets: [
       {
          axisID: "left-axis", // refer to a yAxis id
          name: "Some Data",
          chartType: 'bar',
          values: [25, 40, 30, 35, 8, 52, 17, -4]
        },
        {
          axisID: "left-axis",
          name: "Another Data",
          chartType: 'bar',
          values: [25, 40, 30, 35, 8, 52, 17, -4]
        },
        {
          axisID: "right-axis",
          name: "Another Data",
          chartType: 'bar',
          values: [25, 40, 30, 35, 8, 52, 17, -4],
        }
    }
}

there is an opportunity to solve https://github.com/frappe/charts/issues/128 too

pratu16x7 commented 6 years ago

Yes, I sure did :)

However, the implementation for it is a bit fuzzy, at what point are multiple axes too much? It probably wouldn't be reasonable to allow for the creation of too many axes. I had thought of implementing just 2-axis, but there are implementations out there of up to 4-5 (with single dataset per axis), and multiple datasets per axis would also affect readability. I'm not exactly sure how to decide the tradeoff.

Overall, I am happy about the code base structure in place currently, in that it is cleaner to read and won't need drastic refactors any time soon, and will finally be able to content myself with maintenance for some time; testing, docs, bug fixes, improving on existing features and so on, instead of feature additions (they have wrongly been the focus for far too long). I think if we can do that, it won't be long before people will be able to contribute features themselves.

Thanks for sticking around; I appreciate your support in this project 😀

caleuanhopkins commented 5 years ago

hey @pratu16x7 is this feature available as beta functionality or is it still unavailable to the public?

rvbd commented 4 years ago

Hi @pratu16x7 there is a note in #41 that this is implemented in V1, however I couldn't find a way to use it. Did this go out to production? If not then I will look into contributing if possible.

The library as it is, is already good btw. It's just that with data anlysis, sometimes 2 Y axis is required.

phoet commented 3 years ago

As an open-source maintainer, I understand the desire to reduce the amount of time that you need to dedicate to project. In order to do that and still be able to improve the library and adapt it to users needs, it would be helpful to give guidance to developers willing to implement the feature themselves.

I really like the simplicity of the library and the looks of the default charts. Unfortunately without the option of having at least two axis, it's not a fit for my usecase and probably a lot of others as well.

I'd like to show the total number of something, say infections, and the daily increase of cases. Since both numbers run out of scale quickly, the chart is unusable. I'm currently working around this by providing 2 different charts, but that is suboptimal.

Screenshot 2020-12-07 at 10 46 51

As you can see in the screenshot, it's basically impossible to see the difference in daily increase at a glance.

cujojp commented 2 years ago

Has there ever been any follow-ups to this? Looking around the docs and cannot find anything.