How to show integers, not decimal numbers, on the Core Plot Y axis?

I draw a line graph when using Core Plot, and I want the Y axis labels to display as integers. For example, my range is from 0 to 10 with an interval of 1, but the labels currently show axis labels 1.0, 2.0, 3.0, etc.

How to make Core Plot show tags like 1, 2, 3 and so on?

+4
source share
2 answers

Set the labelFormatter (and minorTickLabelFormatter if you assign labels to minor ticks) value on the axis. These are standard NSNumberFormatter objects.

+3
source

I just post the code here, I have the same problems as before and solved it, but now I have forgotten what change I made, please look at the code below, you will get the exact solution what you want.

It works great, just need to test with this ...

 NSNumberFormatter *yAxisFormat = [[[NSNumberFormatter alloc] init] autorelease]; [yAxisFormat setNumberStyle:NSNumberFormatterNoStyle]; CPXYAxis *y = axisSet.yAxis; y.axisLineStyle = lineStyle; y.majorTickLineStyle = nil; y.minorTickLineStyle = nil; y.majorIntervalLength = CPDecimalFromString(@"20"); y.orthogonalCoordinateDecimal = CPDecimalFromString(@"0"); y.title = @"Number of Cards Learned"; y.titleOffset = 45.0f; y.titleLocation = CPDecimalFromFloat(50.0f); y.labelFormatter = yAxisFormat; 

if further problems then just let me know.

+5
source

Source: https://habr.com/ru/post/1396761/


All Articles