天天看點

RDLC 折線圖

需求一到,要折騰趨勢圖。

打開rdlc一看,發現有折線圖,曲線圖,可用。

說一下折騰rdlc的簡單步驟:

一:前台頁面折騰控件

1.建立項目->dataset資料集->建立datatable,把要顯示的字段先設計好

2.建立報表rdlc->選擇工具箱->拖出圖表到報表設計界面上。

3.右鍵圖表屬性->資料->資料集名稱->選擇剛才的表。

4.對着圖表右鍵->圖型類型->折線圖

5.選擇中圖表->出現上右下三個資料框->将字段分别往裡拖(上面為值字段[如資料值];右邊為序列字段[如分類];下面為類别[如日期])

6.将上面的值右鍵屬性->把=count(fields!gathervalue.value) 改成=sum(fields!gathervalue.value) 不改就顯示不出來了

7.頁面裡拖出一個reportviewer:

 <rsweb:reportviewer id="reportviewer" runat="server" documentmapcollapsed="true" font-names="verdana" font-size="8pt"

            height="100%" showbackbutton="true" width="99%">

        </rsweb:reportviewer>

二:背景折騰代碼,就幾行。

RDLC 折線圖
RDLC 折線圖

 protected void page_load(object sender, eventargs e)

        {

             datatable dt = execustomsql(module.runit.runitcustomsql.runittrend);

            dt.tablename = "runittrend";//表名

            //綁定rdlc報表

            bindrdlcreport(dt);

        }

        private void bindrdlcreport(datatable dt)

            reportviewer.processingmode = processingmode.local;

            localreport localreport = reportviewer.localreport;

            localreport.reportpath = "app_data/runittrend.rdlc";//報表路徑

            reportdatasource dssalesorder = new reportdatasource();

            dssalesorder.name = "tables_runittrend";//dataset名_表名

            dssalesorder.value = dt;

            localreport.datasources.add(dssalesorder);

RDLC 折線圖

到此儲存運作。效果如下圖:

RDLC 折線圖