2012-07-16 56 views
0

我試圖創建的TeeChart一體的MonoDroid的應用程序,我想有一個活動舉行圖表,和其他一些組件,如TextView的,按鈕等下面是代碼,的TeeChart爲MonoDroid的

protected override void OnCreate(Bundle bundle) 
     { 
      base.OnCreate(bundle); 

      SetContentView(Resource.Layout.Test); 
      var testpanel = FindViewById<LinearLayout>(Resource.Id.MealChartPanel); 

      Steema.TeeChart.TChart tChart1 = new Steema.TeeChart.TChart(this); 

      Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(); 
      tChart1.Series.Add(bar1); 

      bar1.Add(3, "Pears", Color.Red); 
      bar1.Add(4, "Apples", Color.Blue); 
      bar1.Add(2, "Oranges", Color.Green); 
      Steema.TeeChart.Themes.BlackIsBackTheme theme = new Steema.TeeChart.Themes.BlackIsBackTheme(tChart1.Chart); 
      theme.Apply(); 

      testpanel.AddView(tChart1); 
     } 

    <?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
    android:id="@+id/MealChartPanel" 
    android:layout_width="fill_parent" 
    android:layout_height="100dip" 
    android:layout_marginLeft="5dip" 
    android:layout_marginRight="5dip"> 
    </LinearLayout> 
</LinearLayout> 

我使用了testpanel.AddView(tChart1);但沒有任何顯示,我怎麼能把圖表放在MealChartPanel linearlayout?

謝謝,

回答

0

這是因爲您需要指定圖表尺寸。您可以設置絕對像素尺寸或使用LayoutParams,例如:

testpanel.AddView(tChart1, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent)); 
+0

謝謝,這有效!網站上是否有任何詳細的教程?我的同事一直在使用teechart進行monotouch,我正在研究如何創建功能圖表的代碼。但是monotouch和monodouch之間確實有一些區別,比如在monotouch中,你可以設置ZoomScrollStyle,newChart.Chart.Aspect.ZoomScrollStyle = Steema.TeeChart.Drawing.Aspect.ZoomScrollStyles.Manual;但如何設置monodorid? – user1467537 2012-07-18 19:49:58

+0

@ user1467537在本月底之前,我們將發佈一個包含教程的新測試版。在MonoDroid中,您可以設置Zoom.Style,例如:tChart1.Zoom.Style = Steema.TeeChart.ZoomStyles.FullChart; – 2012-07-19 07:19:47

+0

@ user1467537我們剛剛發佈了包含完整文檔和教程的測試版更新:http://www.steema.com/entry/116/TeeChart_.NET_Mono_for_Android_Library_BETA_update。我們預計下一個版本是最終版本。 – 2012-07-23 14:06:12