Telerik RadChart Xaxis DataColumn non mostra
-
12-12-2019 - |
Domanda
Ho un databilitabile che aggiungo al grafico in Foreach Loop come seguito e assegnando Dtmonth DataRow a Xaxis del grafico, che è il nomi del mese:
foreach (DataRow dr in dtMD.Rows)
{
DataTable dtMDByName = ocw.GetMDByName(Convert.ToDateTime(txtStartDate.Text), Convert.ToDateTime(txtEndDate.Text), dr["MD"].ToString());
if (dtMDByName.Rows.Count > 0)
{
ChartSeries MDChartSeries = new ChartSeries();
MDChartSeries.Name = dtMDByName.Rows[0][1].ToString();
MDChartSeries.Type = ChartSeriesType.Line;
foreach (DataRow drByName in dtMDByName.Rows)
{
MDChartSeries.AddItem(Convert.ToDouble(drByName["T"]));
radMD.PlotArea.XAxis.DataLabelsColumn = drByName["dtMonth"].ToString();
}
radMD.ChartTitle.TextBlock.Text = "MDs";
radMD.PlotArea.XAxis.AutoScale = true;
radMD.Series.Add(MDChartSeries);
}
}
.
Ma ancora mostra come numeri in Xaxis, tutto ciò che sto sbagliando nel codice sopra?
Anche se lo faccio al di fuori del secondo loop I.e il seguente codice non mostra i nomi del mese:
radMD.PlotArea.XAxis.DataLabelsColumn = "dtMonth";
.
Grazie
Soluzione
Scoperto È necessario impostare AutoScale su FALSE e quindi aggiungere TEXTBLOCK come segue:
radMD.PlotArea.XAxis.AutoScale = true;
for (int i = 0; i < dtMDByName.Rows.Count; i++)
{
radMD.PlotArea.XAxis[i].TextBlock.Text = dtMDByName.Rows[i][3].ToString();
}
. Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow