SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

Answered
0
0

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

Version
2.5
Images
  • You must to post comments
Best Answer
1
0

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

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.