This is a migrated thread and some comments may be shown as answers.

Chart of Time, include missing dates

1 Answer 103 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Indy
Top achievements
Rank 1
Veteran
Indy asked on 18 May 2020, 02:21 PM

Hi

I am using the asp.net charting control.  I am plotting data over time, sometimes over days, weeks, months and years.  I would like th X axis (which shows time) on the graph to be sequential even if the data is not.  eg, if a week/month/year is missing it will plot a the item on the X axis but not have a value (hope that makes sense).  So effectively the chart looks like a timeline of data, the gaps shows missing data

 

Is this possible with the chart control?

Many thanks in advance

 

 

 

 


1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 20 May 2020, 02:30 PM

Hi Indy,

You can control the labels appearance of the XAxis by setting the step between the date. For example, you can have a similar setup:

        <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="640px" Height="480px">
            <PlotArea>
                <Series>
                    <telerik:ColumnSeries DataFieldY="SellQuantity" >
                    </telerik:ColumnSeries>
                </Series>
                <XAxis BaseUnit="days" MinDateValue="05/10/2020" Step="1" Type="Date" DataLabelsField="SellDate"
                    EnableBaseUnitStepAuto="false" >
                    <LabelsAppearance DataFormatString="d" RotationAngle="45">
                    </LabelsAppearance>
                </XAxis>
                <YAxis>
                    <TitleAppearance Text="Quantity">
                    </TitleAppearance>
                    <MajorGridLines Color="#EFEFEF" Width="1"></MajorGridLines>
                    <MinorGridLines Color="#F7F7F7" Width="1"></MinorGridLines>
                </YAxis>
            </PlotArea>
            <ChartTitle Text="Sold Cars per Date">
            </ChartTitle>
        </telerik:RadHtmlChart>

    protected void Page_Load(object sender, EventArgs e)
    {
        RadHtmlChart1.DataSource = GetData();
        RadHtmlChart1.DataBind();
    }

    protected DataTable GetData()
    {
        DataTable dt = new DataTable();

        dt.Columns.Add("ID", typeof(int));
        dt.Columns.Add("SellQuantity", typeof(int));
        dt.Columns.Add("SellDate", typeof(DateTime));

        dt.Rows.Add(1, 2, new DateTime(2020, 05, 10));
        dt.Rows.Add(2, 5, new DateTime(2020, 05, 14));
        dt.Rows.Add(3, 6, new DateTime(2020, 05, 22));

        return dt;
    }

Regards,
Vessy
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Chart (HTML5)
Asked by
Indy
Top achievements
Rank 1
Veteran
Answers by
Vessy
Telerik team
Share this question
or