This page looks plain and unstyled because you're using a non-standard compliant browser. To see it in its best form, please upgrade to a browser that supports web standards. It's free and painless.

RioYoBlog

首页 | 资源中心 | 管理控制台

Dundas for Reporting Services的一些的使用技巧

RioYo | 25 一月, 2011 14:39

如何让Chart的Y轴或2nd Y轴只显示最大值和最小值?
原理很简单,就是设置Y轴的interval是此轴的最大值即可,但是interval是不支持Expression表达式来获取Y轴最大值的,那么就需要在Dundas中写Code来实现。
在Dundas的属性设置窗口中选择Advanced,单击ViewCode按钮,在下拉列表中选择PostApplyData方法,C#实现代码如下:
// Parameter: chartObj - represents the chart object
chartObj.ChartAreas[0].AxisY.Interval=
chartObj.ChartAreas[0].AxisY.Maximum-chartObj.ChartAreas[0].AxisY.Minimum;完成后单击Compile按钮,下方出现Compiled OK后Code即生效,运行Report即可看见效果。

使用了Series Groups后如果自定义每个Series的颜色或者Maker类型?
当你在Dundas中使用了Series Groups,那个每个添加到Dundas的Series都会依据这它来分组显示。并且分组出来的Series的颜色是Dundas随机定义的。要想修改分组出来的Series的颜色或者其Maker设置,也可以通过在Dundas中写Code来实现。
在Dundas中,每个Series都有一个默认的Name,分别是"Series 1"、"Series 2"...依次排下去。我们只要分别判断每个Series的Name,然后再分别采用不同的设置即可。在Dundas的属性设置窗口中选择Advanced,单击ViewCode按钮,在下拉列表中选择PrePaint方法,C#示例Code如下:
// Parameter: chartObj - represents the chart object
// Parameter: sender - the chart object that will be painted

if( sender is Series ){

Series series = (Series) sender;

switch(series.Name){
case "Series 1":
series.Color=Color.LightYellow;
series.MarkerStyle=MarkerStyle.Diamond;
break;
case "Series 2":
series.Color=Color.Red;
series.MarkerStyle=MarkerStyle.Square;
break;
}
}
完成后单击Compile按钮,下方出现Compiled OK后Code即生效,运行Report即可看见效果。
如果Series出现的顺序不固定,那么我们还可以通过LegendText来判断Series。LegendText的值是在Series Groups中用来group的那一列的值。我们可以用switch(series.LegendText)来判断。

说明:LegendText 对应的case值为列名<中文可能会出现乱码>


Valid XHTML 1.0 Strict and CSS.
Powered by pLog
Design by Book of Styles