Metodo createChart (C#)
private void createChart(DataTable dt) {
// Area di lavoro
int w = 300;
int h = 300;
Bitmap bas = new Bitmap(w, h);
Graphics area = Graphics.FromImage(bas);
//Sfondo Bianco
Rectangle rect = new Rectangle(0, 0, w, h);
area.FillRectangle(Brushes.White, rect);
//Lettura dati
int x = 10;
int y = 0;
foreach (DataRow row in dt.Rows){
int qta = ((int)row["qta"]) / 10;
y = h - qta -10;
Rectangle colonna = new Rectangle(x, y, 5, qta);
if (x/2 == 0){
area.FillRectangle(Brushes.Red, colonna);
x += 7;
} else {
area.FillRectangle(Brushes.Blue, colonna);
x += 15;
}
}
area.DrawLine(Pens.Black, 0, y - 70, 0, h); // asse x
area.DrawLine(Pens.Black, 0, h - 1, (x + 10), h - 1); // asse y
bas.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
bas.Dispose();
}