下午好,
我正在使用数据库中的数据动态创建许多雷达图表。
数据集看起来像
X | Y
--------
1 2
2 2
3 1
4 4
5 0
6 2
显示图表时,Xaxis标签不可见 任何人都可以推荐为什么会这样吗?
到目前为止,这是我的代码......
Chart aRadarChart = new Chart();
aRadarChart.Width = Unit.Pixel(450);
aRadarChart.DataSource = dt;
// Add title
Title t = new Title(title, Docking.Top, new Font("Helvetica Neue", 12f, FontStyle.Bold), ColorTranslator.FromHtml("#696969"));
aRadarChart.Titles.Add(t);
//aRadarChart.Titles.
// Add a legend
Legend lgnd = new Legend();
lgnd.Enabled = true;
aRadarChart.Legends.Add(lgnd);
//Important: add ChartArea, otherwise no graph will be shown
ChartArea ca = new ChartArea("myChartArea");
ca.AxisX.Interval = 1;
ca.AxisX.TextOrientation = TextOrientation.Horizontal;
aRadarChart.ChartAreas.Add(ca);
ca.AxisY.Maximum = 4;
string car = String.Empty;
for (int i = 1; i < dt.Columns.Count; i++)
{
car = dt.Columns[i].ColumnName;
aRadarChart.Series.Add(car);
aRadarChart.Series[car].YValueMembers = car;
aRadarChart.Series[car].XValueMember = dt.Columns[0].ColumnName.ToString();
//Define here: what kind of Chart you want
aRadarChart.Series[car].ChartType = SeriesChartType.Radar;
aRadarChart.Series[car]["RadarDrawingStyle"] = "Line";
aRadarChart.Series[car].BorderWidth = 3;
}
//binding data
aRadarChart.DataBind();
aRadarChart.ImageStorageMode = ImageStorageMode.UseImageLocation;//.UseHttpHandler;
//Add Chart to a PlaceHolder Control
pnlMainContent.Controls.Add(aRadarChart);
由于 我已经阅读过如何将间隔设置为等于1.但这不是诀窍。
答案 0 :(得分:0)
我发现它为什么不工作 - 在sql的select语句中我必须将x轴列转换为varchar类型。它最初是int类型。