2010-05-25 74 views
0

我已經制作了一個帶有「SeriesOrientation =」Horizo​​ntal「」的RadChart條形圖。如何在來自Telerik的RadChart組件中使用Bar-type代替數字在Y軸上設置文本

我有文本顯示在每個酒吧結束,但相反,我希望文字在Y軸,而不是1,2,3 ..數字聆聽。

看來我不允許在y軸上設置任何文本,有沒有我可以設置的屬性?

這裏是我的代碼snippes: === ===名爲.ascx

<div> 
     <asp:ScriptManager ID="ScriptManager" runat="server" /> 

     <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
      <ContentTemplate> 
       <telerik:RadChart ID="RadChart1" runat="server" 
        Skin="WebBlue" AutoLayout="true" Height="350px" Width="680px" SeriesOrientation="Horizontal"> 
        <Series> 
         <telerik:ChartSeries DataYColumn="UnitPrice" Name="Product Unit Price"> 
         </telerik:ChartSeries> 
        </Series> 
        <PlotArea> 
         <YAxis> 
          <Appearance> 
           <TextAppearance TextProperties-Font="Verdana, 8.25pt, style=Bold" /> 
          </Appearance> 
         </YAxis> 
         <XAxis DataLabelsColumn="TenMostExpensiveProducts"> 
         </XAxis> 
        </PlotArea> 
        <ChartTitle> 
         <TextBlock Text="Ten Most Expensive Products" /> 
        </ChartTitle> 
       </telerik:RadChart> 
      </ContentTemplate> 
     </asp:UpdatePanel> 
</div> 

========================= 

=== .ascx === 
     protected void Page_Load(object sender, EventArgs e) 
     { 
      RadChart1.AutoLayout = false; 
      RadChart1.Legend.Visible = false; 

      // Create a ChartSeries and assign its name and chart type 
      ChartSeries chartSeries = new ChartSeries(); 
      chartSeries.Name = "Name"; 
      chartSeries.Type = ChartSeriesType.Bar; 

      // add new items to the series, 
      // passing a value and a label string 
      chartSeries.AddItem(98, "Product1"); 
      chartSeries.AddItem(95, "Product2"); 
      chartSeries.AddItem(100, "Product3"); 
      chartSeries.AddItem(75, "Product4"); 
      chartSeries.AddItem(1, "Product5"); 

      // add the series to the RadChart Series collection 
      RadChart1.Series.Add(chartSeries); 
      // add the RadChart to the page. 
      //    this.Page.Controls.Add(RadChart1); 

      //   RadChart1.Series[0].Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing; 
      //   RadChart1.Series[0].DataYColumn = "Uptime"; 
      RadChart1.PlotArea.XAxis.DataLabelsColumn = "Name"; 
      RadChart1.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Font = new System.Drawing.Font("Verdana", 8); 
      RadChart1.BackColor = System.Drawing.Color.White; 
      RadChart1.Height = 350; 
      RadChart1.Width = 570; 
      RadChart1.DataBind(); 
     } 

============ 我想有文字: 「產品1」, 「Product2」等在Y軸上。

任何人都可以幫忙嗎?

回答

1

您需要綁定圖表 - 設置DataSource屬性並調用DataBind()。您不需要調用chartSeries.AddItem()。 DataBind()將爲您添加項目。數據源可以是具有兩列的DataTable - 「UnitPrice」和「TenMostExpensiveProducts」。請參閱這些是您設置爲系列中的DataYColumn和XAxis中的DataLabelsColumn的名稱。

相關問題