Search code examples
javaandroidteechart

Bar.setBarStyle(BarStyle.RECTGRADIENT) does not work as intended


The gradient is erroneously painted using StartColor and Color. It does not respect the value of EndColor.

Bar bar = new Bar();
bar.setMultiBar(MultiBars.STACKED);
bar.setBarStyle(BarStyle.RECTGRADIENT);
bar.getGradient().setDirection(GradientDirection.VERTICAL);
bar.getGradient().setUseMiddle(false);

bar.getGradient().setStartColor(Color.fromArgb(0xff000000));
bar.getGradient().setEndColor(Color.fromArgb(0xffffff00));

// WORKAROUND: Setting the color yields a valid gradient.
// bar.setColor(Color.fromArgb(0xffffff00));

Android 4.1.2, Nexus S.


Solution

  • You are right. I've added it to the defect list to be revised for next releases. In the meanwhile, the workaround you suggested looks fine to me.