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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy

We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

0
1

I want to display auto format date on xAxis (DateAxis) while zooming but I cannot find SubDayTextFormatting function.Is there any way to display minutes and seconds after init months ?there is no DateTime Axis on Android like on iOS ..Should I change to CategoryDate Axis?

Thanks in advance

Version
1.0.0.1063
  • You must to post comments
1
0

Update: Turns out the API is slightly different to the above. The Android team informs me:

Default SciChart label providers don’t use formatLabel/formatCursor because of performance reasons – formatting of labels is one of the slowest operation because we use standard Java Format implementations support standart format strings and they are really slow. If you want to implement custom label formatter which will use formatLabel then I would suggest to start from class similar to this one:

class CustomLabelProvider extends LabelProviderBase {

    // list with all formatted tick labels - we format them once and store them for further reusage
    private final List<String> formattedTickLabels = new ArrayList<>();

    @Override
    public void update() {
        super.update();

        // clear old labels
        formattedTickLabels.clear();

        // iterate over ticks and format them
        final AxisTicks ticks = axis.getTickProvider().getTicks();
        final DoubleValues majorTicks = ticks.getMajorTicks();
        final int size = majorTicks.size();
        final double[] majorTicksArray = majorTicks.getItemsArray();

        for (int i = 0; i < size; i++) {
            final double valueToFormat = majorTicksArray[i];
            final String formattedValue = formatLabel(valueToFormat);
            formattedTickLabels.add(formattedValue);
        }
    }

    @Override
    public String formatLabel(Comparable dataValue) {
        return dataValue.toString() + " vvvv";
    }

    @Override
    public String formatCursorLabel(Comparable dataValue) {
        return dataValue.toString() + " vvvv";
    }

    @Override
    public List<String> getFormattedTickLabels() {
        return formattedTickLabels;
    }
}

From this hopefully you should be able to format labels dynamically. Don’t forget you can access the axis instance from the base class (it’s a protected field) so you can call axis.getVisibleRange() to know how zoomed in you are when formatting labels.

Best regards,
Andrew

  • You must to post comments
0
0

Hi Patrik,

The current convention for modifying DateTimeAxis formatting dynamically is to use the LabelProvider API.

To use this:

  1. Create a class which inherits DateLabelProvider
  2. Override formatLabel and formatCursorLabel
  3. Also override attachToAxis. Here you can grab a reference to the axis. When formatting labels you can call axis.getVisibleRange() to know the current range before formatting.
  4. Attach your class to DateTimeAxis.setLabelProvider

Let me know if this helps.

Best regards,
Andrew

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.