RDLC 图表...删除系列 [英] RDLC Chart... remove series

查看:35
本文介绍了RDLC 图表...删除系列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Visual Studio 2012 中的报告项根据填充的数据集生成图表.

I am trying to use a Report item in Visual Studio 2012 to generate a chart based upon a populated dataset.

我的数据集表中有以下列:

I have the following columns in my dataset table:

date

usersvalue

averagevalue

(除其他外,但这些是我想在图表中显示的内容.)

(among others, but these are what I want to show in the chart.)

我从一个空白报告开始,设置数据源,并添加一个通用折线图:

I start with a blank report, set the data source, and add a generic line chart:

请注意,这首先列出了两个系列(系列 1系列 2).我无法在我查看的任何属性页中找到这些内容的指定位置.我希望我的 usersvalue 和我的 averagevalue 是我的数据点系列,date 值是 x 轴.但是,如果我将这些值添加到系列中,它会在图表上创建 4 行,usersvalueaveragevalue 的系列 1 和系列 2.

Note that this starts with two series (Series 1 and Series 2) listed. I cannot find where these are specified in any property page I look at. I want my usersvalue and my averagevalue to be my data point series, with the date value being the x axis. If I add these values to the series, however, it creates 4 lines on the chart, a Series 1 and Series 2 for both the usersvalue and averagevalue.

我不认为自己是个傻瓜.我可以在 Crystal Reports 和 Excel 中做到这一点,没有任何问题.几个小时以来,我一直试图弄清楚如何只显示两行我想要的信息.要么我遗漏了一些非常明显的东西,要么这是我不幸遇到的最不直观的报告系统.

I don't consider myself a dummy. I can do this in Crystal Reports and Excel with no issues. I have been trying to figure out how to just show two lines with the info I want for hours now. Either I am missing something painfully obvious or this is the most unintuitive reports system I have ever had the misfortune of encountering.

谁能告诉我我做错了什么?

Can someone tell me what I'm doing wrong?

推荐答案

请尝试以下操作:

首先创建一个名为dstest"的数据集,并用dttest"制作一个数据表,并填充数据,如图

Create first a dataset named "dstest" and make a datatable with "dttest" and fill with data as in figure

make a report file (eg. test.rdlc) and drag/drop a line chart as figure
add the dataset "dstest" along with rdlc that we have created before.

添加值"、类别组"和系列组",如图.带有值"、X"和Y"

add "values", "category groups" and "series group" as in figure. with "Values","X" and "Y"

添加一个 Windows 窗体并在其中拖放一个报告查看器.在表单加载时编写以下代码:

add a windows form and drag/drop a report viewer in it. on form load write following codes:

private void test_Load(object sender, EventArgs e)
    {            

        DataTable dtt = new DataTable();
        dtt.Columns.Add("X", typeof(string));
        dtt.Columns.Add("Y", typeof(string));
        dtt.Columns.Add("Values", typeof(int));

        dtt.Rows.Add(new object[] { "3/26/2014", "uservalue", 10 });
        dtt.Rows.Add(new object[] { "3/25/2014", "uservalue", 14 });
        dtt.Rows.Add(new object[] { "3/24/2014", "uservalue", 9 });

        dtt.Rows.Add(new object[] { "3/26/2014", "averagevalue", 15 });
        dtt.Rows.Add(new object[] { "3/25/2014", "averagevalue", 16 });
        dtt.Rows.Add(new object[] { "3/24/2014", "averagevalue", 7 });


        ReportDataSource rds1 = new ReportDataSource("dstest", dtt);   // dstest is dataset that you have added when creating rdlc
        reportViewer1.LocalReport.DataSources.Add(rds1);
        reportViewer1.LocalReport.ReportPath = "you path of rdlc file"\test.rdlc";

        this.reportViewer1.RefreshReport();

    }

最后尝试运行和加载表单.您的表格应显示以下结果..

finally try running and loading form. you form should show following result..

这篇关于RDLC 图表...删除系列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆