UrielArellano111
Posts: 3
Joined: Tue Feb 28, 2023 4:28 pm

Categories not detected "

I have the following problem:
I am extracting from the backend an array like this: ["January 2022", "Februay 2022", "March 2022", ........ "December 2023"]
For the backend I am using ASP . Net with MVC. The problem is when I extract the data from the controller to the view, I extract it with VIEWBAG but apparently the "categories: " section does not detect the quotes and puts them as " and this is a problem since in my graph instead of detecting the quotes it literally puts "
jakub.s
Posts: 1164
Joined: Fri Dec 16, 2022 11:45 am

Re: Categories not detected "

Hi,

Welcome to our forum & thanks for the question.

Could you please write me an example of what are you passing to the xAxis.categories?

xAxis.categories accepts an array of strings (https://api.highcharts.com/highcharts/xAxis.categories)

And everything seems to work fine here (even with "): https://jsfiddle.net/BlackLabel/0x9adwjf/

Regards,
Jakub
Jakub
Highcharts Developer
UrielArellano111
Posts: 3
Joined: Tue Feb 28, 2023 4:28 pm

Re: Categories not detected "

The problem is that it is sending me the parameters of the graph like this:
erroredit.png
erroredit.png (10.39 KiB) Viewed 1593 times
And when viewing the source code of the page it appears like this:
error2.png
error2.png (23.15 KiB) Viewed 1593 times
In the code I have it like this:
errorcodigo.png
errorcodigo.png (14.17 KiB) Viewed 1593 times
It should be noted that I have this viewBag with single quotes, since if I leave it without quotes, the word """ is not detected. therefore it does not generate the "" that are inside my array and it does not show me the graph
UrielArellano111
Posts: 3
Joined: Tue Feb 28, 2023 4:28 pm

Re: Categories not detected "

The example of the ViewBag without single quotes is like this:
errorcodigosincomillas.png
errorcodigosincomillas.png (13.77 KiB) Viewed 1593 times
errorsincomillasfuemnte.png
errorsincomillasfuemnte.png (23.98 KiB) Viewed 1593 times
It seems to be fine but it doesn't show me the graph because, as I had mentioned before, the word """ it does not detect it
jakub.s
Posts: 1164
Joined: Fri Dec 16, 2022 11:45 am

Re: Categories not detected "

Well, it does not seem to be a problem with Highcharts, but with your config.

As I've mentioned in the previous post, xAxis.categories accepts only an array of strings. You're not passing an array of strings.

How about fetching this data from the server before creating a chart and preprocessing it with a simple function?

Here's an example how you could preprocess your data: https://jsfiddle.net/BlackLabel/Lwjo7g8x/

This way, you have an array of strings that you can pass to xAxis.categories and everything will be working fine.

Let me know if you encounter any problems with this.

Regards,
Jakub
Jakub
Highcharts Developer

Return to “Highcharts Gantt”