Open sirolf2009 opened 6 years ago
Sure! I will add the ability to specify a range, or if one is not provided I will incorporate the minimum value as the bottom instead of zero. Thanks for the idea, it had never occurred to me.
Maybe I'm missing something, but I plugged in some BTC prices from the last month and got this result using the current version of ASCIIGraph
:
package com.mitchtalmadge.asciidata.graph;
public class Test {
public static void main(String... args) {
System.out.println(ASCIIGraph.fromSeries(new double[]{7438.67, 7562.14, 7634.19, 7769.04, 8181.20, 8221.58, 8205.82, 8169.06, 7950.40, 8176.85, 8379.66, 7716.51, 7414.71, 7417.80, 7352.72, 7467.40, 7378.20, 7315.32, 6739.65, 6357.01, 6272.70, 6247.50, 6235.03, 6396.78, 6330.77, 6739.21, 6775.08, 6857.80, 6668.71, 6638.69}).withNumRows(7).plot());
}
}
8379.66 ┤ ╭─╮ ╭╮
8022.22 ┤ ╭╯ ╰──╯│
7664.78 ┤╭──╯ ╰╮
7307.34 ┼╯ ╰─────╮
6949.91 ┤ │ ╭─╮
6592.47 ┤ ╰╮ ╭╯ ╰─
6235.03 ┤ ╰─────╯
Does your data have any negative or very low values somehow? I guess I already have the graph determining the range from the highs and lows.
hmm, yeah you're right. Maybe I was testing with my profit and not the market price and then my brain farted. Anyway, here's what you get for negative values:
System.out.println(ASCIIGraph.fromSeries(Arrays.asList(-181d, -171d, -161d)).plot());
-1.00 ┤
-2.00 ┤
-3.00 ┤
-4.00 ┤
-5.00 ┤
-6.00 ┤
-7.00 ┤
-8.00 ┤
-9.00 ┤
-10.00 ┤
-11.00 ┤
-12.00 ┤
-13.00 ┤
-14.00 ┤
-15.00 ┤
-16.00 ┤
-17.00 ┤
-18.00 ┤
-19.00 ┤
-20.00 ┤
-21.00 ┤
-22.00 ┤
(snipped)
-160.00 ┤
-161.00 ┤ ╭
-162.00 ┤ │
-163.00 ┤ │
-164.00 ┤ │
-165.00 ┤ │
-166.00 ┤ │
-167.00 ┤ │
-168.00 ┤ │
-169.00 ┤ │
-170.00 ┤ │
-171.00 ┤╭╯
-172.00 ┤│
-173.00 ┤│
-174.00 ┤│
-175.00 ┤│
-176.00 ┤│
-177.00 ┤│
-178.00 ┤│
-179.00 ┤│
-180.00 ┤│
-181.00 ┼╯
So yeah, I do have negative values.
Looks like the negatives could use some cropping. I'll work on that
I'm using this library mostly for debugging trading bots. The problem is that the prices never go to 0, but instead hang around, let's say, 8000. The charts force the zero to be in range of the Y axis, which flattens my chart to a point where I can't see movements anymore. Can you add an option to not force zero in range on the Y axis? Or better yet, allow us to determine our own ranges?