Comments (4)
Hey @tonka3000! Thank you very much and thanks for raising this issue, good idea! I've included this functionality in a new formatter in the latest version. Is this what you need?
from ascii-chart.
Hey @gtktsc ,
This is exactly what I was hoping for 😊.
But one thing is strange: When I use your test-data values the switch to K
postfix works, but when I use my numbers it don't switch to K
mode.
Plotcode
const chart = plot(coords, { "height": 12, width: 60, "hideXAxis": true});
Your test-data
const coords: Coordinates = [
[-9000, 2000],
[-8000, -3000],
[-2000, -2000],
[2000, 2000],
[3000, 1500],
[4000, 5000],
[10000, 1400],
[11000, 20000],
[12000, 30000],
];
Output:
My example data
const coords: Coordinates = [
[ 0, 6000 ], [ 100, 9000 ],
[ 200, 9100 ], [ 300, 9200 ],
[ 400, 9344 ], [ 500, 9877 ],
[ 600, 10200 ], [ 700, 15000 ],
[ 800, 9100 ], [ 900, 9200 ],
[ 1000, 9344 ], [ 1100, 9877 ],
[ 1200, 10001 ], [ 1300, 9000 ],
[ 1400, 9100 ], [ 1500, 9200 ],
[ 1600, 9344 ], [ 1700, 9877 ],
[ 1800, 10001 ], [ 1900, 9000 ],
[ 2000, 9100 ], [ 2100, 9200 ],
[ 2200, 9344 ], [ 2300, 9877 ],
[ 2400, 10001 ], [ 2500, 10001 ],
[ 2600, 9000 ], [ 2700, 9100 ],
[ 2800, 9200 ], [ 2900, 9344 ],
[ 3000, 9877 ], [ 3100, 10001 ]
];
Output:
from ascii-chart.
Hello @tonka3000
Yes, that's because I've added additional transformation for small numbers, but apparently it wasn't good enough. It's gone now, please try out the newest release - should work out of the box.
Alternatively, you can add custom formatter:
const coords: Coordinates = [
[0, 6000],
[100, 9000],
[200, 9100],
[300, 9200],
[400, 9344],
[500, 9877],
[600, 10200],
[700, 15000],
[800, 9100],
[900, 9200],
[1000, 9344],
[1100, 9877],
[1200, 10001],
[1300, 9000],
[1400, 9100],
[1500, 9200],
[1600, 9344],
[1700, 9877],
[1800, 10001],
[1900, 9000],
[2000, 9100],
[2100, 9200],
[2200, 9344],
[2300, 9877],
[2400, 10001],
[2500, 10001],
[2600, 9000],
[2700, 9100],
[2800, 9200],
[2900, 9344],
[3000, 9877],
[3100, 10001],
];
const chart = plot(coords, {
height: 12,
width: 60,
hideXAxis: true,
formatter: (value) => {
if (Math.abs(value) > 1000) return `${value / 1000}k`;
return value;
},
});
Thanks!
from ascii-chart.
@gtktsc Works perfect. Thank you very much.
from ascii-chart.
Related Issues (5)
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 ascii-chart.