DHDynamicLineChart 1.0.1

DHDynamicLineChart 1.0.1

测试已测试
语言语言 Obj-CObjective C
许可协议 MIT
发布最后发布2017年4月

SilentCaaaaat维护。



  • David Hu

特性

此图表允许您

  • 自定义线条的控制位置。
  • 在运行时动态控制转折点。
  • 在运行时更新x/y轴的标签。

并且它可以

  • 自动调整不同尺寸的视图(Autolayout)。

演示

img

安装

简单用法

  • 只需将文件夹DHDynamicLineChart拖入您的项目,并在您的文件中导入DHDynamicLineChart.h
      #import "DHDynamicLineChart.h" 
  • 您还需要将CoreGraphic库添加到您的项目中。

使用方法

  • 初始化
        _xAxisLabels = @[@"125",@"250",@"500",@"1000",@"2000",@"4000",@"8000",@"10000"];//Label titles
        _yAxisLabels = @[@"0",@"-20",@"-40",@"-60",@"-80",@"-100",@"-120",@"-140"];
        _positions = @[@0,@(1.0/7),@(2.0/7),@(3.0/7),@(4.0/7),@(5.0/7),@(6.0/7),@1];

        _myLineChart = [[DHDynamicLineChart alloc] initWithXAxisLabelTitles:_xAxisLabels
                                                           yAxisLabelTitles:_yAxisLabels
                                                     controlPointsByXRatios:_positions
                                                                  direction:DHDyanmicChartDirectionDown];//Facing up or down.
        //Set grid line and line...

        [self.view addSubview:_myLineChart];

_positions数组通过x轴的比率指示控制位置。

  • 在不同位置控制线条
        [self.myLineChart refreshLineChartWithYRatio:yRatio atIndex:index];

        or
        [self.myLineChart refreshLineChartWithYRatios:yRatios];

“索引”指示控制点的顺序。“yRatio”表示“实际值”/“最大值”([0,1])。

  • 更新x/y轴的标签
        //X
        [self.myLineChart updateWithXAxisLabelTitles:xNewYLabels];
        //Y
        [self.myLineChart updateWithXAxisLabelTitles:yNewYLabels];
        //Or
        [self.myLineChart updateWithXAxisLabelTitles:xNewlabels
                                    YAxisLabelTitles:yNewLabels
                              controlPointsByXRatios:newControlXRatios
                                           direction:newDirection
                                            animated:YES
                                          completion:nil];
  • 当您更新标签时,您可能希望更新控制点
        [self.myLineChart updateWithControlPointsByXRatios:xNewRatios];
  • 如果您想要将图表颠倒过来
        [self.myLineChart switchDirectionAnimated:YES completion:^(DHDynamicLineChart * _Nonnull chart) {
                //Do some additional settings with 'chart'.
        }];
  • 查看更多详细信息的演示。享受!

许可协议

此存储库受MIT许可协议的约束。