How is your experience with the OutSystems Community?
11
Views
8
Comments
How to assign distinct colors per user in Highcharts (ODC)?
Question

I have a multi‑series chart where each series represents a user. I want every user to have a clearly distinct and stable color, regardless of filters or data order.

My question: How can I correctly modify the Highcharts config in ODC to assign a unique color per user (per series)?



2021-09-06 15-09-53
Dorine Boudry
 
MVP

I'm assuming you would have a place to attach a color to each user (like in a user_settings table or something like that) ?

From the dataAction fetching the chart datapoints, add as extra export a list of a structure {seriesname, color} for the users that have datapoints in your current chart (or for all if you always want to see all users in your legend)

add a list widget with in there a ChartSeries block in the addon section of your chart.

2023-09-06 07-26-35
Sudip Pal

Hey @Michal Konwerski 

How many series you have? are they fixed or dynamic? 

Thanks,

Sudip

UserImage.jpg
Michal Konwerski

Hey @Sudip Pal 

I have a dynamic number of series.  

Each series represents a user, and the list of users changes depending on filters.

So the number of series is not fixed and the order also changes.

What I need is:

each user should always have a distinct and stable color, even when the number of users or their order changes.

Thanks,

Michał

2023-09-06 07-26-35
Sudip Pal

@Michal Konwerski 

How many series is possible? Do the users have their ID? 

I can create a logic which can take care of 50-200 series after filtering. But if you need more than that then colors will look like similar visually, but hex code will be different.

Thanks,

Sudip


UserImage.jpg
Michal Konwerski

@Sudip Pal 

We can have about 35 series now, but the number is not fixed. It depends on which users are selected in the filters. Yes, every user has a unique ID.

2023-09-06 07-26-35
Sudip Pal

Hey @Michal Konwerski 

Have a look on the below OML. If you need any help let me know.

Thanks,

Sudip

Charts.oml
2021-09-06 15-09-53
Dorine Boudry
 
MVP


@Sudip Pal ,

coloring a whole series is not done by coloring all individual data points.


UserImage.jpg
vikas sharma
Champion

I think simply you should attach one color with each user, It may be done at entity level. While creating series you just need to pass the color code with each user. If don't want to add color with user then at the time of data series creation you can pass color code.

May be you can create a client action as function and call that function here to assign some color code to user it may be random.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.