Comments (4)
You don't have to use map
. The chart just needs an array of ChartAxisValue
. How you generate this array is up to you. The examples use map
because it makes the code easier to read (this has a performance penalty though, since it iterates over all the array, but it's irrelevant for small datasets).
For numbers you can use ChartAxisValueFloat
, where you can pass a formatter. ChartAxisValue
should not be instantiated directly (this is like an "abstract class" if you are familiar with that). This class doesn't have any information about how to display the double, if it generated labels and you pass e.g. 2.3423422342425 it would show all the decimal digits and that's in most cases not what you want.
So you can simply:
let xValues = [
ChartAxisValueFloat(1),
ChartAxisValueFloat(2.5),
ChartAxisValueFloat(3)
]
(This will use the default formatter which shows max 2 fraction digits - if you need something different, pass it to the initializer).
from swiftcharts.
I've tried several times but your example helped me figuring out that a CGFloat is needed by the library.
I just had to use CGFloat(X[i]) in my code to solve it.
I suggest to add documentation about that in the method definition while the use types in the commands
from swiftcharts.
Actually, you have a point - there's no real reason to use CGFloat
here. Somebody changed recently the internal representation to Double
(because CGFloat
causes problems with dates), so it's converted to Double
anyways. It makes sense to replace ChartAxisValueFloat
with ChartAxisValueDouble
. I'll leave this open as an enhancement issue.
Also, the behaviour/documentation of ChartAxisValue
has to be improved, such that it's clear that it's not meant to be instantiated directly.
from swiftcharts.
Improvements implemented
from swiftcharts.
Related Issues (20)
- Static library
- Temporarily hide lines in Line chart
- What's the correct way to set contentView background color and border? HOT 1
- Is this kind of y axis layout possible:
- Extending Views to create custom views isn't working due to file private and internal properties
- How to overlay a layer of labels?
- Axis disappear after coming back from background
- X Y points in horizontal bar chart keeps moving rights; when the y axis labels length (text) is more
- Swift 5
- Changing axis values
- X values not adding properly
- Axis Labels not showing up HOT 2
- ChartLabelSettings() ignoring supplied font color, always defaults to black HOT 1
- SPM Support?
- Problem building on new MacBook
- SPM not working properly due to missing TAG HOT 1
- x, y Axis didn't show in the Chart HOT 2
- ChartPointsBubbleLayer not draws properly HOT 1
- how to dynamic live update line chart
- How can i make xAxisLabel to get multiple data instead of one value for one xAxisLabel ?
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 swiftcharts.