Controlling Color in Line series


#1

Im running into an issue when setting Line colors, I’ve been playing around with it a while and wondering if its a possible bug.

Basically the Line Color is not being set to what I specify, and it is being set to the same as the area around the legends border, the keys border specifically, which Im also not setting.

I have code like this

//Red defined as <color name="Red">#FF0000</color>

int color = getResources().getColor(R.color.RED);

shinobiSeries = new LineSeries();
shinobiSeries.setTitle("Title";
shinobiDataAdapter = new SimpleDataAdapter<Double, Double>();
shinobiSeries.setDataAdapter(shinobiDataAdapter);

LineSeriesStyle lss = shinobiSeries.getStyle();

lss.setAreaColor(color); //The TOP of gradient
lss.setLineColor(color);
lss.setAreaColorGradient(Color.TRANSPARENT); //Bottom of gradiant
lss.setFillStyle(FillStyle.GRADIENT);

My legend is styled as so:

Legend legend = shinobiChartLandscape.getLegend();
			legend.setPlacement(Placement.INSIDE_PLOT_AREA);
			legend.setPosition(Position.TOP_LEFT);
			
			
			legend.setMaxSeriesPerRow(1);
			
			
			legend.setVisibility(1);	
			
			LegendStyle ls = legend.getStyle();
			ls.setTextColor(Color.WHITE);
			ls.setPadding(0);
			ls.setBackgroundColor(Color.TRANSPARENT);
			ls.setBorderColor(Color.TRANSPARENT);
			ls.setTextSize(10f);
			ls.setSymbolLabelGap(0);
			ls.setBorderWidth(0);
			ls.setSymbolCornerRadius(5f);
			ls.setRowVerticalMargin(0);

You can see a picture here of what it displays (http://imgur.com/nmpKuJM)   The Legend and fill area are correctly set to RED (#FF0000) while the line and Legend key box are set to sometwhere around #202020, which I have not defined anywhere.

Im wondering if its possible that somewhere the color is accidently set to an ID rather than converting the ID to a color?  Ive seen results like this before in that case.

I’ve searched my code, and cant find the source of error, not saying its not there though :slight_smile:


#2

Hi AEB,

Thanks for all the detail - really helps us get to the bottom of any issues our users are having!

As you’re setting an area color on your LineSeries, you’ll need to call setAreaLineColor(int) on the LineSeriesStyle object rather than setLineColor(int) - the latter will be ignored if you are setting an area color on your series. This mirrors the ShinobiCharts for iOS API.

The corresponding legend item for the line series will then take it’s border color from the areaLineColor that you set - the color you’re currently seeing is the default areaLineColor.

I hope that helps! Do let us know if that doesn’t fix your problem.

Thanks,

Pat


#3

Thank you Pat, that worked exactly as you described.  I just needed to RTFM :slight_smile:


#4

Ha! No worries at all… I’d be lying if I said that had never caught me out before! :wink: