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

0 votes
3k views

It’s continuation of this question. I need to set text formatting in PriceLabelProvider for cursor label based on current step between nearest labels numbers. In my screenshot it would be 0.50. How can I get step between nearest labels numbers from code?

enter image description here

  • RTrade A asked 4 years ago
  • last active 4 years ago
0 votes
837 views

Hi,

When I did some practices with your example app, I found some features does not work as I expected.
Here is CandlestickChartFragment.java and I wrote additional lines on xAxis builder, yAxis builder and surface.chartModifiers,

public class CandlestickChartFragment extends ExampleBaseFragment {
    @BindView(R.id.chart)
    SciChartSurface surface;

    @Override
    protected int getLayoutId() {
        return R.layout.example_single_chart_fragment;
    }

    @Override
    protected void initExample() {
        PriceSeries priceSeries = DataManager.getInstance().getPriceDataIndu(getActivity());
        int size = priceSeries.size();

        final IAxis xAxis = sciChartBuilder.newCategoryDateAxis()
            .withVisibleRange(size - 30, size)
            .withGrowBy(0, 0.1)
            // Start additional lines
            .withAutoFitMarginalLabels(false)
            .withTextFormatting("yyyy-MM-dd")
            .withCursorTextFormating("MM-dd")
            // End additional lines
            .build();
        final IAxis yAxis = sciChartBuilder.newNumericAxis()
            // Start additional lines
            .withAutoFitMarginalLabels(false)
            .withTextFormatting("$ #.#")
            .withCursorTextFormating("#.#")
            // End additional lines
            .withGrowBy(0d, 0.1d)
            .withAutoRangeMode(AutoRange.Always)
            .build();

        IOhlcDataSeries<Date, Double> dataSeries = new OhlcDataSeries<>(Date.class, Double.class);
        dataSeries.append(priceSeries.getDateData(), priceSeries.getOpenData(), priceSeries.getHighData(), priceSeries.getLowData(), priceSeries.getCloseData());

        final FastCandlestickRenderableSeries rSeries = sciChartBuilder.newCandlestickSeries()
                .withStrokeUp(0xFF00AA00)
                .withFillUpColor(0x8800AA00)
                .withStrokeDown(0xFFFF0000)
                .withFillDownColor(0x88FF0000)
                .withDataSeries(dataSeries)
                .build();

        UpdateSuspender.using(surface, new Runnable() {
            @Override
            public void run() {
                Collections.addAll(surface.getXAxes(), xAxis);
                Collections.addAll(surface.getYAxes(), yAxis);
                Collections.addAll(surface.getRenderableSeries(), rSeries);
                Collections.addAll(surface.getChartModifiers(), sciChartBuilder.newModifierGroupWithDefaultModifiers()
                    // Start additional lines
                    .withCursorModifier().withShowAxisLabels(true).withShowTooltip(true).build()
                    // End additional lines
                    .build());

                sciChartBuilder.newAnimator(rSeries).withWaveTransformation().withInterpolator(new DecelerateInterpolator()).withDuration(3000).withStartDelay(350).start();
            }
        });
    }
}

The result is below picture. I also attached the same image.
https://imgur.com/a/5Eqo8Gd
Displayed xAxis values are [27 Sep, 04 Oct, 11 Oct, 18 Oct, 25 Oct, 01 Nov].

The problems are
1. xAxis(CategoryDate) tick values should be started with year, even though it does not have enough margin. It looks updated format is not applied.
2. Cursor should be shown on touch event, but it does not be displayed at all.

I ran above code on [Samsung Galaxy S9, API 26] and [Xiaomi Mi A1, API 25] and same problems are happened.

Could I know what I missed?

Showing 2 results
This template supports the sidebar's widgets. Add one or use Full Width layout.