mariusmuntean / ChartJs.Blazor

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

LineChart with Multiple Axes #151

Closed mariohik closed 3 years ago

mariohik commented 3 years ago

Describe your question

How can I set the Type = AxisType.Category?

Which Blazor project type is your question related to?

Which charts is this question related to?

Line

Additional context

I'm trying to set the Type = AxisType.Category, but it's readonly.

Property or indexer 'LinearCartesianAxis.Type' cannot be assigned to -- it is read only

mariohik commented 3 years ago

For help you guys unterstand me, I'm trying to achieve this graph Multiple Axes, with XAxes = Months

Joelius300 commented 3 years ago

I'm sorry, I don't quite understand your question. In order to achieve the multiple axis sample, you don't need to explicitly set the axis type.

Just use a single CategoryAxis in the XAxes and two LinearCartesianAxis in the YAxis. Then you can assign an id to an axis and use that same id in your dataset.

Check the source for the sample you sent (via GitHub or the devtools) and you'll see the config used. It's pretty much the same in C#, just different syntax and casing.

mariohik commented 3 years ago

Thank you! Worked.