URGENT!! pls help, Chartview become smaller and smaller (zoomed out) when binding the new data

4 posts, 0 answers
  1. Richard
    Richard avatar
    3 posts
    Member since:
    Apr 2015

    Posted 16 Apr Link to this post

    it is super weird. I spend over 4 hours 

    my project has very simple data table :

    date,quantitysold,AverageQuantity,  in datatime, int, int

    date will be X

    quantitysold, averageQuantity, will be Y1 and Y2

    first, user will get the product ID table into gridview and when choosing the product to show the chart,

    the radchartview should popup/update the chart based on the product PID

    I could make it work when I click the first product ID, erverything is ok, but more I click the datagrid to view the product sales data , the chartview becomes more smaller, please refer to the screenshots

    everytime I click the data, I first make series.clear(), and tested area clear(), chart refresh, update.

     

     

       private void radGridView_197_data_CellClick(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
            {
                this.radChartView_197_chart.Series.Clear();
                this.radChartView_197_chart.Area.Series.Clear();
                this.radChartView_197_chart.Refresh();
                this.SetChartViewData();
             //   if (gridview_197_firstClick)
                this.SetupChartView();

    ....more other code here ,

    ....

     

                   CartesianArea area = this.radChartView_197_chart.GetArea<CartesianArea>();
                    area.ShowGrid = true;
                    CartesianGrid grid = area.GetGrid<CartesianGrid>();
                    grid.DrawHorizontalStripes = true;

     

     

    ...............more code here to update the table which is every time different because product id changed.

     this.radChartView_197_chart.DataSource = table;
             
                this.radChartView_197_chart.Update();
                this.radChartView_197_chart.Refresh();

     

     

     

    }
              

    there is no zoom related setup , I tried almost everything, but there is very limited source online to bind the new data source.

     

    please let me know how to do this.

     

     

     

     

     

     

     

  2. Richard
    Richard avatar
    3 posts
    Member since:
    Apr 2015

    Posted 16 Apr Link to this post

    update:

     

    just find the very strange problem

    in my test code,

    if I comm out

    //   speed.VerticalAxis = speedAxis;
             //  speed.HorizontalAxis = horizontalAxis;

    then it works without any problem (but without multiple verticalaxis, chart is useless since use all shared Y and X )

    left any verticalaxis or horzontalaxis will cause the chart zoomed out at that direction.

     

     

     

     

    LineSeries speed = new LineSeries();
             //   speed.LegendTitle = "Qty";
                speed.ValueMember = "Qty";
                speed.CategoryMember = "Time";
                LinearAxis speedAxis = new LinearAxis();
                speedAxis.AxisType = AxisType.First;
                speedAxis.Title = "Quantity";
               // speedAxis.Minimum = 0;
                //speedAxis.Maximum = 500;
             //   speed.VerticalAxis = speedAxis;
               speed.HorizontalAxis = horizontalAxis;
                this.radChartView_197_chart.Series.Add(gear);

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 18 Apr Link to this post

    Hello Richard,

    Thank you for writing.

    In this case, you should remove the axes after the series are cleared: 
    radChartView1.Series.Clear();
    radChartView1.Axes.Purge();
     
    LineSeries speed = new LineSeries();
    //   speed.LegendTitle = "Qty";
    speed.ValueMember = "Qty";
    speed.CategoryMember = "Time";
    speed.DataSource = GetTable();
     
    LinearAxis speedAxis = new LinearAxis();
    speedAxis.AxisType = AxisType.Second;
    speedAxis.Title = "Quantity";
    speedAxis.Minimum = 0;
    speedAxis.Maximum = 500;
     
    speed.VerticalAxis = speedAxis;   
    this.radChartView1.Series.Add(speed);

    Let me know if you have additional questions.

    Regards,
    Dimitar
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  5. Richard
    Richard avatar
    3 posts
    Member since:
    Apr 2015

    Posted 20 Apr Link to this post

    solved

     

    axes purge()

     

    thanks

Back to Top