Comments (7)
How about having an option for the x axis where you could specify it's type?
For example:
[xAxisType]="dateEpoch"
The xAxisType could of course be an enum specifying the possible types.
I think this would solve all the points you've mentioned and it remove the need from the user to parse the dates.
What do you think?
from ngx-charts.
Did you copy the data from the sidebar in the demo page? The dates there get converted to string for the JSON representation. In order to get a time scale on the line and area charts, you need to use date objects. If you use strings, you get an ordinal scale.
There's an argument here for detecting whether the string is a representation of a date and converting it internally, but I believe this should be handled outside the charts.
Take a look at this plunkr for an example. I convert the strings into date objects in the constructor in app.ts: https://plnkr.co/edit/HOXr8K?p=preview
from ngx-charts.
There's an argument here for detecting whether the string is a representation of a date and converting it internally, but I believe this should be handled outside the charts.
@marjan-georgiev can you explain why you believe this should be handle outside the charts? I believe many charts do rely on dates/time ?
from ngx-charts.
Sure. I think it is easier to do some minor wrangling and give the chart precise, formatted data, than have the chart guess whether you want it to treat your strings as dates or actual strings.
- What if you wanted those values to be treated as strings?
- What if you had the dates in a different format - should we try to parse any possible date format out there?
- What if you didn't have strings, but integers - do we try to parse them as dates too?
These are all decisions that the user needs to make, not the chart.
I do think we should make assumptions when applicable in order to cut on configuration, but not here.
from ngx-charts.
Just a heads up if you use the code from the constructor in the plunkr you get a "Type 'Date' is not assignable to type 'string'." warning. Is this from an older version of TS?
from ngx-charts.
@yann510 I also think this is something the chart should handle. But i also agree with @marjan-georgiev that the chart should not try to guess what the data is, so i like your suggestion about specifying xAxisType.
from ngx-charts.
@marjan-georgiev Parsing integers as a dates is pretty normal in javascript no? (Im thinking specifically about unix epoch).
from ngx-charts.
Related Issues (20)
- Custom pie chart label
- Chart rendering will shake when SSR is enabled
- X Axis Orientation
- Heat map If max and min parameters are not passed, the colors of legend and heat grid will be inconsistent. HOT 1
- Mouse misalign with vertical line and tooltip in chart-line while zooming in or out
- Please, migrate (or provide as an alternative) standalone APIs for both components and providers.
- Timeline mini chart of line chart not clipped correctly when min / max value of x / y is set
- Maximum Callstack exceeeded on Pie Chart V: 20.5.0
- Euro symbol is displayed when animations is turned off on advanced pie chart
- Timeline chart type
- NGX-Charts does not seem to support Content-Security-Policies with nonces properly
- Infinite loading when refreshing the page for multi ngx-charts-bar-horizontal HOT 1
- Add valueFormatting parameter for Line Area charts HOT 1
- Is this project still maintained?
- Change geolocation from browser to Mumbai, numerical values are displayed in local language.
- JEST transformIgnorePatterns not working HOT 1
- Bar chart appears to render animation misaligned
- In Area Line Chart Need Descending Date Time Format like Year 2024 to 2022 instead of Year 2022 to 2024
- Chart overlay customization & style
- Chart switching animation
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 ngx-charts.