Comments (4)
hey @karzler. im having the issue where the old labels aren't getting removed. Im using a redux like approach when updating my pie chart but for some reason, the old labels won't go away. This is what i have:
chartView.models.removeAll()
chartView.removeSlices()
chartView.layers.removeAll()
self.chartView.models = state.pieSlices
chartView.layers = [createTextLayer()] <- this function creates new labels with updated values
how'd you remove the old labels?
I'd appreciate the help here
from piecharts.
Apparently, it was a tiny mistake on my side. I was recreating text layers multiple times.
For folks looking out how to update the chart, simple set models to empty, and then create models again. Make sure you remove the slices before creating the new models
from piecharts.
Hey @zas9vf, I struggled a bit to remove the old labels. In my case I used
self.chartView.removeSlices()
self.chartView.layers.removeAll()
self.chartView.models.removeAll()
and initialized text layer as a global variable in the page
var textLayer = PiePlainTextLayer()
Each time i needed to update the chart i used this code:
self.textLayer.clear()
Then update the layers using the method that exists in the tutorial
let textLayerSettings = PiePlainTextLayerSettings()
textLayerSettings.viewRadius = 100
textLayerSettings.hideOnOverflow = false
textLayerSettings.label.textColor = UIColor.white
textLayerSettings.label.font = UIFont.systemFont(ofSize: 15)
let formatter = NumberFormatter()
formatter.maximumFractionDigits = 1
textLayerSettings.label.textGenerator = {slice in
return formatter.string(from: slice.data.percentage * 100 as NSNumber).map{_
}
}
self.textLayer.settings = textLayerSettings
self.chartView.layers = [self.textLayer]
I hope this helps.
from piecharts.
I had to do some edits to the source code itself to get what I wanted but appreciate the help! 👍🏽
from piecharts.
Related Issues (20)
- Aligning Slice labels to always stay in the middle of slices
- Disable selection HOT 2
- Chart not centered if simulator screen size is not the storyboard screen size HOT 3
- Failed to render and update auto layout status HOT 1
- IBDesignable Error
- failed to render and update auto layout status HOT 3
- SnapKit related issue HOT 1
- inner and outer radius not updating when changing them via code HOT 1
- Parameter name change for CAMediaTimingFunction in PieSliceLayer.swift
- Placing piechart in a table view cell
- slices not moving
- static slices HOT 2
- how get slice when it is selected after doing some animation like rotation
- how get slice when it is selected after doing some animation like rotation
- add button
- Adding Drop Shadow to PieChart
- Labels overlapping HOT 3
- Pie chart not at center
- labelGenerator creating Multiple labels for each Part
- How to make a chart with only 1 model ? by default they must be at least 2 !!
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 piecharts.