Fit ChartView Area to Container

5 posts, 1 answers
  1. Joavn
    Joavn avatar
    7 posts
    Member since:
    Feb 2019

    Posted 01 Feb Link to this post

    Hello, i would like to know if it's possible to resize chart view area to fit container, at the moment whole ChartView is docked to "Fill" for that container but Area has that white border.

    Example what i want is shown on image.

     

    Thanks in advance.

  2. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3224 posts

    Posted 01 Feb Link to this post

    Hello, Joavn,       

    By default, RadChartView there is a margin applied to its view. In order to eliminate it, you can use the following code snippet:

    LineSeries lineSeries = new LineSeries();
    lineSeries.DataPoints.Add(new CategoricalDataPoint(20, "Jan"));
    lineSeries.DataPoints.Add(new CategoricalDataPoint(22, "Apr"));
    lineSeries.DataPoints.Add(new CategoricalDataPoint(12, "Jul"));
    lineSeries.DataPoints.Add(new CategoricalDataPoint(19, "Oct"));
    this.radChartView1.Series.Add(lineSeries);
     
    this.radChartView1.ChartElement.View.Margin = new Padding(0);


     

    I hope this information helps. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Joavn
    Joavn avatar
    7 posts
    Member since:
    Feb 2019

    Posted 02 Feb Link to this post

    Works great but there's one problem.
    I don't wanna show axes so i do radChartView.Axes.Clear();

    And gives me that result sadly.
    Is there a way to not show axes and to have it streched to fit view?

  4. Joavn
    Joavn avatar
    7 posts
    Member since:
    Feb 2019

    Posted 04 Feb Link to this post

    I marked your post as answer as it did help in what i needed. Thanks!
  5. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3224 posts

    Posted 06 Feb Link to this post

    Hello, Joavn,         
     
    RadChartView relies on the axes in order to draw the series correctly. That is why instead of clearing the axis, I would recommend just to hide them. This will not break the rending mechanism:

    LineSeries lineSeries = new LineSeries();
    lineSeries.DataPoints.Add(new CategoricalDataPoint(20, "Jan"));
    lineSeries.DataPoints.Add(new CategoricalDataPoint(22, "Apr"));
    lineSeries.DataPoints.Add(new CategoricalDataPoint(12, "Jul"));
    lineSeries.DataPoints.Add(new CategoricalDataPoint(19, "Oct"));
    this.radChartView1.Series.Add(lineSeries);
     
    this.radChartView1.ChartElement.View.Margin = new Padding(0);
     
    lineSeries.HorizontalAxis.IsVisible = false;
    lineSeries.VerticalAxis.IsVisible = false;

    Should you have further questions please let me know.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top