Time Series Chart - Apply Different Color Scheme to New Trend

Just like the title says, is it possible to apply a different color scheme to each trend? I have 2 series and the first trend in each is green, they are different scales so they need to be on separate axes.

Hi Brandon,

This post might help you!

I managed to make a red and blue by adding values to underneath the colors property:

1 Like

Thanks for the response. This works (as well as changing the colorScheme) for multiple trends in a single series.

However, it doesn’t apply the second color to the first trend in a second series. What I need to do is apply a different colorScheme to the second series instance.

Hi,
Same problem for me. Add manually colors in defaultStyles >colors doesn’t work.


Can you help me ?
Thanks

1 Like

I am also looking to have separate colors for different trends.

I believe I have found a solution.

By inserting blank columns, you can "skip" colors in the trend.

However, the only problem with this, is that the "blank" columns are added to the legend. I have not found a way to hide individual items from the legend. However you could hide the legend, and make your own legend to get around this..

On the binding to the series data add the following script to a script transform. Then in the script, indicate which color you want by changing the value of "requested_color" (0 based).

	
	requested_color = 1
	
	if requested_color > 0:	
		table_headers = list(value.getColumnNames())
		
		headers = []
		for table_header in table_headers:
			headers.append(table_header)
		
		for i in range(requested_color):
			headers.insert(1,"blank"+str(i))
		
		
		data=[]
		for i in range(value.getRowCount()):
			thisrow = []
			for header in table_headers:
				thisrow.append(value.getValueAt(i, header))
				
			for i in range(requested_color):
				thisrow.insert(1,None)
			
			data.append(thisrow)
	
		return system.dataset.toDataSet(headers, data)
	
	else:	
		return value

Unfortunately, I don't believe you are able to assign a colorScheme style attribute to series that share a plot (perhaps this should be added in the future). My workaround was to utilize the trends array property configured on a plot to assign a series to an axes. I was then able to reference the key of the column for the series and override the default color assigned to the pen. This key is the column name of the serie's returned dataset. This way you have to explicitly define each pens' color but is a bit cleaner than the above post's approach.

1 Like