[英]How To Make A Multiline Data Label In A Bar Chart?
This may seem like a issue that is easy to solve but I have not been able to solve it. 这似乎是一个容易解决的问题但我无法解决它。 Basically, I have a bar chart on a html web page.
基本上,我在html网页上有一个条形图。 Using the System.Web.UI.DataVisualization.Charting to create the charts.
使用System.Web.UI.DataVisualization.Charting创建图表。 What I want to do is change the look of the label.
我想要做的是改变标签的外观。 An idea of how my label looks like is: "M: 312 A: 321 S: 432".
我的标签看起来如何:“M:312 A:321 S:432”。 What I would like to do is make them on top of one another, not side by side.
我想做的是让它们彼此叠加,而不是并排。 So "M: ..." will be the first line then the others.
所以“M:......”将是第一线,然后是其他线。 So three lines in total.
所以共有三行。 Is there anyway I can do that?
无论如何我能做到吗?
Code: 码:
Chart1.Visible = true;
DataTableReader datareader = table.CreateDataReader();
Chart1.DataBindCrossTable(datareader, "FunctionGroup", "Date", "AverageGrading", "");
Chart1.Legends.Add("Legend");
Chart1.ChartAreas[0].AxisX.Title = "Period of feedback";
Chart1.ChartAreas[0].AxisY.Title = "Average grade";
Chart1.Legends[0].Enabled = true;
Chart1.Legends[0].BackColor = System.Drawing.Color.Transparent;
Chart1.Width = 1000;
Chart1.Height = 600;
ArrayList listOfStDev = new ArrayList();
ArrayList listOfMed = new ArrayList();
foreach (DateTime date in listofdates)
{
listOfStDev.Add(dbmanager.GetStdDevAppraisalForFunction(section, functionlist, date, questionID));
listOfMed.Add(GetMedianFunctionViaSectionCount(section, functionlist, date, questionID));
}
for (int i = 0; i < Chart1.Series.Count; i++)
{
for (int k = 0; k < Chart1.Series[i].Points.Count; k++)
{
Chart1.Series[i].Points[k].Label = "A: " + "#VALY" + " S: " + Convert.ToDouble(listOfStDev[k]).ToString("F") + " M: " + Convert.ToDouble(listOfMed[k]).ToString();
}
}
Try this: 尝试这个:
<asp:Chart ID="Chart1" runat="server">
<Series>
<asp:Series Name="Series1" Label="A: #VAL\nS: #VALX\nM: #INDEX">
<Points>
<asp:DataPoint XValue="1" YValues="10" />
<asp:DataPoint XValue="2" YValues="20" />
<asp:DataPoint XValue="3" YValues="30" />
</Points>
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
<AxisY>
<MajorGrid LineColor="DarkGray" LineDashStyle="Dot" />
</AxisY>
<AxisX>
<MajorGrid LineColor="DarkGray" LineDashStyle="Dot" />
</AxisX>
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.