公告
财富商城
积分规则
提问
发文
2019-09-02 22:59发布
叛逆
I'm trying to create a column chart that has columns with diffrent widths.
Is it possible to create a chart like that with the chart control or should I look for a library that supports it?
You can use a Area type chart like this:
Set it up
Series s1 = chart1.Series.Add("S1"); s2.ChartType = SeriesChartType.Area; ChartArea ca = chart1.ChartAreas[0]; ca.AxisX.Minimum = 0; AddArea(chart1, s2, 12, 53, Color.SlateBlue); AddArea(chart1, s2, 32, 63, Color.Firebrick); AddArea(chart1, s2, 22, 23, Color.SlateBlue); AddArea(chart1, s2, 62, 33, Color.Goldenrod); AddArea(chart1, s2, 12, 33, Color.PaleVioletRed);
and add points like this:
int AddArea(Chart chart, Series s, double x, double y, Color color) { ChartArea ca = chart.ChartAreas[s.ChartArea]; Axis ax = ca.AxisX; Axis ay = ca.AxisY; if (s.Points.Count == 0) s.Points.AddXY(ax.Minimum, ay.Minimum); DataPoint dp0 = s.Points.Last(); int p1 = s.Points.AddXY(dp0.XValue, y); s.Points.AddXY(dp0.XValue + x, y); s.Points.Last().Color = color; s.Points.AddXY(dp0.XValue + x, ay.Minimum); dp0.Color = color; s.Points.Last().Color = color; return p1; }
Change the MarkerSize property on each DataPoint individually
MarkerSize
DataPoint
最多设置5个标签!
You can use a Area type chart like this:
Set it up
and add points like this:
Change the
MarkerSize
property on eachDataPoint
individually