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

RadChart and Dates on X axis

2 Answers 441 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 31 Aug 2011, 05:09 AM
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 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 31 Aug 2011, 07:22 AM
Hello Tony,

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

Thanks,
Shinu.
0
Tony
Top achievements
Rank 1
answered on 31 Aug 2011, 03:04 PM
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
Tags
Chart (Obsolete)
Asked by
Tony
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Tony
Top achievements
Rank 1
Share this question
or