Pre loader

iOS Axis & Cursor Formatting via textFormatting/cursorTextFormatting or LabelProvider

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

Answered
0
0

I have a simple line renderable series in iOS with an SCIDateTimeAxis for X and an SCINumericAxis for Y. At this point all I’m trying to do is format the Y-axis labels and cursor labels as currency. According to the documentation, this should be as simple as:

yAxis.textFormatting = "$%f"

But it does not appear to properly use this formatting. The Y-axis is showing values like “$%f1400” when formatting a value for 14.

So, I instead attempted creating my own label provider by overriding SCINumericLabelProvider:

class CurrencyLabelProvider: SCINumericLabelProvider {

static let formatter: NumberFormatter = {
    let formatter = NumberFormatter()
    formatter.numberStyle = .currency
    return formatter
}()

override func formatLabel(_ dataValue: SCIGenericType) -> NSAttributedString! {
    let value = dataValue.doubleData
    let string = CurrencyLabelProvider.formatter.string(from: NSNumber(value: value))!
    return NSAttributedString(string: string)
}
}

Then assigning:

yAxis.labelProvider = CurrencyLabelProvider()

This works to properly format the axis labels. So, I also override SCINumericLabelProvider to provide the cursor labels:

 override func formatCursorLabel(_ dataValue: SCIGenericType) -> NSAttributedString! {
    let value = dataValue.doubleData
    let string = CurrencyLabelFormatter.formatter.string(from: NSNumber(value: value))!
    return NSAttributedString(string: string)
}

This then properly formats the cursor label for the Y-axis- but it also formats the X-axis cursor:
Formatted Cursor

At this point, the X-axis is already assigned an SCIDateTimeLabelProvider- the X-axis is not assigned CurrencyLabelProvider. But it seems to be overridden by the Y-axis label provider or simply unused. The X-axis labels are formatted as dates properly, but X-axis cursor values are just numbers when not being interfered with by the Y-axis label provider.

Am I misunderstanding something or are these all bugs in the iOS SDK? We’re currently evaluating whether this package will meet our needs and it certainly appears to be riddled with issues.

Version
2.2.2.2289
  • You must to post comments
Best Answer
2
0

Hello, Sean Young and Rich Wardwell.
Thank you for the reports.
There was a bug in SciChart, when the format of yAxis was used to display both cursor labels. This bug was fixed today, and the fix should be available in the latest nightly build (v2.2.2.2291).

Also, Sean Young, as for text formatting in general. In version 2.2 text formatting was refactoring and now axis.textFormatting is used by NSNumberFomatter, so the format “$%f” isn’t correct. (Documentation will be updated soon).
In an answer to this forum question, I’ve explained how the textFormatting property should be used. Please check, and let me know if more info is needed from our side.

Regards,
Andriy.

  • You must to post comments
0
0

I seem to have this issue too… I’m absolutely amazed that I searched for this 3 hours after you also ran into it, which makes me wonder if it is a regression. In my case, it seems to apply the label provider correctly in the little tooltips on the axes but the primary tooltip over the data is incorrect.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.