如何在 Telerik 的 Bar 类型的 RadChart 组件中设置 Y 轴文本而不是数字
我用“SeriesOrientation=”Horizontal”制作了一个 RadChart 条形图。
我在每个条的末尾显示文本,但我希望该文本在 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”等。
有人可以帮忙吗?
I have made an bar RadChart with "SeriesOrientation="Horizontal"".
I have the text showing at the end for each bars, but instead I would like that text to be listet in the y-axis, instead of the 1,2,3.. numbers.
It seems like I'm not allow to set any text in the y-axis, is there a property I can set?
Here is my code 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();
}
============
I want to have the text: "Product1", "Product2", etc in the y-axis.
can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要绑定图表——设置 DataSource 属性并调用 DataBind()。您不需要调用chartSeries.AddItem()。 DataBind() 将为您添加项目。数据源可以是具有两列的数据表——“UnitPrice”和“TenMostExpectiveProducts”。请注意,这些是您为系列中的 DataYColumn 和 XAxis 中的 DataLabelsColumn 设置的名称。
You need to bind the chart -- set the DataSource property and call DataBind(). You will not need to call chartSeries.AddItem(). DataBind() will add the items for you. The datasource can be a DataTable with two columns -- "UnitPrice" and "TenMostExpensiveProducts". See, these are the names you set to DataYColumn in the series and DataLabelsColumn in XAxis.