为什么我的 RadChart StackedBarChart 没有堆叠条形图以匹配 Y 轴?
我在 Silverlight 4.0 中使用 Telerik RadChart 控件。我有一个问题,因为我认为我的数据集存在差异,这导致我的较大堆叠条形图被裁剪在 ChartArea 内。没问题,我想,我可以循环遍历所有数据并找到 StackedBar 必须达到的最大尺寸,然后调整 y 轴的比例。这是我选择实施的方法。
private void ForceScaleOfYaxis(IEnumerable<ChartObject> chartData)
{
double sum = 0;
foreach (var bar in chartData)
{
sum = Math.Max(sum, bar.Series1 +
bar.Series2 +
bar.Series3 +
bar.Series4 +
bar.Series5);
}
ChartArea chartArea = radChart1.DefaultView.ChartArea;
chartArea.AxisY.AutoRange = true;
double min = chartArea.AxisY.ActualMinValue;
double step = sum / 10;
chartArea.AxisY.AutoRange = false;
chartArea.AxisY.AddRange(min, sum, step);
}
这非常有效,因为它将 y 轴更改为等于堆叠条形图系列值的最大总和。
现在我有一个不同的问题:我正确设置了 y 轴的比例,但图表似乎没有堆叠。
人们可以通过下面的图表看到这一点,如该屏幕截图所示。
I am using Telerik RadChart controls for Silverlight with Silverlight 4.0. I have a problem, due I think to the variance in my data sets, which causes my larger stacked bars to be clipped within the ChartArea. No problem, I thought, I can just loop through all my data and find the maximum size my StackedBar has to be, and adjust the scale of the y-axis. Here's the method I chose to implement.
private void ForceScaleOfYaxis(IEnumerable<ChartObject> chartData)
{
double sum = 0;
foreach (var bar in chartData)
{
sum = Math.Max(sum, bar.Series1 +
bar.Series2 +
bar.Series3 +
bar.Series4 +
bar.Series5);
}
ChartArea chartArea = radChart1.DefaultView.ChartArea;
chartArea.AxisY.AutoRange = true;
double min = chartArea.AxisY.ActualMinValue;
double step = sum / 10;
chartArea.AxisY.AutoRange = false;
chartArea.AxisY.AddRange(min, sum, step);
}
This worked quite well, in that it changed the y-axis to equal the largest sum of series values for the stacked bar.
Now I have a different problem: I correctly set the scale of the y-axis, but the Charts do not appear to stack.
One can see this with the following chart, as seen in this screen shot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这与 YAxis Range 引起的条形裁剪无关,而是与数据分组和填充图表的方式有关。
您的示例项目应该可以更多地阐明真正的问题。
I don't think that this is related to the clipping of bars caused by the YAxis Range but rather the way you Group the data and populate the Chart.
A sample project of yours should shed some more light on the real issue.