Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET Chart axis is displayed discrete rather than continuous for point chart
    text
    copied!<p>I am using the standard ASP.NET Chart control to create a point graph from the following data:</p> <pre><code>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 </code></pre> <p>The data is read into a <code>DataTable</code> parsed as <code>Double</code> type to which the chart is data bound. The control finds the data and draws it, but not as expected, as shown below:</p> <p><img src="https://i.stack.imgur.com/XWM3h.png" alt="ASP.NET Chart"></p> <p>As the image shows, the axis is discrete rather than continuous. The label are displayed fine including individual data points. The following settings have been set in the code:</p> <p>ASP.NET:</p> <pre><code>&lt;asp:Series Name="DataSeries" XValueType="Double" YValuesPerPoint="25"&gt; // 25 used in case other data sets are larger </code></pre> <p>C# Backend:</p> <pre><code>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 */, ""); </code></pre> <p>Are there any additional properties I should be settings to correct the chart display? Is it a <code>ChartArea</code> issue rather than a <code>Series</code> issue?</p> <p>As requested, here is the code to populate the <code>DataTable</code> instance. The data from an incoming string is split into individual lines (by the <code>\n</code> character). Each line is then split by whitespace between the values:</p> <pre><code>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 &gt;= 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])); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload