phibr0 / obsidian-charts

Charts - Obsidian Plugin | Create editable, interactive and animated Charts in Obsidian via Chart.js
https://charts.phib.ro/
GNU Affero General Public License v3.0
546 stars 25 forks source link

Chat.js Axis ID Issue that doesn't recognize non-default `x y r` axis IDs #81

Open RicSanOP opened 1 year ago

RicSanOP commented 1 year ago

I am using the advanced functionality of the plugin to renderRaw a chart that has a dual y-axis. However, after a lot of time trying to ensure that my formatting was correct, and playing around with axis IDs, it seems that the plugin or chart.js is unable to process axis that don't have the default IDs x, y, z. Although, I originally ran into this issue whilst using the window.renderChart function, here is an advanced-chart JSON config that simply does not render the points of non default axis IDs. I hope that there is a simple fix to this issue.

```advanced-chart
{
    "data": {
        "datasets": [
            {
                "type": "bar",
                "data": [{"x": 1, "y": 30}, {"x": 2, "y": 20}, {"x": 3, "y": 10}],
                "yAxisId": "y",
                "order": 0,
                "backgroundColor": "#00FF0080",
                "borderColor": "#00FF00"
            },
            {
                "type": "line",
                "data": [{"x": 1, "y2": 10}, {"x": 2, "y2": 10}, {"x": 3, "y2": 10}],
                "yAxisId": "y2",
                "order": 1,
                "backgroundColor": "#FF000080",
                "borderColor": "#FF0000"
            }
        ]
    },
    "options": {
        "responsive": true,
        "plugins": {
            "legend": {
                "position": "top"
            }
        },
        "scales": {
            "x": {
                "type": "linear",
                "position": "bottom"
            },
            "y": {
                "type": "linear",
                "position": "left"
            }, 
            "y2": {
                "type": "linear",
                "position": "right"
            }
        }
    }
}