Charts Shinobi iOS图表中的限制轴范围值
我正在使用Shinobi iOS控件在我的应用程序中绘制折线图。我目前正在渲染一个0的值。生成的图形如下所示: 现在,问题是我所代表的数量是一种货币,所以它不能是负数。在这种特定情况下,如何将范围限制为从0开始 以下是我创建图表的方式:Charts Shinobi iOS图表中的限制轴范围值,charts,shinobi,Charts,Shinobi,我正在使用Shinobi iOS控件在我的应用程序中绘制折线图。我目前正在渲染一个0的值。生成的图形如下所示: 现在,问题是我所代表的数量是一种货币,所以它不能是负数。在这种特定情况下,如何将范围限制为从0开始 以下是我创建图表的方式: // initiatialise line chart ShinobiChart *chartView = [[ShinobiChart alloc]initWithFrame:frame]; chartView.clipsToBoun
// 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;
yAxis.anchorPoint=@0
设置此选项,它将解决您的问题。我使用的是一个简单的ShinobiChart子类。通常,范围始终在W最低值和最高值之间。现在,图形的反应是有意义的,因为在这种情况下没有提供极值,但我更愿意将最低极值设置为0。您是对的…完成:)当您初始化yAxis SChartNumberAxis时,您可以尝试使用initWithRange:instance方法和适当的SChartNumberRange。是,我现在正在尝试,但我不想静态地设置top值,因为它应该由我的数据集定义。我也可能在某一点上有负值。当数据集仅包含正值时,我希望有一个[0,max_value]范围;当值均为零时,我希望有一个[0,5]范围。您可能需要首先从数据集获取高/低值(如果此方法确实有效)。