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

Line Chart with Daily Data as Show chart as Weekly, monthly and Quarterly Data

4 Answers 172 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Imran Javed Zia
Top achievements
Rank 1
Imran Javed Zia asked on 17 Oct 2011, 07:05 PM
Hi,

We have a chart bind to List of custom object with 3 properties with 1000+, One is DateTime, other two are double values, there is a single line for each value so we have two lines for the given data. It is working fine and we don't have any problem except that chart shows line as there values weekly instead of daily values.

Next we need to show chart for data weekly, monthly and or quarterly as per user requirements. Is there any built in functionality to show chart as weekly or monthly while we have daily data.

Thanks

4 Answers, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 20 Oct 2011, 02:48 PM
Hi Imran Javed Zia,

I can suggest you changing the DefaultLabelFormat of your Axis from showing weekly to showing daily values, for example:
radChart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "ddd";

Regarding your other question, you could use our Zooming and Scrolling feature. A demo example of it can be found here. It is the Silverlight demo, but it is basically the same for WPF. 

You could also wire to the PropertyChanged event and attach a similar method like the one below to set the label format depending on the ZoomScroll range:
RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.PropertyChanged += ZoomScrollSettingsX_PropertyChanged;
private void ZoomScrollSettingsX_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
    double range = (sender as ZoomScrollSettings).Range;
  
    if (range > 0.7d)
    {
        RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "yyyy";
        RadChart1.DefaultView.ChartArea.AxisX.StepLabelLevelCount = 1;
    }
    else if (range > 1d / 12d)
    {
        RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "MMMM yyyy";
        RadChart1.DefaultView.ChartArea.AxisX.StepLabelLevelCount = 2;
    }
    else if (range > 1d / 12d / 30d)
    {
        RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "dd MMM yyyy";
        RadChart1.DefaultView.ChartArea.AxisX.StepLabelLevelCount = 2;
    }
    else
    {
        RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "dd-MMM (HH:mm)";
        RadChart1.DefaultView.ChartArea.AxisX.StepLabelLevelCount = 2;
    }
}

Hope that helps.

All the best,
Peshito
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Imran Javed Zia
Top achievements
Rank 1
answered on 24 Oct 2011, 03:33 PM
We have tried purpossed solution, but it havs no effect except, it changes the labels in x-axis.
0
Imran Javed Zia
Top achievements
Rank 1
answered on 25 Oct 2011, 12:31 PM
Hi,
Although, we are not lucky to get help from provided method, but we found follwoing two links regarding Zoom and sampling. we have not used sampling yet, but we have enabled zooming, and we are getting a little issue that if there is missing date range in the data then oom fails on that area and chart shows message "no data" and every thing gets disappear. 

can you help us in this regards? 
 
http://www.telerik.com/help/wpf/radchart-features-zooming-and-scrolling.html
http://www.telerik.com/help/wpf/radchart-features-sampling.html

Thanks
0
Peshito
Telerik team
answered on 27 Oct 2011, 03:36 PM
Hi Imran Javed Zia,

Try using the MinZoomRange which specifies the minimal range that can be visible in the ChartArea. For instance, a minimal range of 0.1 will display 10% of the whole series (the series will get zoomed 10x).
Example:
radChart.DefaultView.ChartArea.ZoomScrollSettingsX.MinZoomRange = 0.4;
This way you should avoid zooming the chart to a range that will then display the "No data" message.

Hope that helps.

Greetings,
Peshito
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
Chart
Asked by
Imran Javed Zia
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Imran Javed Zia
Top achievements
Rank 1
Share this question
or