Hi,
I want to select the high value of the point that appears when I move my finger while holding the screen on the candlestick chart. I wrote the Custom RolloverModifier but the result has not changed. How can i change the default point position?
public class CustomRolloverModifier extends RolloverModifier
{
private final HitTestInfo hitTestInfo = new HitTestInfo();
SciChartFragmentUI sciChartFragmentUI;
public CustomRolloverModifier(SciChartFragmentUI sciChartFragmentUI)
{
this.sciChartFragmentUI = sciChartFragmentUI;
}
@Override
protected void updateCurrentPoint(PointF currentPoint, ModifierTouchEventArgs args)
{
try
{
getParentSurface().getRenderableSeries().get(0).hitTest(hitTestInfo, currentPoint.x, currentPoint.y, 0);
double data = sciChartFragmentUI.ohlcDataSeries.getHighValues().get(hitTestInfo.dataSeriesIndex);
ICoordinateCalculator coordCalc = sciChartFragmentUI.yAxis.getCurrentCoordinateCalculator();
currentPoint.y = coordCalc.getCoordinate(data);
super.updateCurrentPoint(currentPoint, args);
}
catch (Exception ex)
{
Log.e("updateCurrentPoint: ", ex.getMessage());
}
}
}
Tnx
- Emre Gökberk asked 4 years ago
- You must login to post comments
Hi Emre
In your case super.updateCurrentPoint(currentPoint, args) call will override your changes. By default this method translates coordinates from charts space, which includes axes into renderable series area space ( center of chart where series are rendered ). I would suggest to try to move super.updateCurrentPoint() call before hittesting chart. Also I would suggest to use verticalSliceHitTest() for your case:
super.updateCurrentPoint(currentPoint, args);
getParentSurface().getRenderableSeries().get(0).verticalSliceHitTest(hitTestInfo, currentPoint.x, currentPoint.y);
ISmartList<Double> xValues = sciChartFragmentUI.ohlcDataSeries.getXValues();
double data = xValues.get(Math.min(hitTestInfo.dataSeriesIndex + 1, xValues.size() - 1); // offset by one data point, but ensure that we don't get outside data bounds
ICoordinateCalculator coordCalc = sciChartFragmentUI.xAxis.getCurrentCoordinateCalculator();
currentPoint.x = coordCalc.getCoordinate(data);
Hope this will help you!
Best regards,
Yura
- Yura Khariton answered 4 years ago
- last edited 4 years ago
-
Hi Yura; Thanks for your answer. I’m copy-paste your code to updateCurrentPoint Override method. But nothing has changed; The green dot still selects the Open value of the candlestick bar. It does not select High. When I debug the code, I see that I get the high value at the point I pressed. However, I cannot set the green dot to this value.
-
Hi Emre, I updated my response. Nothing changed because your original code uses results of hit test without modification, so as result dataSeriesIndex returns the same value as original rollover code. I added offsetting of data point. Also to shift rollover horizontally you need to change x coord instead of y ( unless you’re using vertical chart ). So I replaced updating of coords from Y to X axis. Can you try it now?
-
@Yura; Yes i don’t modified my hit test (except for the use of verticalSliceHitTest) because ohlcDataSeries.getHighValues().get(hitTestInfo.dataSeriesIndex) returns the correct high value where i’m click. Likewise if i want to get Low,Close or Open values get..Values methods return correct value. I tried to find the coordinate of this value and assign it to the green dot. In your code: sciChartFragmentUI.ohlcDataSeries.getXValues() returns Date but ISmartList xValues is a Double List. Because of that it gives an error.
-
Well if you want to adjust the position of rollover marker, then it should be done on level of individual series ( by creating custom SeriesInfoProvider like here https://www.scichart.com/example/android-chart-custom-rollovermodifier-example/ ). For example you can override https://www.scichart.com/documentation/android/current/webframe.html#SciChart.Charting~com.scichart.charting.visuals.renderableSeries.tooltips.SeriesTooltipBase~onDrawTooltipOverlay(Canvas,PointF,int).html for OhlcSeriesTooltip and adjust point coords. Regrding Double vs Date – you can use ComparableUtil to convert it to double ( https://www.scichart.com/documentation/android/current/webframe.html#SciChart.Core~com.scichart.core.utility.ComparableUtil~toDouble(Comparable%7B%7D).html )
-
@Yura; I create a CustomOhlcSeriesInfoProvider class and override onDrawTooltipOverlay method. Now i can able to set green dot position with Changing methods’s xyCoordinate parameter. Tnx.
- You must login to post comments
Please login first to submit.