An open API service indexing awesome lists of open source software.

https://github.com/zhipingyang/xychart

XYChart is designed for line & bar of charts which can compare mutiple datas in form styles, and limited the range of values to show, and so on.
https://github.com/zhipingyang/xychart

barchart chart linechart

Last synced: 22 days ago
JSON representation

XYChart is designed for line & bar of charts which can compare mutiple datas in form styles, and limited the range of values to show, and so on.

Awesome Lists containing this project

README

        

















> **XYChart** is designed for line & bar of charts which can compare mutiple datas in form styles, and limited the range of values to show, and so on.

| **LineChart** | **BarChart** |
|:-------:|:---------:|
| ![WechatIMG65](https://user-images.githubusercontent.com/9360037/62707044-4671de00-ba23-11e9-9ddc-57509edba0dc.jpeg) | ![WechatIMG66](https://user-images.githubusercontent.com/9360037/62707048-47a30b00-ba23-11e9-90a9-c414a92da2cc.jpeg) |
| single datas in linechart | single datas in linechart |
| ![WechatIMG70](https://user-images.githubusercontent.com/9360037/62711726-20047080-ba2c-11e9-8890-022fe4e58df9.jpeg) | ![click](https://user-images.githubusercontent.com/9360037/62712419-5ee6f600-ba2d-11e9-9605-aeaba3097e9b.gif) |
| **LineDotsClicked:** show all if the dots closed in multi-datas | **BarClicked:** custom click effects in multi-datas |
| ![gif](https://user-images.githubusercontent.com/9360037/62709107-54c1f900-ba27-11e9-8312-8fcec88a58d5.gif) | ![gif](https://user-images.githubusercontent.com/9360037/62709087-48d63700-ba27-11e9-86f3-e92e4e1bd094.gif) |
| scrolling linechart (did set row width) | scrolling barchart (did set row width) |

## Install

> required `iOS >= 8.0` with [Cocoapods](https://cocoapods.org/)
>
> ```ruby
> pod 'XYChart'
> ```

## Usage

Expand for XYChart details

```objective-c
@interface XYChart : UIView

@property (nonatomic, weak, nullable) id dataSource;
@property (nonatomic, weak, nullable) id delegate;

@property (nonatomic, readonly) XYChartType chartType;

- (instancetype)initWithFrame:(CGRect)frame type:(XYChartType)type NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithType:(XYChartType)type;

/**
更新图标数据

@param dataSource 数据
@param animation 是否执行动画
*/
- (void)setDataSource:(id)dataSource animation:(BOOL)animation;

/**
重载数据

@param animation 是否执行动画
*/
- (void)reloadData:(BOOL)animation;

@end
```

**Method 1:**
[details](https://github.com/ZhipingYang/XYChart/issues/50)

```objective-c
_chartView = [[XYChart alloc] initWithFrame:CGRectMake(0, 0, 300, 100) chartType:XYChartTypeLine];
_chartView.dataSource = self;
_chartView.delegate = self;
[self.view addSubview:_chartView];
```

**Method 2:**

```objective-c
// the obj follow the XYChartDataSource protocol
_datasource = [[XYChartDataSourceItem alloc] init];

_chartView = [[XYChart alloc] initWithType:XYChartTypeLine];
_chartView.dataSource = _datasource;
[self.view addSubview:_chartView];
```

Expand for XYChartDelegate protocol details

```objective-c
@protocol XYChartDelegate
@optional

/**
是否展示UIMenuController
*/
- (BOOL)chart:(XYChart *)chart shouldShowMenu:(NSIndexPath *)index;

/**
点击后的action,重载一般就不show UIMenuController了
*/
- (void)chart:(XYChart *)chart itemDidClick:(id)item;

/**
line用于展示圆圈,bar用于柱形图的动画
*/
- (CAAnimation *)chart:(XYChart *)chart clickAnimationOfIndex:(NSIndexPath *)index;

@end
```

Expand for XYChartDataSource protocol details

```objective-c
/**
多套对比数据展示
*/
@protocol XYChartDataSource

/**
多少条并行对比数据,折线图表现多条线,柱状图表现一列中有几条柱状图
*/
- (NSUInteger)numberOfSectionsInChart:(XYChart *)chart;

/**
完整的周期内,数据的个数,横向列数
*/
- (NSUInteger)numberOfRowsInChart:(XYChart *)chart;

/**
x坐标的标题
*/
- (NSAttributedString *)chart:(XYChart *)chart titleOfRowAtIndex:(NSUInteger)index;

/**
x坐标的标题
*/
- (NSAttributedString *)chart:(XYChart *)chart titleOfSectionAtValue:(CGFloat)sectionValue;

/**
index下的数据模型
*/
- (id)chart:(XYChart *)chart itemOfIndex:(NSIndexPath *)index;

/**
标记y轴方向高亮区间
*/
- (XYRange)visibleRangeInChart:(XYChart *)chart;

/**
y轴方向分段,5就分5段
*/
- (NSUInteger)numberOfLevelInChart:(XYChart *)chart;

/**
横向一栏的宽度
*/
- (CGFloat)rowWidthOfChart:(XYChart *)chart;

/**
自适应平均分横向栏目的宽度
*/
- (BOOL)autoSizingRowInChart:(XYChart *)chart;

@end
```

## Author

XcodeYang, [email protected]

## License

XYChart is available under the MIT license. See the LICENSE file for more info.