Comments (3)
Asking the same thing :D
from charts.
Asking the same thing :D
- (void)setTestData1 {
ChartLimitLine *maxLine = [[ChartLimitLine alloc] initWithLimit:80 label:@"80"];
maxLine.valueFont = [UIFont systemFontOfSize:8];
maxLine.lineWidth = 1;
maxLine.labelPosition = ChartLimitLabelPositionRightTop;
maxLine.lineColor = [UIColor qmui_colorWithHexString:@"#FFA200"];
[self.chartView.leftAxis addLimitLine:maxLine];
ChartLimitLine *minLine = [[ChartLimitLine alloc] initWithLimit:60 label:@"60"];
minLine.valueFont = [UIFont systemFontOfSize:8];
minLine.lineWidth = 1;
minLine.labelPosition = ChartLimitLabelPositionRightTop;
minLine.lineColor = [UIColor redColor];
[self.chartView.leftAxis addLimitLine:minLine];
NSMutableArray *dataSets = [NSMutableArray array];
// 第一段
{
NSMutableArray *firstValue = [NSMutableArray array];
for (int i = 0; i < 10; i++) {
// value 是 0 - 60 的随机数
int value = [self getRandomNumber:60 to:80];
ChartDataEntry *entry = [[ChartDataEntry alloc] initWithX:i y:value];
[firstValue addObject:entry];
}
ChartDataEntry *entry = [[ChartDataEntry alloc] initWithX:10 y:60];
[firstValue addObject:entry];
LineChartDataSet *dataSet = [[LineChartDataSet alloc] initWithEntries:firstValue];
dataSet.drawFilledEnabled = YES;
dataSet.drawCirclesEnabled = YES;
dataSet.drawCircleHoleEnabled = YES;
dataSet.circleHoleColor = UIColor.whiteColor;
dataSet.circleColors = @[
[UIColor qmui_colorWithHexString:@"#FFA200"],
[UIColor qmui_colorWithHexString:@"#FFA200"],
[UIColor qmui_colorWithHexString:@"#FFA200"],
[UIColor qmui_colorWithHexString:@"#FFA200"],
[UIColor qmui_colorWithHexString:@"#FFA200"],
[UIColor qmui_colorWithHexString:@"#FFA200"],
[UIColor qmui_colorWithHexString:@"#FFA200"],
[UIColor qmui_colorWithHexString:@"#FFA200"],
[UIColor qmui_colorWithHexString:@"#FFA200"],
[UIColor qmui_colorWithHexString:@"#FFA200"],
[UIColor clearColor]
];
dataSet.circleRadius = 3;
dataSet.circleHoleRadius = 1;
dataSet.lineWidth = 1;
dataSet.mode = LineChartModeCubicBezier;
dataSet.drawValuesEnabled = NO;
NSArray *fillColors = @[
(id)[ChartColorTemplates colorFromString:@"#00FFA200"].CGColor,
(id)[ChartColorTemplates colorFromString:@"#FFFFA200"] .CGColor,
];
CGGradientRef gradient = CGGradientCreateWithColors(nil, (CFArrayRef)fillColors, nil);
dataSet.fillAlpha = 1.f;
dataSet.fill = [[ChartLinearGradientFill alloc] initWithGradient:gradient angle:90.0f];
[dataSet setColors:@[
[UIColor qmui_colorWithHexString:@"#FFA200"],
]];
[dataSets addObject:dataSet];
}
// 第二段
{
NSMutableArray *firstValue = [NSMutableArray array];
ChartDataEntry *entry = [[ChartDataEntry alloc] initWithX:10 y:60];
[firstValue addObject:entry];
for (int i = 11; i < 20; i++) {
int value = [self getRandomNumber:00 to:60];
ChartDataEntry *entry = [[ChartDataEntry alloc] initWithX:i y:value];
[firstValue addObject:entry];
}
LineChartDataSet *dataSet = [[LineChartDataSet alloc] initWithEntries:firstValue];
dataSet.drawFilledEnabled = YES;
dataSet.drawCirclesEnabled = YES;
dataSet.drawCircleHoleEnabled = YES;
dataSet.circleHoleColor = UIColor.whiteColor;
dataSet.circleColors = @[
[UIColor clearColor],
[UIColor redColor],
[UIColor redColor],
[UIColor redColor],
[UIColor redColor],
[UIColor redColor],
[UIColor redColor],
[UIColor redColor],
[UIColor redColor],
[UIColor redColor]
];
dataSet.circleRadius = 3;
dataSet.circleHoleRadius = 1;
dataSet.lineWidth = 1;
dataSet.mode = LineChartModeCubicBezier;
dataSet.drawValuesEnabled = NO;
NSArray *fillColors = @[
(id)[ChartColorTemplates colorFromString:@"#00FF0000"].CGColor,
(id)[ChartColorTemplates colorFromString:@"#FFFF0000"] .CGColor,
];
CGGradientRef gradient = CGGradientCreateWithColors(nil, (CFArrayRef)fillColors, nil);
dataSet.fillAlpha = 1.f;
dataSet.fill = [[ChartLinearGradientFill alloc] initWithGradient:gradient angle:90.0f];
[dataSet setColors:@[
[UIColor redColor],
[UIColor orangeColor],
[UIColor yellowColor],
]];
dataSet.valueColors = @[
[UIColor blueColor],
[UIColor purpleColor],
[UIColor systemPinkColor],
];
[dataSets addObject:dataSet];
}
// 第三段
LineChartData *chartData = [[LineChartData alloc] initWithDataSets:dataSets];
self.chartView.data = chartData;
}
from charts.
我用了这样一个思路,效果勉勉强强,不知道能不能给你启发
from charts.
Related Issues (20)
- CombinedChartView with barChartView and stackBarChartView, tap effect error!
- Apple silicon Macs support issue HOT 4
- Not able to scroll a line chart horizontally, please help to do the same
- After upgrade to 5.0 all charts crash on <Chart>.delegate = self in ViewDidLoad() HOT 7
- NSBitmapImageRep deprecated from macOS 10.14: SOLUTION!
- IndexAxisValueFormatter behaves not as expected
- how to fix Value of type 'XAxis' has no member 'nameAxis'
- How to fill color only below the zero line and set different line color below the zero line
- How to set different colour to Y-Axis labels ?
- LinearChart left right padding HOT 2
- Crash using highlighted value in combined charts HOT 1
- View in center of Pie Chart
- How to align labels bottom of the dots
- Can't compile DGCharts HOT 5
- LineChartView one x axis label color is bold and dark.
- Charts framework takes a long time to build
- How to set the default xAxis offset?
- Can the top be rounded? Is it possible to increase demand? HOT 1
- Change to DGCharts, but PieViewData portion still seems to be conflating with Apple's Charts HOT 2
- On the issue of LineChartView stuttering
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from charts.