HighCharts (Pie) defining color.

  

I am having trouble with the color on my UI, specifically matching the pie chart color and keeping it consistent. 

  • I cannot set the color on my pie chart. I would like to set them to be a pre-defined entity, to match other elements at the top of the UI. These entities are shown below and elsewhere I set the color to Entities.Color.Blue to achieve this. Is there a solution, possibly to use AdvancedFormat, to define the color of each chart slice to be one of these entities? 

  • Also, currently the default colors are rotating through each slice of the chart. In the screenshot, 'disapproved' is red above, yet blue in the chart. I understand this is an issue with the chart.colorCounter not being reset, but am not sure where to fix it. I would like them to be consistent. 

Thanks in advance for any insight.

Hi William,

If you don't explicitly set the chart's colours, the Platform will just pick some colours, independently of any other colours that might be on your Screen. There's no way for the chart component to know you've used a toned red for "disapprove", you'll have to explicitly tell it.

On how to set colours for a chart, see e.g. here.

Hi Kilian, 

Thank you for the linked discussion. I understand J's approach to setting the series color and have looked at his example oml, however I cannot figure out how to use AdvancedFormat_Init. Specifically how do I add records to advanced format as J has done below? 

"using the advancedFormatInit.

add per series an record to the advancedseries_format.

simply do

name : your series name

seriesJSON: "{color: #ffd900}"


Solution

Hi William,

Perhaps you didn't notice, but J added an OML that shows it :). AdvancedFormat_Init has an Input Parameter, DataSeriesFormats, that is a List of AdvancedDataSeriesFormat Structures (actually a Record List, as the Action was introduced pre-P10). To create the List, add a Local Variable of type AdvancedDataSeriesFormat, and a Local Variable of type AdvancedDataSeriesFormat List. For each series you want to set the colour of, set the DataSeriesJSON Attribute of the Local Variable to "{color: seriescolour}" (where seriescolour is the desired colour), and ListAppend the Local Variable to the Local Variable List. Then, pass the List to the DataSeriesFormats Input Parameter of the AdvancedFormat_Init Action.

Solution

I have completed everything described above. Do I have to set the DataSeriesName for each DataPoint prior to adding each Name/Color record? Within the preparation, I do not think my assignments are correctly referencing the DataSeriesName.

Hi Wiliam,

All DataPoints with the same DataSeriesName belong to a single series. The colour for that series is determined by the AdvancedDataSeriesFormat for that data series (with the same DataSeriesName as your DataPoints). Since both the data points (via the SourceDataPoint Input Parameter) and the advanced format (via the AdvancedFormat Input Parameter) are passed to the chart at the same time, the order in which you prepare them is inconsequential.

Hi William,

Were you able to make this work for Pie Chart? I was able to make it work for the column chart but when I applied it for a pie chart, app is still using the default colors.

Please advise.

Regards,

Rom

Hi Romuel,

For pie charts things work differently, as you only have a single series, and you don't want a colour per series, but a colour per datapoint. For a pie you need to set the pie colours.

Thanks, Kilian. Was able to make it work now.