c# - Dynamically creating charts -
i trying dynamically create chart each drive in computer, inside form.
each chart should pie chart contains amount of free space (colored green) , used space(colored red) in gbs.
but when run following code thing see blank rectangles titles of "c:\", "d:\" , on.
here code :
public static void drawcharts() { chart[] charts = new chart[driveinfo.getdrives().length]; driveinfo[] drives = driveinfo.getdrives(); (int = 0; < drives.length; i++) { charts[i] = new chart(); charts[i].palette = chartcolorpalette.brightpastel; charts[i].titles.add(drives[i].name); charts[i].series.add("storage"); charts[i].series[0].charttype = seriescharttype.pie; charts[i].location = new system.drawing.point(20 + * 231, 30); charts[i].size = new system.drawing.size(230, 300); datapoint d = new datapoint(); d.xvalue = 1; double[] p = { (double)drives[i].totalfreespace / 1000000000 }; d.yvalues = p; d.color = system.drawing.color.yellowgreen; d.label = "free space"; charts[i].series[0].points.add(d); d.label = "used space"; d.xvalue = 2; double[] = { (double)((drives[i].totalsize - drives[i].totalfreespace) / 1000000000) }; d.yvalues = a; d.color = system.drawing.color.red; charts[i].series[0].points.add(d); form1.tabs.tabpages[1].controls.add(charts[i]); charts[i].invalidate(); } }
thanks.
you there.
but basic thing need add dynamically created chart..:
charts[i] = new chart();
..is chartarea
:
charts[i].chartareas.add("ca1"); // pick name!
without no series
can display..
use style axis tickmarks
, gridlines
or labels
or set minima
, maxima
, intervals
. well, @ least other charttypes
; pies
don't need of anyway..
note can have several chartareas
in 1 chart
.
also note still display nothing until @ least 1 series
has @ least 1 datapoint
..
Comments
Post a Comment