mariusmuntean / ChartJs.Blazor

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

Adding your own labels to Line Chart #82

Closed rollerolle2020 closed 4 years ago

rollerolle2020 commented 4 years ago

Hi,

Is it possible to change the labels on the x-axis in the Line chart? Right now it takes the points from the dataset and plots it on the y and x axis as labels. However, I want to change the x-axis labels into strings and show words instead of the numbers/point.

Server-side and client-side

Which charts is this question related to?

Line chart

Joelius300 commented 4 years ago

Thank you for your report.

I have just updated the github question template to include a very important piece of information. As per the new section, please include how to solve your issue with JavaScript code. We can help you translate your JavaScript/Chart.js code to C#/Chart.js.Blazor code but we're not chart.js-support. I hope you understand.

The added section is as follows:

JavaScript equivalent

If the question is "how can I do x?", then please include how you can do it with JavaScript by adding a link to a jsfiddle and pasting the code here. This library just acts as a bridge between Blazor (C#) and Chart.js (JavaScript) and we don't have the time to help you with questions that only relate to Chart.js and not this library. Thank you for your understanding.

Only if you're 100% certain that it doesn't make sense to include JavaScript code, remove this section.

rollerolle2020 commented 4 years ago

Hi Joelius300

I do not have a an equivalent to JavaScript. Using Blazor and this Nuget to avoid dealing too much with JavaScript.

I was just wondering if it is possible, as for a PieChart you can add string labels, but if I do the same for the Line chart as such :

_lineConfig.Data.Labels.AddRange(new[] { "Jan", "Feb", "Mar", "Apr", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" });`

It does not have any affect on the Line chart.

But if this is not something Blazor.ChartJS has been configured to do yet, I will not take any of your time. I was just wondering if this is even an option in Blazor.ChartJS.

Joelius300 commented 4 years ago

I'm assuming you mean something like this? This would be a category axis and you can use the class CategoryAxis in C# to achieve what you can see in that sample I linked. We don't have a category axis line-chart sample but it works the same way with the bar chart and there we have a sample you can check out.

I really don't want to be harsh but if that's the solution, I really think you could have figured that out by yourself. I have very little free time but I always try to answer the issues to this repo. It would make my life easier if people tried to solve the issue they're having themselfs first especially when there are so many great resources for chart.js freely available.

rollerolle2020 commented 4 years ago

Thank you for your time.