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

5 posts, 0 answers
  1. Imran Javed Zia
    Imran Javed  Zia avatar
    55 posts
    Member since:
    Jul 2009

    Posted 17 Oct 2011 Link to this post

    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
  2. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 20 Oct 2011 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Imran Javed Zia
    Imran Javed  Zia avatar
    55 posts
    Member since:
    Jul 2009

    Posted 24 Oct 2011 Link to this post

    We have tried purpossed solution, but it havs no effect except, it changes the labels in x-axis.
  5. Imran Javed Zia
    Imran Javed  Zia avatar
    55 posts
    Member since:
    Jul 2009

    Posted 25 Oct 2011 Link to this post

    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
  6. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 27 Oct 2011 Link to this post

    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 >>
Back to Top
UI for WPF is Visual Studio 2017 Ready