0
我使用Shinobi iOS控件在我的应用程序中绘制折线图。我目前正在渲染一个严重的0值。结果图是这样的:Shinobi限制轴范围值iOS图表
现在的问题是,我代表数量的货币,因此不能为负数。在这种特定情况下,我如何限制范围从0开始?
这是如何创建的图形:
// initiatialise line chart
ShinobiChart *chartView = [[ShinobiChart alloc]initWithFrame:frame];
chartView.clipsToBounds = NO;
//Choose the light theme for this chart
SChartLightTheme *theme = [SChartLightTheme new];
//perform any theme stylign here before applying to the chart
chartView.theme = theme;
chartView.title = @"my Title";
chartView.autoresizingMask = UIViewAutoresizingNone;
// Use a number axis for the x axis.
SChartDateTimeAxis *xAxis = [[SChartDateTimeAxis alloc] init];
xAxis.title = @"date";
xAxis.tickLabelClippingModeHigh = SChartTickLabelClippingModeTicksAndLabelsPersist;
//keep tick marks at the right end
//Make some space at the axis limits to prevent clipping of the datapoints
xAxis.rangePaddingHigh = [SChartDateFrequency dateFrequencyWithDay:1];
xAxis.rangePaddingLow = [SChartDateFrequency dateFrequencyWithDay:1];
//allow zooming and panning
xAxis.enableGesturePanning = YES;
xAxis.enableGestureZooming = YES;
xAxis.enableMomentumPanning = YES;
xAxis.enableMomentumZooming = YES;
chartView.xAxis = xAxis;
// Use a number axis for the y axis.
SChartNumberAxis *yAxis = [[SChartNumberAxis alloc] init];
yAxis.title = @"Value";
yAxis.enableGesturePanning = YES;
yAxis.enableGestureZooming = YES;
yAxis.enableMomentumPanning = YES;
yAxis.enableMomentumZooming = YES;
yAxis.title = @"Value";
yAxis.style.titleStyle.position = SChartTitlePositionBottomOrLeft;
chartView.yAxis = yAxis;
chartView.userInteractionEnabled = YES;
chartView.gesturePanType = SChartGesturePanTypeNone;
我使用了一个简单的ShinobiChart子类。通常范围始终在最低和最高值之间。现在图表反应是这样的,因为在这种情况下没有提供极端值,但我更愿意将最低极值设置为0. – Claus
您是对的......完成:) – Claus
当您初始化yAxis SChartNumberAxis时可以尝试使用具有适当SChartNumberRange的initWithRange:instance方法。 –