nikopol / Harry-Plotter

Lightweight standalone javascript library to plot charts, pies, river, or histograms
http://nikopol.github.com/Harry-Plotter
MIT License
38 stars 11 forks source link

Negative values in charts. #8

Open cablegunmaster opened 8 years ago

cablegunmaster commented 8 years ago

http://nikopol.github.io/Harry-Plotter/#tab=generator I can't get a chart to have a [1,0,-1] limit, values in this simple chart.

Ideally I want to be able to make a chart with steps of: "1,0.8,0.6,0.4,0.2,0,-0.2,-0.4.-0.6,-0.8,-1.0,-1.2,-1.4,-1.6" Of Y-axis value steps. with values of "-0.239,-0.742,-0.900,-1.0" for example. so its a very small graph. but the information itself is very small. But won't resize on the screen.

The X-axis is just a label. But with the stacked graph it won't resize these values. Is it possible to make a negative graph out of this, with a positive one on top? Like dual graph. One negative the other stack is positive.

It doessn't seem to handle negative values that well, for the rest Its a awesome javascript library, keep up the good work! :+1:

Thanks for reading the request. Hopefully I have made myself clear.

nikopol commented 8 years ago

Hi, actually you can do it with two graphs as you said, using the options mirror:{y:true} option for yours negatives values (but you'll need to provide Math.abs value anyway). example : http://plnkr.co/edit/wlHx0YRhtHcHVqIQhtIv?p=preview

I'll try to find the time to do it in a prettiest way with one graph.

gtimoshaz commented 6 years ago

@nikopol I tried to fix it, but it was impossible for me to read your code, so here's an idea how to fix. You can found minimal Y global_minimum value in all datasets and then subtract global_minimum from Y labels before output it. I. e. replace gc.fillText(v, x, y) with gc.fillText(v-global_minimum, x, y)