#ORCharts

This article is a detailed description of ORCharts: curves and line charts

Related links

  • GitHub
  • ORCharts
  • ORCharts: ring charts, pie charts, pie charts

Results the preview


Slider Control
config


The installation


pod 'ORCharts/Line'  
Copy the code


use


Use Interface Builder

1. Drag and drop a UIView from the XIB or Storyboard to the location you want to display it. 2

code

@property (nonatomic.strong) ORLineChartView *lineChartView;
Copy the code
_lineChartView = [[ORLineChartView alloc] initWithFrame:CGRectMake(0.0.375.350)];
_lineChartView.dataSource = self;
_lineChartView.delegate = self;    
[self.view addSubview:_lineChartView];
Copy the code

ReloadData when data changes or configuration changes

[_lineChartView reloadData];
Copy the code


Agent for the relevant


ORLineChartViewDataSource

  • @requiredYou have to implement the method, the number of data and the corresponding data, and so ontableView
- (NSInteger)numberOfHorizontalDataOfChartView:(ORLineChartView *)chartView;
- (CGFloat)chartView:(ORLineChartView *)chartView valueForHorizontalAtIndex:(NSInteger)index;
Copy the code
  • @optionalThe number of lines (left label) in the vertical direction. The default value is 5, which determines the division of the vertical interval (left data)
- (NSInteger)numberOfVerticalLinesOfChartView:(ORLineChartView *)chartView;
Copy the code

The title of the corresponding data at the bottom. Default recent date: MM-DD

- (NSString *)chartView:(ORLineChartView *)chartView titleForHorizontalAtIndex:(NSInteger)index;
Copy the code

Bottom rich text property Settings

- (NSDictionary<NSAttributedStringKey.id> *)labelAttrbutesForHorizontalOfChartView:(ORLineChartView *)chartView;
Copy the code

Left rich text property setting

- (NSAttributedString *)chartView:(ORLineChartView *)chartView attributedStringForIndicaterAtIndex:(NSInteger)index;
Copy the code

Rich text of the data corresponding to the indicator, which defaults to current data

- (NSString *)chartView:(ORLineChartView *)chartView titleForHorizontalAtIndex:(NSInteger)index;
Copy the code

ORLineChartViewDelegate

  • @optional style == ORLineChartStyleControlButton click trigger
- (void)chartView:(ORLineChartView *)chartView didSelectValueAtIndex:(NSInteger)index;
Copy the code

Style == ORLineChartStyleSlider is triggered when the indicator value changes

- (void)chartView:(ORLineChartView *)chartView indicatorDidChangeValueAtIndex:(NSInteger)index;
Copy the code


Configuration related


The following is a diagram of some of the properties in the configuration

Configuration Modification Mode

_lineChart.config.style = ORLineChartStyleSlider;
_lineChart.config.isBreakLine = YES;
_lineChart.config.chartLineWidth = 2;
_lineChart.config.animateDuration = 1;
[_lineChart reloadData];
Copy the code

The following describes the configuration

  • Style ORLineChartStyleSlider: indicators are displayed by drag and drop (default) orlinechartStyle management: indicators are controlled by click
  • line

    ChartLineWidth:chartLine.shadowLineWidth, default 3

    BglineWidth: Background grid line width, default 1

    ChartLineColor:chartLineColor, orange by default

    ShadowLineColor:shadowLineColor, defaultLightGray alpha 0.5

    BgLineColor: Background grid line color, defaultLightGray alpha 0.5
  • As a whole

    GradientColors: defaultRed alpha 0.3Blue alpha 0.3

    BottomInset: Bottom margin. The default value is 10

    TopInset: Top margin, default 0

    ContentMargin: the offset margin between the left and right sides of the table content (ScrollView ContentInset), default 10

    LeftWidth: Left labels view width, default 40

    BottomLabelWidth: Width of a single label view at the bottom. Default value: 50

    BottomLabelInset: The margin between the bottom label view and the body of the table. The default margin is 10
  • show

    ShowShadowLine: indicates whether to displayshadowLineThe default YES,

    ShowVerticalBgline: specifies whether to display vertical background lines. The default value is YES

    ShowHorizontalBgline: Indicates whether to display horizontal background lines. Default: YES

    DottedBGLine: indicates whether the background line is a dashed line. The default value is YES

    IsBreakLine:chartLine,shadowLineIs it a broken line? Default: NO
  • indicator

    IndicatorContentInset: Indicator content margin, default 7

    IndicatorCircleWidth: Indicator circle orORLineChartStyleControlUnder button size, default 13

    IndicatorLineWidth: indicatorLineWidth, default 0.8

    IndicatorTintColor: indicator theme color, defaultchartLineColor

    IndicatorLineColor: indicatorLineColor, defaultchartLineColor

    IndicatorControlImage:ORLineChartStyleControlButton image, default nil

    IndicatorControlSelectedImage:ORLineChartStyleControlClick on the image, default nil
  • Other animation duration: if it is 0, no animation is performed, default is 0

At the end of the article


Making portal

If you have any questions, please comment below this article or make an issue on GitHub