fix
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good

This commit is contained in:
Nishi 2026-09-14 02:59:35 +09:00
commit b86fe4f306

View file

@ -12,6 +12,8 @@ static const char* palette0[] = {
"#888", "#888",
NULL}; NULL};
#define NUMFMT "%.2f"
static int wcreate(MwWidget handle) { static int wcreate(MwWidget handle) {
MwChart c = malloc(sizeof(*c)); MwChart c = malloc(sizeof(*c));
memset(c, 0, sizeof(*c)); memset(c, 0, sizeof(*c));
@ -99,7 +101,18 @@ static void draw(MwWidget handle) {
double twidth; double twidth;
char buf[128]; char buf[128];
node.x = 128; node.x = 0;
for(i = 0; i < arrlen(c->entries); i++) {
int w;
sprintf(buf, NUMFMT, c->entries[i].value);
w = MwTextWidth(handle, NULL, buf);
if(node.x < w) node.x = w;
}
node.y = 0; node.y = 0;
width = (r.width - node.x) * s / (arrlen(c->entries) * (1 + s) + 1); width = (r.width - node.x) * s / (arrlen(c->entries) * (1 + s) + 1);
@ -119,12 +132,12 @@ static void draw(MwWidget handle) {
vmax += (double)width / r.height * (vmax - vmin); vmax += (double)width / r.height * (vmax - vmin);
} }
sprintf(buf, "%.2f", ovmax); sprintf(buf, NUMFMT, ovmax);
draw_line(handle, buf, node.x, (r.height - space) - (ovmax - vmin) / (vmax - vmin) * (r.height - space), twidth, width / 2, border); draw_line(handle, buf, node.x, (r.height - space) - (ovmax - vmin) / (vmax - vmin) * (r.height - space), twidth, width / 2, border);
draw_line(handle, "0", node.x, (r.height - space) - (0 - vmin) / (vmax - vmin) * (r.height - space), twidth, width / 2, border); draw_line(handle, "0", node.x, (r.height - space) - (0 - vmin) / (vmax - vmin) * (r.height - space), twidth, width / 2, border);
sprintf(buf, "%.2f", ovmin); sprintf(buf, NUMFMT, ovmin);
draw_line(handle, buf, node.x, (r.height - space) - (ovmin - vmin) / (vmax - vmin) * (r.height - space), twidth, width / 2, border); draw_line(handle, buf, node.x, (r.height - space) - (ovmin - vmin) / (vmax - vmin) * (r.height - space), twidth, width / 2, border);
p[0].x = node.x; p[0].x = node.x;