Work on y legend
This commit is contained in:
parent
84c3ac6740
commit
f337ab9a08
@ -263,7 +263,9 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
|
|
||||||
// ys = c_rect.height / c_mm.getDiff();
|
// ys = c_rect.height / c_mm.getDiff();
|
||||||
|
|
||||||
return (c_rect.height - (((float)Math.log(y) - c_mm.getMin()) * ys)) + c_rect.y;
|
// return (c_rect.height - (((float)Math.log(y) - c_mm.getMin()) * ys)) + c_rect.y;
|
||||||
|
return c_rect.height + c_rect.y - ((float)Math.log(y) - c_mm.getMin()) * ys;
|
||||||
|
|
||||||
|
|
||||||
/* float m = c_mm.getMax() / c_mm.getMin();
|
/* float m = c_mm.getMax() / c_mm.getMin();
|
||||||
|
|
||||||
@ -294,8 +296,20 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
|
|
||||||
// (-(y-c_rect.y-c_rect.heigh))/c_yscaling = (val - c_mm.getMin())
|
// (-(y-c_rect.y-c_rect.heigh))/c_yscaling = (val - c_mm.getMin())
|
||||||
|
|
||||||
if (logs){
|
if (c_mm.isLog()){
|
||||||
return (-(Math.exp(y)-c_rect.y-c_rect.height))/c_yscaling+Math.exp(c_mm.getMin());
|
float ys = c_rect.height / c_mm.getDiff();
|
||||||
|
|
||||||
|
|
||||||
|
//val = return c_rect.height + c_rect.y - ((float)Math.log(y) - c_mm.getMin()) * ys;
|
||||||
|
// ((float)Math.log(y) - c_mm.getMin()) * ys = c_rect.height + c_rect.y
|
||||||
|
// ((float)Math.log(y) - c_mm.getMin()) = (c_rect.height + c_rect.y)/ys
|
||||||
|
// ((float)Math.log(y) = (c_rect.height + c_rect.y)/ys + c_mm.getMin())
|
||||||
|
|
||||||
|
//return (-(Math.exp(y)-c_rect.y-c_rect.height))/ys+c_mm.getMin();
|
||||||
|
|
||||||
|
|
||||||
|
return Math.exp( (c_rect.height + c_rect.y)/ys + c_mm.getMin() );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -413,7 +427,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
|
|
||||||
for (int yp=(int) y2; yp<y1; yp+=em_size*2) {
|
for (int yp=(int) y2; yp<y1; yp+=em_size*2) {
|
||||||
g.drawLine(dim.width + dim.x - yw, yp, dim.width + dim.x - yw + em_size , yp);
|
g.drawLine(dim.width + dim.x - yw, yp, dim.width + dim.x - yw + em_size , yp);
|
||||||
double v1 = getValAtY(y1);
|
double v1 = getValAtY(yp);
|
||||||
g.drawString(String.format("%.2f", v1), dim.width + dim.x - yw + em_size * 1.5f, yp + c_font_height / 3);
|
g.drawString(String.format("%.2f", v1), dim.width + dim.x - yw + em_size * 1.5f, yp + c_font_height / 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,9 +566,8 @@ System.out.printf("v1 %f, v2 %f\n",v1,v2);
|
|||||||
ctx.iwidth = (float) ((x_unit_width * em_size) * 0.9f);
|
ctx.iwidth = (float) ((x_unit_width * em_size) * 0.9f);
|
||||||
|
|
||||||
this.ct = ChartType.CANDLESTICK;
|
this.ct = ChartType.CANDLESTICK;
|
||||||
logs=true;
|
logs=false;
|
||||||
|
c_mm.setLog(false);
|
||||||
c_mm.setLog(true);
|
|
||||||
drawChart(ctx);
|
drawChart(ctx);
|
||||||
|
|
||||||
c_mm = data.getVolMinMax(first_bar, last_bar);
|
c_mm = data.getVolMinMax(first_bar, last_bar);
|
||||||
|
@ -48,6 +48,11 @@ public class MinMax {
|
|||||||
return !log ? max - min : max_log - min_log;
|
return !log ? max - min : max_log - min_log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getDiff(boolean plog) {
|
||||||
|
return !plog ? max - min : max_log - min_log;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public float getMin() {
|
public float getMin() {
|
||||||
return !log ? min : min_log;
|
return !log ? min : min_log;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user