I have a few problems that I’m trying to address with y-axis labelling.
- 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?
- 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?
- 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
)
}
- Marcela Guerra asked 4 years ago
- last edited 4 years ago
- You must login to post comments
Hi Paul,
-
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));
-
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);
-
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 answered 4 years ago
-
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
-
Ticket submitted: https://support.scichart.com/index.php?/Tickets/Ticket/View/46271
-
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”
-
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 )
-
Hi Yura, I don’t see a ticket for the issue regarding the gravity of multi-line labels on a y-axis
- 4 more comments
- You must login to post comments
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
- Yura Khariton answered 3 years ago
- You must login to post comments
Please login first to submit.