126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
" UNION ALL SELECT %.17g, '(%d others)';",
rTooSmall, nTooSmall);
db_bind_double(&q, ":limit", rTotal/60.0);
nTotal += 1 - nTooSmall;
}else{
db_prepare(&q, "SELECT amt, label FROM piechart");
}
for(j=0; db_step(&q)==SQLITE_ROW; j++){
double x = db_column_double(&q,0)/rTotal;
const char *zLbl = db_column_text(&q,1);
/* @ <!-- x=%g(x) zLbl="%h(zLbl)" h=%d(h) --> */
if( x<=0.0 ) continue;
x1 = cx + sin(a1)*r;
y1 = cy - cos(a1)*r;
|
>
|
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
" UNION ALL SELECT %.17g, '(%d others)';",
rTooSmall, nTooSmall);
db_bind_double(&q, ":limit", rTotal/60.0);
nTotal += 1 - nTooSmall;
}else{
db_prepare(&q, "SELECT amt, label FROM piechart");
}
if( nTotal<=10 ) pieFlags |= PIE_CHROMATIC;
for(j=0; db_step(&q)==SQLITE_ROW; j++){
double x = db_column_double(&q,0)/rTotal;
const char *zLbl = db_column_text(&q,1);
/* @ <!-- x=%g(x) zLbl="%h(zLbl)" h=%d(h) --> */
if( x<=0.0 ) continue;
x1 = cx + sin(a1)*r;
y1 = cy - cos(a1)*r;
|
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
zAnc = "end";
}else{
x5 = x4 + 4.0;
zAnc = "start";
}
if( (j&1)==0 || (pieFlags & PIE_CHROMATIC)!=0 ){
h = 256*j/nTotal;
}else{
h = 256*((j+1+nTotal/2)%nTotal)/nTotal;
}
zClr = rgbName(h,SATURATION,VALUE);
l = x>=0.5;
a1 = a2;
@ <path stroke="black" stroke-width="1" fill="%s(zClr)"
@ d='M%g(cx),%g(cy)L%g(x1),%g(y1)A%g(r),%g(r) 0 %d(l),1 %g(x2),%g(y2)z'/>
@ <line stroke='black' stroke-width='1'
|
>
>
|
|
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
zAnc = "end";
}else{
x5 = x4 + 4.0;
zAnc = "start";
}
if( (j&1)==0 || (pieFlags & PIE_CHROMATIC)!=0 ){
h = 256*j/nTotal;
}else if( j+2<nTotal ){
h = 256*(j+2)/nTotal;
}else{
h = 256*((j+2+(nTotal&1))%nTotal)/nTotal;
}
zClr = rgbName(h,SATURATION,VALUE);
l = x>=0.5;
a1 = a2;
@ <path stroke="black" stroke-width="1" fill="%s(zClr)"
@ d='M%g(cx),%g(cy)L%g(x1),%g(y1)A%g(r),%g(r) 0 %d(l),1 %g(x2),%g(y2)z'/>
@ <line stroke='black' stroke-width='1'
|
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
db_reset(&ins);
n++;
}
db_finalize(&ins);
blob_reset(&all);
if( n>0 ){
@ <svg width=%d(width) height=%d(height) style="border:1px solid #d3d3d3;">
piechart_render(width,height, PIE_OTHER|PIE_CHROMATIC);
@ </svg>
@ <hr>
}
@ <form method="post" action='%R/test-piechart'>
@ <p>One slice per line. Value and then Label.<p>
@ <textarea name='data' rows='20' cols='80'>%h(zData)</textarea><br/>
@ Width: <input type='text' size='8' name='width' value='%d(width)'/>
|
|
|
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
db_reset(&ins);
n++;
}
db_finalize(&ins);
blob_reset(&all);
if( n>0 ){
@ <svg width=%d(width) height=%d(height) style="border:1px solid #d3d3d3;">
piechart_render(width,height, PIE_OTHER);
@ </svg>
@ <hr>
}
@ <form method="post" action='%R/test-piechart'>
@ <p>One slice per line. Value and then Label.<p>
@ <textarea name='data' rows='20' cols='80'>%h(zData)</textarea><br/>
@ Width: <input type='text' size='8' name='width' value='%d(width)'/>
|