首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Telerik的RadChart组件中设置Y轴文本,而不是数字

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

Stack Overflow用户
提问于 2010-05-25 15:39:52
回答 1查看 10.6K关注 0票数 0

我已经制作了一个带有“SeriesOrientation=”RadChart“”的横条。

我让文本显示在每个条形图的末尾,但我希望该文本列在y轴上,而不是1,2,3。数字。

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

下面是我的代码片段:=== .ascx ===

代码语言:javascript
复制
    <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",等等。

有人能帮上忙吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-05-26 00:01:34

您需要绑定图表--设置DataSource属性并调用DataBind()。您不需要调用chartSeries.AddItem()。DataBind()将为您添加这些项。数据源可以是包含两列的DataTable -- "UnitPrice“和"TenMostExpensiveProducts”。看,这些是您在系列中设置为DataYColumn的名称,以及在XAxis中设置为DataLabelsColumn的名称。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2902835

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档