RadChart and Dates on X axis

Thread is closed for posting
3 posts, 0 answers
  1. Tony
    Tony avatar
    3 posts
    Member since:
    Dec 2010

    Posted 31 Aug 2011 Link to this post

    I have a chart that is displaying 365 days of data and I want the X axis labeled only by month. Seems like a simple request but after spending considerable time looking at documentation and numerous forum posts, it looks like it is not as easy as it seems. I have also included an image of how my chart renders. I can get the range on the x axis to display fine however the plotted line does not extend to the end of the graph. Even if the monthly labels are impossible to achieve, I need to AT LEAST get that plotted line to scale to the end of the graph. Of course when I turn the auto scaling on the X axis range does not work.

    Here is my chart and code behind.

    <telerik:RadChart ID="rc1" runat="server" DataSourceID="SqlDataSource1" DefaultType="Line"
        Width="600px">
        <Series>
            <telerik:ChartSeries DataYColumn="ClosePrice" Name="ClosePrice" Type="Line">
                <Appearance ShowLabels="false">
                    <FillStyle MainColor="213, 247, 255">
                    </FillStyle>
                </Appearance>
            </telerik:ChartSeries>
        </Series>
        <Legend Visible="False">
            <Appearance Visible="False">
            </Appearance>
        </Legend>
        <PlotArea XAxis-AutoScale="False">
            <Appearance Dimensions-Margins="18%, 5%, 22%, 10%">
            </Appearance>
            <XAxis LayoutMode="Inside" AutoScale="false" LabelStep="45">
                <Appearance ValueFormat="ShortDate" MajorGridLines-Visible="false">
                    <LabelAppearance RotationAngle="45" Position-AlignedPosition="Top">
                    </LabelAppearance>
                </Appearance>
            </XAxis>
            <YAxis IsZeroBased="false" AxisMode="Extended">
            </YAxis>
        </PlotArea>
        <ChartTitle>
            <TextBlock Text="Title Here" />
        </ChartTitle>
    </telerik:RadChart>

    SqlDataSource1.SelectCommand = "select * from BofIHistoricalData where datadate between '" + 
                DateTime.Now.Date.AddMonths(-12).ToString() + "' and '" + DateTime.Now.Date.AddDays(-1) + "'" +
                "order by datadate";
                   
                double today = DateTime.Now.Date.ToOADate();
                double lastYear = DateTime.Now.Date.AddMonths(-12).ToOADate();
                rc1.PlotArea.XAxis.AddRange(lastYear, today, 1);
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 31 Aug 2011 Link to this post

    Hello Tony,

    Check the following forum thread which discusses similar scenario.
    Display custom format in x-axis.

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tony
    Tony avatar
    3 posts
    Member since:
    Dec 2010

    Posted 31 Aug 2011 Link to this post

    Shinu,

    I have went through both of those forum posts. I need the X-axis labels to change dynamically based on the dates within  the range of data. They can not be static. 

    The code that I included does work some what however the plotted line stops before the end of the graph. Most urgently I need to address that issue.

    Tony

    As an update I think I found partially what the issue is. The yearly data I was populating only had weekdays and did not have data points for Saturdays and Sundays but the range on the X-axis was set for the entire year. That is why the plotted line did not reach the end of the range.

    TC
Back to Top