使用ArcGIS API for Silverlight + Visifire繪製地圖統計圖

來源:互聯網
上載者:User

標籤:style   c   class   blog   code   java   

原文:使用ArcGIS API for Silverlight + Visifire繪製地圖統計圖

   最近把很久之前做的統計圖又拿出來重新做了一遍,感覺很多時候不複習,不記錄就真的忘了,時間是最好的稀釋劑,真是這樣。

   恰好有些網友又向我問起,於是稍作記錄,以便自己今後複習和參考。

    本文樣本用的版本為:

   Silverlight 5+Visifire 3.6.8+ArcGIS API for Silverlight 3.0+Visual Studio 2010

一、ArcGIS API For Silverlight 繪製統計圖如何?

      通常的情況我們是將得到的統計圖作為一個ElementLayer添加到地圖中,通過設定ElementLayer的位置,來設定統計圖在地圖上顯示的位置。

      所有繪製統計圖的工作都是由第三方控制項:Visifire完成,當然這裡你也可以用Silverlight內建的Chart控制項。

     下面說一下Visifire繪圖的設定過程:

     1.1 首先定義一個Chart(可以理解為畫布),並設定相關屬性,例如:

                    Chart chart = new Chart();                    chart.Background = null;                    chart.BorderBrush = null;                    chart.IndicatorEnabled = false;                    chart.LightingEnabled = false;                    chart.View3D = true;                    chart.Height = 300;                    chart.Width = 100;                    // 設定標題                    Title title = new Title();                    title.Text = "汙染物濃度統計圖";                    chart.Titles.Add(title);

         1.2 定義曲線(柱狀圖,餅狀圖等),如:

                   DataSeries dataSeries = new DataSeries();// 設定圖表樣式,這裡設定為Column表示柱狀圖,還有Pie表示餅狀圖,以及其他圖形等。                    
dataSeries.RenderAs = RenderAs.Column;

          1.3 定義資料點,例如:
             

                    DataPoint dataPoint = new DataPoint();                    dataPoint.Exploded = true;                    dataPoint.AxisXLabel = "汙染物A";                    / Set YValue for a DataPoint                    dataPoint.YValue = 10;

        1.4 將資料點添加到DataSeries中,然後將DataSeries添加到Chart中,例如:

                     dataSeries.DataPoints.Add(dataPoint);                     chart.Series.Add(dataSeries);


         1.5 定義ElementLayer,設定Evelop(範圍)屬性,將Chart添加到ElementLayer中,例如:

                    ElementLayer chartlayer = new ElementLayer();                    chartlayer.ID = "統計圖層";                    chartlayer.Opacity = 0.7;
//g為輸入的統計要素(點,面,線) MapPoint mapPoint = g.Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint; //設定該參數來控制統計圖顯示的位置 Envelope extent = new Envelope(mapPoint.X, mapPoint.Y , mapPoint.X , mapPoint.Y); ElementLayer.SetEnvelope(chart, extent); chartlayer.Children.Add(chart);

       1.6 最後將ElementLayer添加到地圖圖層中:  

                     Map.Layers.Add(chartlayer);

       這樣就能得到最後的統計圖了:
                                 

 

 

  【樣本下載】

  範例程式碼用法:點擊地圖任意一點,可添加一個Graphic,並輸入相關屬性,然後點擊統計,即可對添加點的屬性進行統計。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.