【发布时间】:2019-07-22 15:57:19
【问题描述】:
大家晚上好。
尝试使用一些数据格式化柱形图,但遇到了问题。 所有列都以它们的标签为中心。我希望每一列都在标签之间。
代码:
Random rnd = new Random();
Chart myChart = new Chart();
myChart.Parent = this;
myChart.Size = new System.Drawing.Size(300, 185);
myChart.Location = new Point(865, 56);
myChart.Titles.Add("Distribution of clients per time span");
ChartArea chArea = new ChartArea("clientsDistribution");
chArea.AxisX.Title = "Time span";
chArea.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.DecreaseFont;
chArea.AxisY.Title = "Count";
chArea.AxisY.LabelAutoFitMaxFontSize = 5;
myChart.ChartAreas.Add(chArea);
Series mySeriesOfPoint = new Series("timeSpans");
mySeriesOfPoint.ChartType = SeriesChartType.Column;
mySeriesOfPoint.ChartArea = "clientsDistribution";
for (int x = 0; x < 9; x++)
{
mySeriesOfPoint.Points.AddXY(x + 9, countByTimeSpan[x]);
mySeriesOfPoint.Points[x].Color = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));
}
myChart.Series.Add(mySeriesOfPoint);
myChart.Series["timeSpans"]["PointWidth"] = "1";
【问题讨论】:
-
我认为这是一个误导性的图形。或者 iou 可以选择正确的类型:这实际上是关于 AreaChart,而不是 column..
-
差不多了,但不是我想要的 (cdn1.imggmi.com/uploads/2019/2/28/…)
-
是的,您需要加分来创建矩形区域。请参阅here for an example
-
这正是我所需要的,谢谢! cdn1.imggmi.com/uploads/2019/2/28/…
-
如果您发现该帖子有用,您可能需要考虑为它点赞..