App 2.19.8: charging curve labels clear of each other; Charging tab 35/65

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LhzAVaUyqcw5PkGjz4mWW6
This commit is contained in:
2026-10-23 22:18:32 +02:00
co-authored by Claude Opus 5.5
parent 93e7e4cb63
commit e2922e4842
4 changed files with 43 additions and 11 deletions
@@ -41,12 +41,39 @@ public final class ChargingGraphView extends View {
}
return found ? out.toString().trim() : "No charging measurements yet";
}
/**
* Axes with their labels clear of each other: "kW" in a row of its own above the plot, the
* power values right-aligned against the y axis, and the SOC ticks as "0 %" … "100 %",
* centred under their lines, the last one kept inside the view.
*/
@Override protected synchronized void onDraw(Canvas c) {
super.onDraw(c); float left=58, right=getWidth()-12, top=12, bottom=getHeight()-38;
float max=20; for(float[] p:points) max=Math.max(max,p[1]); max=(float)Math.ceil(max/20f)*20f;
for(int i=0;i<=5;i++){float y=bottom-(bottom-top)*i/5f; c.drawLine(left,y,right,y,grid); c.drawText(String.format(Locale.US,"%.0f",max*i/5f),4,y+7,text);}
for(int soc=0;soc<=100;soc+=20){float x=left+(right-left)*soc/100f; c.drawLine(x,top,x,bottom,grid); c.drawText(String.valueOf(soc),x-10,getHeight()-8,text);}
c.drawText("kW",5,20,text); c.drawText("SOC %",right-52,getHeight()-8,text);
for(int i=1;i<points.size();i++){float[] a=points.get(i-1),b=points.get(i); float ax=left+a[0]*(right-left)/100, ay=bottom-a[1]*(bottom-top)/max, bx=left+b[0]*(right-left)/100, by=bottom-b[1]*(bottom-top)/max; c.drawLine(ax,ay,bx,by,line); c.drawCircle(bx,by,4,line);}
super.onDraw(c);
float left = 58, right = getWidth() - 12, top = 36, bottom = getHeight() - 38;
float max = 20; for (float[] p : points) max = Math.max(max, p[1]); max = (float) Math.ceil(max / 20f) * 20f;
text.setTextAlign(Paint.Align.RIGHT);
for (int i = 0; i <= 5; i++) {
float y = bottom - (bottom - top) * i / 5f;
c.drawLine(left, y, right, y, grid);
c.drawText(String.format(Locale.US, "%.0f", max * i / 5f), left - 8, y + 7, text);
}
text.setTextAlign(Paint.Align.LEFT);
c.drawText("kW", 4, 20, text);
for (int soc = 0; soc <= 100; soc += 20) {
float x = left + (right - left) * soc / 100f;
c.drawLine(x, top, x, bottom, grid);
String label = soc + " %";
float half = text.measureText(label) / 2f;
float cx = Math.min(x, getWidth() - 2 - half);
text.setTextAlign(Paint.Align.CENTER);
c.drawText(label, cx, getHeight() - 8, text);
}
text.setTextAlign(Paint.Align.LEFT);
for (int i = 1; i < points.size(); i++) {
float[] a = points.get(i - 1), b = points.get(i);
float ax = left + a[0] * (right - left) / 100, ay = bottom - a[1] * (bottom - top) / max;
float bx = left + b[0] * (right - left) / 100, by = bottom - b[1] * (bottom - top) / max;
c.drawLine(ax, ay, bx, by, line);
c.drawCircle(bx, by, 4, line);
}
}
}