標準の ASP.NET Chart コントロールを使用して、次のデータからポイント グラフを作成しています。
X Y
32.6768, 1
32.6768, 2
32.6768, 3
32.6768, 4
32.678, 5
32.678, 6
187.862, 1
187.862, 2
データは、チャートがデータ バインドされているDataTable
parsed as型に読み込まれます。Double
以下に示すように、コントロールはデータを見つけて描画しますが、期待どおりにはなりません。
画像が示すように、軸は連続ではなく離散的です。ラベルは、個々のデータ ポイントを含めて正常に表示されます。コードでは次の設定が設定されています。
ASP.NET:
<asp:Series Name="DataSeries" XValueType="Double" YValuesPerPoint="25">
// 25 used in case other data sets are larger
C# バックエンド:
chtData.Series["DataSeries"].ChartType = SeriesChartType.Point;
DataView dv = new DataView(/* DataTable Instance */);
chtData.Series["DataSeries"].Points.DataBind(dv, /* X-axis column title */, */ Y-axis column title */, "");
グラフの表示を修正するために設定する必要がある追加のプロパティはありますか? ChartArea
問題ではなく問題ですかSeries
?
リクエストに応じて、インスタンスにデータを入力するコードを次に示しDataTable
ます。入力文字列からのデータは、(文字ごとに) 個々の行に分割され\n
ます。次に、各行は値の間の空白で分割されます。
string[] row = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (!columnsFound)
{
// columns: int to hold number of columns required in DataTable
columns = row.GetLength(0);
columnsFound = true;
if (columns == 4) this.DataPoints.Columns.Add("Label"); // Labels for data points
this.DataPoints.Columns.Add(this.XAxis); // string with X-axis label
this.DataPoints.Columns.Add(this.YAxis); // string with Y-axis label
if (columns >= 3) this.DataPoints.Columns.Add(this.ColumnThree); // string with label for a third data column - not used in the graph
}
if (columns == 4) this.DataPoints.Rows.Add(row[0], double.Parse(row[1]), double.Parse(row[2]), double.Parse(row[3]));
else if (columns == 3) this.DataPoints.Rows.Add(double.Parse(row[0]), double.Parse(row[1]), double.Parse(row[2]));
else this.DataPoints.Rows.Add(double.Parse(row[0]), double.Parse(row[1]));