Comments (6)
Excel 2013 handle this by using the negative numbers as positive.
I think this can be the a good solution since you might want to make a pie chart that compare incomes vs expenses or something similar
.
from chart.js.
I think Excel is too dumb here (unless there is more to the screenshot).
Abs'ing all values is only a good idea if you label the negatives somehow or explicitly state that this has been done.
Example: Let's say that I am a developer that sets up a dashboard for a department in my company unaware of this "feature". Everything looks good until one day a negative value turns up and without anyone realizing it, a group of people are making decisions on incorrect data.
from chart.js.
How would you expect this to render? Highcharts handles this slightly oddly as well... http://jsfiddle.net/E4jg7/
Unless there is something which seems like it would be appropriate for everyone, I think the best approach is to sanitise the data before creating the chart depending on the use case. For example, if people feel the approach Excel takes in abs'ing the value is the best way, that should be done before instantiating the chart. Alternatively, if you wanted to throw an error in your application, maybe the best way of doing that is before you create the chart based off that data.
from chart.js.
I have, in this situation, rendered this as a simple circle (gray outline only) with a message in the center saying something along the lines of "pie charts can't represent negative values".
There really isn't much else you can do without being misleading (or weird like Highcharts). Some chart types simply won't work with some values. Another example of such a thing is a stacked area chart: I don't know that there is anything sane that can be done, if smack in the middle you encounter a big negative value, other than just telling the viewer that this won't work.
from chart.js.
Why don't you have some logic in your application that detects negative values before rendering a chart? I think that would make more sense than trying to add partial support for negative values in Chart.js.
from chart.js.
I would suggest that you at least add an exception then if negative values are found to inform the developer that it isn't supported.
from chart.js.
Related Issues (20)
- Stackweight not working with multiple stacks HOT 2
- Connecting scatter points HOT 4
- Safari 12.1.2 getting error Unexpected token '='. Expected an opening '(' before a method's parameter list HOT 2
- Line Chart backgroundColor looks scratched when assigning segment borderColor, 200~ points on dataset
- Filled areas of the graph are distorted when adding tension HOT 1
- Official Discord Server ? HOT 4
- Cannot see ticks lines when grid > display = false HOT 2
- Dynamic data not updating HOT 1
- Lines partially missing after upgrade from 4.3.0 to 4.3.1 HOT 1
- Moving from 4.3.0 to 4.3.1 break most of my already existing code due to types HOT 11
- Non-static registry HOT 2
- Doughnut chart legends issue in chart.js
- Partially missing line on time axis, regression in 4.3.1 HOT 11
- Toggle doughnut vs. label resizing HOT 4
- BorderRadius of Bar Chart issue on Firefox 116 HOT 5
- Release 4.3.3 missing tgz file HOT 7
- Rendering flowchart is wrong
- Superfluous value copies inside plugin options
- Vite giving chart.js ActiveElement import error HOT 1
- PackedCircle HOT 4
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 chart.js.