RDLC Chart… remove series

泄露秘密 提交于 2019-12-11 05:06:02

问题


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:

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.

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?


回答1:


Please try the following:

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.

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

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..



来源:https://stackoverflow.com/questions/20063138/rdlc-chart-remove-series

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!