RDLC Chart… remove series

2019-08-04 00:38发布

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: generic 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条回答
Ridiculous、
2楼-- · 2019-08-04 00:45

Please try the following:

enter image description here

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

enter image description here

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.

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

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.. enter image description here

查看更多
登录 后发表回答