ASP.NET chart management - how to open an autoflow chart area with a blank?

It may seem strange that I want to plot a chart with an empty series.

But here is the deal. My chart displays data from a database between two dates that are provided to a stored procedure.

The result is this:

2011-08-05 - 37,5 2011-08-11 - 20,1 2011-08-16 - 8,0 2011-08-17 - 15,7 

The x axis is plotted on a graph with dates. And the y axis is plotted with numbers (decimal places).

There is no problem building them.

But I want this:

 2011-08-01 - 0 2011-08-02 - 0 ^ etc. v 2011-08-05 - 37,5 2011-08-06 - 20,1 2011-08-07 - 8,0 2011-08-08 - 15,7 ^ etc. v 2011-08-30 - 0 2011-08-31 - 0 

Can someone give me a hint?

My code is as follows:

  <asp:Chart ID="Chart_NormalRegistrations" runat="server" Height="650px" Width="975px" DataSourceID="SqlDataSource1" Palette="Bright"> <Series> <asp:Series Name="Series1" XValueMember="Dato" XValueType="DateTime" ChartArea="" YValueMembers="Total" YValueType="Double" YValuesPerPoint="1"> </asp:Series> </Series> <ChartAreas> <asp:ChartArea Name="ChartArea1"> <AxisY Title="Tid" Interval="5"> </AxisY> <AxisX Title="Dage" Interval="1"> </AxisX> <Area3DStyle Enable3D="True" /> </asp:ChartArea> </ChartAreas> </asp:Chart> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString=" //connectionstring" SelectCommand="stored_proc_regs" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:Parameter DefaultValue="2011-08-01" Name="from" Type="DateTime" /> <asp:Parameter DefaultValue="2011-09-01" Name="to" Type="DateTime" /> </SelectParameters> </asp:SqlDataSource> 
+4
source share
2 answers
 <AxisX Title="Dage" Interval="1"> 

In this tag, you can set an explicit Minimum and Maximum for the axis, and the chart will abide by them. But developing what needs to be installed can be a bit complicated.

Assuming your saved proc returns a DateTime (or sql equivalent), the chart will efficiently convert them to double using OLE Automation Conversion , which is close enough to the number of days after midnight December 30, 1899. If you (as you see) just use markup, you will have to calculate it manually for the dates you want and provide these numbers, since I don’t think the markup of the chart will convert for you.

OADate for 2011-08-01 is 40756 , and to add a day, just add 1 , so 31st is 40786 . Try this and see if it works - if so, you might think about whether you want to simplify this definition by starting to do some code work.

+1
source

Another solution is to insert blank dots into the chart. You will need to use the DataManipulator Class. However, you must also set the maximum x-axis values. eg:

 Chart_NormalRegistration.Series["Series1"]["EmptyPointValue"] = 0; Chart_NormalRegistration.DataManipulator.InsertEmptyPoints(1, IntervalType.Days, 1, IntervalType.Days, "Series1"); 
+1
source

All Articles