Pre loader

Tag: Y-Axis Formatting

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

0 votes
6k views

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.

  • Sean Young asked 5 years ago
  • last active 5 years ago
Showing 1 result

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies