Skip to content

Commit

Permalink
Fill rewrite (#3084)
Browse files Browse the repository at this point in the history
close #3140
* Fill is now a protocol

Different fill logic is broken up into separate classes. This has a few benefits:
1. It makes the `Fill` types more readable (logic is grouped together)
2. No optionals
3. Most importantly it allows consumers to create new Fill types without looking into the framework.

* Added super.init() for objc

* Updated Fill access

No need to subclass existing fills now that the system is more flexible. If functionality is needed from another fill, user can call it within their own `fillPath(context: CGContext, rect: CGRect)` implementation.

* Updated Fill Names

* Update Fill.swift

update code style

Co-authored-by: Jacob Christie <jchristie@christie.teamspace.ad>
Co-authored-by: Xuan <liuxuan30@gmail.com>
  • Loading branch information
3 people authored Apr 16, 2020
1 parent 5689a1c commit 4b23327
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 197 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ - (void)setDataCount:(int)count range:(double)range
CGGradientRef gradient = CGGradientCreateWithColors(nil, (CFArrayRef)gradientColors, nil);

set1.fillAlpha = 1.f;
set1.fill = [ChartFill fillWithLinearGradient:gradient angle:90.f];
set1.fill = [[ChartLinearGradientFill alloc] initWithGradient:gradient angle:90.0f];
set1.drawFilledEnabled = YES;

CGGradientRelease(gradient);
Expand Down
2 changes: 1 addition & 1 deletion ChartsDemo-iOS/Swift/Demos/LineChart1ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class LineChart1ViewController: DemoBaseViewController {
let gradient = CGGradient(colorsSpace: nil, colors: gradientColors as CFArray, locations: nil)!

set1.fillAlpha = 1
set1.fill = Fill(linearGradient: gradient, angle: 90) //.linearGradient(gradient, angle: 90)
set1.fill = LinearGradientFill(gradient: gradient, angle: 90)
set1.drawFilledEnabled = true

let data = LineChartData(dataSet: set1)
Expand Down
Loading

0 comments on commit 4b23327

Please sign in to comment.