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

0
0

I have a few problems that I’m trying to address with y-axis labelling.

  1. I am including a y-axis on the left side of my graph but want the text of the labels to be right-aligned. Each label uses two lines of text. How can I do that?
  2. I want the margin of the text to be a specific width so that I can line up the y-axis of multiple scichart surfaces that are stacked vertically. How can I set each of my scichart surfaces to use a particular margin for the y-axis labelling?
  3. The y-axis label text will wrap when I don’t want it to (see attached image — The text of the label should be “1m \n Left” and I am currently seeing “1m \n Lef \n t”). How do I turn off the wrapping of text on the y-axis?

———-

This is how I am currently implementing the y-axis:

NumericAxis(context).apply {
    drawLabels = true
    axisAlignment = AxisAlignment.Left
    this.labelProvider = labelProvider
    this.tickProvider = tickProvider
    drawMajorBands = false
    drawMajorTicks = false
    drawMinorTicks = false
    drawMajorGridLines = false
    drawMinorGridLines = false
    isLabelCullingEnabled = false
    visibleRange = DoubleRange(
            dataRange.first,
            dataRange.second
    )
    autoRange = AutoRange.Never
    tickLabelStyle = FontStyle(
            TypefaceManager.obtainTypeface(context, CustomTypeface.PROXIMA_NOVA_REG),
            context.resources.getDimension(R.dimen.results_screen_graph_labels_text_size),
            Color.LTGRAY
    )
}
Version
2.2.2.2459
Images
  • You must to post comments
1
0

Hi Paul,

  1. Please try to use AxisTickLabelStyle property and set gravity applied to labels during layout:

    yAxis.setAxisTickLabelStyle(new AxisTickLabelStyle(Gravity.CENTER_VERTICAL | Gravity.END, 5, 0, 5, 0));

  2. Please try to use SciChartVerticalGroup class. You can find example here. We used it in this example to synchronize width of axes between chart panes.

    // declare it somewher in Fragment/Activity
    private final SciChartVerticalGroup verticalGroup = new SciChartVerticalGroup();
    // add SciChartSurface which should be in sync with other charts in group
    verticalGroup.addSurfaceToGroup(surface);
    
  3. May I ask what version of SciChart do you use? I believe we recently fixed an issue related to measuring text in axes and it should be available with latest version from our Maven repository

Best regards,
Yura

  • Yura Khariton
    I took a look on issue #1. It looks like AxisTickLabelStyle works as it should ( it aligns rect used to render tick label with specified gravity ), but in case of multiline text it doesn’t help to achieve desired behavior, because it requires applying another alignment for text within tick label bounds. I’m sorry, but we don’t have exposed property for modifying this internal text alignment for now. I’m going to create a task to add it into our bugtracker
  • Paul Bonneville
  • Paul Bonneville
    Hi Yura, is there some way that I can see the status of the ticket that you submitted this in this comment: “I took a look on issue #1. It looks like AxisTickLabelStyle works as it should ( it aligns rect used to render tick label with specified gravity ), but in case of multiline text it doesn’t help to achieve desired behavior, because it requires applying another alignment for text within tick label bounds. I’m sorry, but we don’t have exposed property for modifying this internal text alignment for now. I’m going to create a task to add it into our bugtracker”
  • Yura Khariton
    You can take a look on your ticket’s status on https://support.scichart.com/ ( you’ll need to login and there should be ‘My Tickets’ button on main page )
  • Paul Bonneville
    Hi Yura, I don’t see a ticket for the issue regarding the gravity of multi-line labels on a y-axis
1
0

Hi Paul,

Regarding issue with changed behavior after update from v2 to v4.

Labels are different because in v3 we’ve added SubDayTextFormatting property for DateAxis . So now by default for DateAxis TextFormatting is applied when VisibleRange for axis has more than one day of data to display, and if there is less than one day then we use SubDayTextFormatting to format axis tick labels. To get behavior from v2 you can set same formatting string for both TextFormatting and SubDayTextFormatting.

Best regards,
Yura

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.