Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.Net Chart X Axis showing misleading date labels
    text
    copied!<p>I've got a straight forward column chart with 4 series on it, % on the Y and DateTime on the X axis. All is working fine except that the X axis labeling and interval marks are incorrect (well, misleading). The 1st cluster of columns are Januarys data, however the chart positions the cluster directly on top of a Feb label. The interval line (is that the correct name?) isn't helping either as it runs through the cluster of Januarys data making it look like col 1 &amp; 2 are in Jan and col 3 and 4 in Feb. The data being used runs from Jan to July, with Aprils missing (intentional), however the chart makes it look like it runs Feb to Aug with May missing.</p> <p><img src="https://i.stack.imgur.com/HCOXf.jpg" alt="Dodgy Chart"></p> <p>Data <img src="https://i.stack.imgur.com/wg296.jpg" alt="Correct Data"></p> <p>So my questions is: How can I centre the clusters of columns in their own interval section with the correct month label on the X axis directly below it? I can even live without the interval line as long as the correct month displays below the correct data. </p> <p>I've tried this chart with Splines, Lines and without any formatting and they all have the same problem. Help. It's Friday and I want to get this fixed so I can go to the pub.</p> <p>Update: As requested - code behind:</p> <pre><code> // set Y axix range Chart1.ChartAreas["ChartArea1"].AxisY.Minimum = 0; Chart1.ChartAreas["ChartArea1"].AxisY.Maximum = 100; // show y line every x% Chart1.ChartAreas[0].AxisY.Interval = 10; // Set axis title Chart1.ChartAreas["ChartArea1"].AxisX.Title = "Period"; Chart1.ChartAreas["ChartArea1"].AxisY.Title = "Percentage (%)"; // set the x axis date format to short month and year Chart1.ChartAreas[0].AxisX.IsLabelAutoFit = false; Chart1.ChartAreas[0].AxisX.LabelStyle.Format = "MMM \n yyyy"; // The legend Chart1.Legends.Add("Default"); Chart1.Legends["Default"].Docking = Docking.Bottom; Chart1.Legends["Default"].Alignment = StringAlignment.Center; // load the template for the basic styles Chart1.Serializer.IsResetWhenLoading = false; Chart1.LoadTemplate("SkyBlue.xml"); </code></pre> <p>and mark up:</p> <pre><code>&lt;asp:Chart ID="Chart1" runat="server" DataSourceID="SqlDataSource1" Width="600px"&gt; &lt;Series&gt; &lt;asp:Series Name="thing1" XValueMember="Period" YValueMembers="thing1"&gt; &lt;/asp:Series&gt; &lt;asp:Series ChartArea="ChartArea1" Name="Team" XValueMember="Period" YValueMembers="thing2"&gt; &lt;/asp:Series&gt; &lt;asp:Series ChartArea="ChartArea1" Name="Systems" XValueMember="Period" YValueMembers="thing3"&gt; &lt;/asp:Series&gt; &lt;asp:Series ChartArea="ChartArea1" Name="Env" XValueMember="Period" YValueMembers="thing4"&gt; &lt;/asp:Series&gt; &lt;/Series&gt; &lt;ChartAreas&gt; &lt;asp:ChartArea Name="ChartArea1"&gt; &lt;/asp:ChartArea&gt; &lt;/ChartAreas&gt; &lt;/asp:Chart&gt; &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:myConnString %&gt;" SelectCommand="mySP" SelectCommandType="StoredProcedure"&gt; &lt;SelectParameters&gt; &lt;asp:Parameter DefaultValue="1" Name="ID" Type="Int32" /&gt; &lt;/SelectParameters&gt; &lt;/asp:SqlDataSource&gt; </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