mariusmuntean / ChartJs.Blazor

Brings Chart.js charts to Blazor
https://www.iheartblazor.com/
MIT License
676 stars 151 forks source link

Support to add data with specified x- and y-values? #197

Closed fredblom closed 2 years ago

fredblom commented 2 years ago

Describe your question

Is there support to add data with specified x- and y-values instead of adding data and labels separately?

Which Blazor project type is your question related to?

Which charts is this question related to?

All charts

JavaScript equivalent

In chart.js it can be accomplished like this: datasets: [ { label: "my series", data: [{x: "March", y: 150}, {x: "April", y: 200}] }, ...

Looking to find a way to plot datasets where they all don't have the same count of labels and values. Thank you for any help or workarounds.

fredblom commented 2 years ago

The workaround i found to work was to use int? for my datapoint values instead of a regular int. This way, it's possible to set individual datapoint values to null, meaning they will appear as empty "gaps" in the chartJs dataset. This technique is useful to match dataset lengths by simply providing a datapoint with a null value whenever you want to leave an empty gap in a dataset.