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

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

3 Answers 146 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 16 Apr 2016, 10:54 PM

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.

 

 

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 17 Apr 2016, 12:06 AM

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);

0
Dimitar
Telerik team
answered on 18 Apr 2016, 10:27 AM
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.
0
Richard
Top achievements
Rank 1
answered on 20 Apr 2016, 05:02 AM

solved

 

axes purge()

 

thanks

Tags
ChartView
Asked by
Richard
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or