Git Product home page Git Product logo

xychart's Introduction

Version License Platform CI Status


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 WechatIMG66
single datas in linechart single datas in linechart
WechatIMG70 click
LineDotsClicked: show all if the dots closed in multi-datas BarClicked: custom click effects in multi-datas
gif gif
scrolling linechart (did set row width) scrolling barchart (did set row width)

Install

required iOS >= 8.0 with Cocoapods

pod 'XYChart'

Usage

Expand for XYChart details
@interface XYChart : UIView<XYChartReload>

@property (nonatomic, weak, nullable) id<XYChartDataSource> dataSource;
@property (nonatomic, weak, nullable) id<XYChartDelegate> 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<XYChartDataSource>)dataSource animation:(BOOL)animation;

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

@end

Method 1: details

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

Method 2:

// 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
@protocol XYChartDelegate
@optional

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

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

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

@end
Expand for XYChartDataSource protocol details
/**
 多套对比数据展示
 */
@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<XYChartItem>)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.

xychart's People

Contributors

cornelisonc avatar jeffrey-huang avatar rolandasrazma avatar zhipingyang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xychart's Issues

zoom

How to add zoom feature in this library

柱状图值图不对

一个 x 标签添加多组个柱状图时候,会出现值图不对问题.请修复...

Line chart adding two legends

Hi,
I am trying to add two legends into one line chart
say for example,
A, B
A = {10, 11, 12} for {10/03/2017, 11/03/2017, 12/03/2017}
B = {15,17} for {10/03/2017, 12/03/2017}

The above data was not populated correctly in my chart.
So, can you help me to solve this.

Line Graphic does not show all my values

Hi ,

I have 31 values in my graphic but only 21 of them is shown. Although i change the size of my line graphic view size it is still the same, it just strecthes, but not show all values.

What might be wrong?

可以定义显示lineChart的显示范围吗?

就是,比如我的数据有很多月份,从2001年1月到2014年12月,但是我想它的视觉范围只显示6个月的内容,滑动屏幕显示其他月份的,是否可以实现?

yLabel出现Label重叠

背景色是clear ,yLabel就有1 2 3 4 5 和我自己获取数据后的那个yLabel数组,是不是初始化的时候如果数组没值,就默认给的 1 2 3 4 5

Could you please provide the code for fill Color between two Line Charts

Hi,
We have implemented Line, Bar Charts in our application and Customer also liked this graphs UI and animation.
But We have immediate requirement that, we need to fill with color between two Line charts for one Graph.
I tried a lot, but I could not get it resolve, Could you please help me to get out of this issue.
Thanks

Grouped bar chart

How to get the grouped bar chart only from this library? Removing all other unwanted implementations.

小数点

作者辛苦了,我有幸用到这个库,使用很方便也很好用,但是我实现出效果后,发现最大值和最小值不能显示小数点,我看了下代码没找到修改的位置,能提示下在哪修改吗

不知道为什么x轴文字就是显示不了

  • (NSArray *)UUChart_xLableArray:(UUChart *)chart{
    return [self getXTitles:7];
    }
  • (NSArray *)getXTitles:(int)num
    {
    NSMutableArray *xTitles = [NSMutableArray array];
    for (int i=0; i<num; i++) {
    NSString * str = [NSString stringWithFormat:@"R-%d",i];
    [xTitles addObject:str];
    }
    return [xTitles copy];
    }
    x轴是这样写的,但是最终显示是这样

求楼主指导,不甚感激

2条曲线,前面都会重叠

我是在一个view里面添加了折线图,设置了delegate和datasource的代理为view,在里面实现了代理方法,根据服务器返回的值,设置数据后,2条曲线,前面都会重叠,点击显示时,值又是对的,比如,有一条曲线的值是 9341.00,9300.00,9200.00,838500.00,838500.00,838500.00,838500.00 ,第二条曲线的值,0,0,0,0 ,0,0,0,可是2条曲线,前面都重叠了,点击第一个点后,显示出来第一条曲线的值又是9341.00,我不知道是不是我哪里弄错了,还请帮忙解答一下。

Crash in SingleView Project for the following code

//
//  ViewController.m
//  PKAnalyseTestProject
//
//  Created by Piccolo on 2019/12/11.
//  Copyright © 2019 Piccolo. All rights reserved.
//

#import "ViewController.h"
#import "XYChartDataSourceItem.h"
#import "XYChartItem.h"
#import "XYChart.h"
#import "RandomChartDataSource.h"

@interface ViewController () <XYChartDelegate> {
    
}
@property (nonatomic, strong) XYChart *chartView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _chartView = [[XYChart alloc] initWithType:XYChartTypeLine];
    _chartView.frame = CGRectMake(0, 100, 200, 500);
    _chartView.delegate = self;
    [self.view addSubview:_chartView];
    XYChartDataSourceItem *a = [[RandomChartDataSource alloc] initWithStyle:XYChartTypeLine section:1 row:2];
    [_chartView setDataSource:a animation:YES];
}

@end

Run this following code in single view project.
Any problem with it?
It crashed.

Different colors on same bar.

I am trying to get multiple colors on a single bar, But no luck. Could you please guide me to get a different colors on single bar based on bar value.

Swift support

if ([self.dataSource respondsToSelector:@selector(UUChart:ShowHorizonLineAtIndex:)])

How to write the swift dataSource to ensure the above respondsToSelector true?

Multiple colours on single bar.

How to add multiple colours on same bar. Based on bar percentage , i need to show the colours.
60% of bar with one colour, other 40% of bar with another colour

不走代理方法

在viewcontroller里面实现了代理方法 datasource也设置了self,也导入了代理请问为什么没走代理方法呢?

如何重新绘制

如何重新绘制?strokeChart 不会清除之前绘制的,没有相关方法调用重绘? 怎么解决?

背景颜色可更改吗

UUBar.m中的

  • (void)drawRect:(CGRect)rect{
    //Draw BG
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
    CGContextFillRect(context, rect);
    }

換成CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
背景的barchart变成黑色
如何更改成透明的?

菜鸟问题

请问您这个Library具体是怎样使用的呢?能不能给个例子?

X轴数据太长

如果X轴数据比较多,一个屏幕的宽度显示不下,是否可以滑动

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.