代码之家  ›  专栏  ›  技术社区  ›  radbyx Matt

如何在条形Telerik的RadChart组件中设置Y轴文本而不是数字

  •  0
  • radbyx Matt  · 技术社区  · 16 年前

    我有文本显示在每个栏的结尾,但相反,我希望文本列在y轴,而不是1,2,3。。数字。

    似乎我不允许在y轴上设置任何文本,有什么属性可以设置吗?

    ===.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();
            }
    

    我想在y轴上有文本:“Product1”,“Product2”等。

    1 回复  |  直到 13 年前
        1
  •  1
  •   alan    16 年前

    您需要绑定图表--设置DataSource属性并调用DataBind()。您不需要调用chartSeries.AddItem()。DataBind()将为您添加项。数据源可以是一个有两列的数据表--“UnitPrice”和“TenMostExpensiveProducts”。请参阅,这些是您在series中设置为DataYColumn的名称,以及在XAxis中设置为datalabelscollan的名称。

    推荐文章