- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
public static Bitmap DrawBarsChart(ChartType t, Size s)
{
double[] values = DataValues;
string[] names = DataNames;
Bitmap bmp = new Bitmap(s.Width, s.Height);
if (t != ChartType.bars || names.Length != values.Length || names.Length < 2)
return bmp;
else
{
Graphics g = Graphics.FromImage(bmp as Image);
g.Clear(Color.White);
g.DrawLines(new Pen(Brushes.Black), new Point[] { new Point(20, 20), new Point(20, s.Height - 20), new Point(s.Width - 200, s.Height - 20) });
int Columnwidth = (s.Width - 240) / values.Length;
if (Columnwidth > 150) Columnwidth = 150;
double maxvalue = values.Max();
int counter = 1;
int rangefirst;
int rangesecond;
while (true)
{
if (maxvalue / Math.Pow(10, counter) < 10)
{
rangefirst = (int)Math.Floor(maxvalue / Math.Pow(10, counter));
rangesecond = (int)(maxvalue - rangefirst * Math.Pow(10, counter));
break;
}
else
{
counter++;
}
}
int rangepix = (s.Height - 60) / (rangefirst + 1);
for (int i = 0; i < rangefirst + 1; i++)
{
g.DrawString((i * Math.Pow(10, counter)).ToString(), new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular),
Brushes.Black, new PointF(0, s.Height - 30 - rangepix * i));
g.DrawLine(new Pen(Brushes.Black), new Point(17, s.Height - 20 - rangepix * i), new Point(20, s.Height - 20 - rangepix * i));
}
Colors colors = new Colors(); //класс-контейнер цветов (99 штук)
int startcolor = new Random(DateTime.Now.Millisecond).Next(99);
int j = startcolor;
int startx = 21;
int ColumnNumber = 1;
foreach (var value in values)
{
int curfirstrange = (int)Math.Floor(value / Math.Pow(10, counter));
int cursecondrange = (int)(value - curfirstrange * Math.Pow(10, counter));
int rangesmallpix = (int)(cursecondrange * rangepix / Math.Pow(10, counter));
g.FillRectangle(new SolidBrush(colors.GetNextColor(j)), startx,
s.Height - 20 - curfirstrange * rangepix - rangesmallpix, Columnwidth, curfirstrange * rangepix + rangesmallpix);
g.DrawString(value.ToString(), new Font(FontFamily.GenericSerif, 10, FontStyle.Regular), new SolidBrush(Color.Black), new PointF(startx + Columnwidth / 2 - 10,
s.Height - 20 - curfirstrange * rangepix - rangesmallpix - 20));
g.DrawString(ColumnNumber.ToString(), new Font(FontFamily.GenericSerif, 10, FontStyle.Regular), new SolidBrush(Color.Black), new PointF(startx + Columnwidth / 2 - 10,
s.Height - 10));
ColumnNumber++;
j++; if (j > 99) j = 0;
startx += Columnwidth;
}
j = startcolor;
int TopMargin = 20;
foreach (string str in names)
{
string tmp = str;
if (str.Length > 15)
tmp = str.Substring(0, 15);
g.FillRectangle(new SolidBrush(colors.GetNextColor(j)), s.Width - 200, TopMargin, 10, 10); //pucyeM LIBeTHbIe kBagpaTuku
g.DrawString(tmp, new Font(FontFamily.GenericSerif, 12, FontStyle.Italic), Brushes.Black, new PointF(s.Width - 180, TopMargin - 6)); //pucyeM Hagnucu
TopMargin += 20;
j++; if (j > 99) j = 0;
}
return bmp;
}
}
SmackMyBitchUp 06.05.2011 20:22 # 0
Lure Of Chaos 06.05.2011 20:25 # +2
guest 06.05.2011 20:58 # +6
Lure Of Chaos 06.05.2011 23:15 # 0
bugmenot 07.05.2011 00:27 # 0
а он есть!
This is obvious 07.05.2011 10:21 # 0
Lure Of Chaos 07.05.2011 10:31 # 0
bugmenot 06.05.2011 21:08 # 0
istem 06.05.2011 21:21 # 0
Govnocoder#0xFF 07.05.2011 12:25 # 0
guest8 08.04.2019 21:22 # −999
guest8 08.04.2019 22:07 # −999
guest8 08.04.2019 22:09 # −999
guest8 09.04.2019 10:34 # −999
guest8 09.04.2019 10:42 # −999
guest8 09.04.2019 17:49 # −999
guest8 09.04.2019 17:51 # −999