Hi,
I’m using scichart for android and trying to change the color of the column that was hit by touch. I have successfully identified which index of the data series that was hit. I’ve looked all over the android documentation but does not find an answer or example for this. This is my onTouch function:
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
SciChartSurface surface = (SciChartSurface) view;
touchPoint.set(motionEvent.getX(), motionEvent.getY());
surface.translatePoint(touchPoint, surface.getRenderableSeriesArea());
for (IRenderableSeries renderableSeries : surface.getRenderableSeries()) {
renderableSeries.hitTest(hitTestInfo, touchPoint.x, touchPoint.y, 30);
if (hitTestInfo.isHit) {
Double yValue = consumptionDataSeries.getYValues().get(hitTestInfo.dataSeriesIndex);
// Todo: Show a text annotation and color the column differently
Toast.makeText(this.getContext(), yValue.toString(), Toast.LENGTH_SHORT).show();
}
}
return true;
}
What should I do next?
- Linnea Springare asked 2 years ago
-
Have you checked out the palette provider API? This is the way to colour columns or data points individually in SciChart https://www.scichart.com/documentation/android/latest/articles/chart2d/PaletteProvider%20API.html?tabs=java
-
Yes, but I did not find enough docuemtation and examples to understand how to implement it.
-
Hi Linnea, I’ll ask the team if they can put together a demo. In the meantime, look at our PaletteProvider examples https://www.scichart.com/example/android-chart/android-chart-example-using-paletteprovider/
-
Hi! I solved it using a custom PaletteProvider and setting the clicked index in the inTouch function above, and then calling update() and only color the clicked index differently. Thank you for the tip!
- You must login to post comments
Hi Linnea
That’s great you solve the issue. Can you share your code so that it can help other users too?
Thanks
- Bikrant Srivastwa answered 2 years ago
- last edited 2 years ago
- You must login to post comments
Please login first to submit.