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

set chart height dynamically

3 Answers 192 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Khurram Ilyas
Top achievements
Rank 1
Khurram Ilyas asked on 02 Nov 2010, 12:09 PM
i want to set the height of chart dynamically depending upon the size of rows. here is the code
  void chart1_NeedDataSource(object sender, System.EventArgs e)
    {
        Telerik.Reporting.Processing.Chart chart =
            (Telerik.Reporting.Processing.Chart)sender;
        Telerik.Reporting.Chart chartDefinition = (Telerik.Reporting.Chart)chart.ItemDefinition;
        chartDefinition.Height = new Telerik.Reporting.Drawing.Unit(50, Telerik.Reporting.Drawing.UnitType.Inch);
        
        
        //SqlDataAdapter adapter = new SqlDataAdapter(sqlDataSource1.SelectCommand,sqlDataSource1.ConnectionString);
        //DataSet dataSet = new DataSet();
        
          //  adapter.Fill(dataSet);
        //if (dataSet.Tables[0].Rows.Count != 0)
        {
            chartDefinition.Height = new Telerik.Reporting.Drawing.Unit(this.tableTopEmployees.Items.Count, Telerik.Reporting.Drawing.UnitType.Inch);
        }

        
        
    }
private void chart1_NeedDataSource(object sender, System.EventArgs e)
    {
        Telerik.Reporting.Processing.Chart chart =
            (Telerik.Reporting.Processing.Chart)sender;
        Telerik.Reporting.Chart chartDefinition = (Telerik.Reporting.Chart)chart.ItemDefinition;
        chartDefinition.Height = new Telerik.Reporting.Drawing.Unit(50, Telerik.Reporting.Drawing.UnitType.Inch);
         
         
        //SqlDataAdapter adapter = new SqlDataAdapter(sqlDataSource1.SelectCommand,sqlDataSource1.ConnectionString);
        //DataSet dataSet = new DataSet();
         
          //  adapter.Fill(dataSet);
        //if (dataSet.Tables[0].Rows.Count != 0)
        {
            chartDefinition.Height = new Telerik.Reporting.Drawing.Unit(this.tableTopEmployees.Items.Count, Telerik.Reporting.Drawing.UnitType.Inch);
        }
 
         
         
    }
     
        
private void chart1_NeedDataSource(object sender, System.EventArgs e)
    {
        Telerik.Reporting.Processing.Chart chart =
            (Telerik.Reporting.Processing.Chart)sender;
        Telerik.Reporting.Chart chartDefinition = (Telerik.Reporting.Chart)chart.ItemDefinition;
        chartDefinition.Height = new Telerik.Reporting.Drawing.Unit(50, Telerik.Reporting.Drawing.UnitType.Inch);
      chartDefinition.Height = new Telerik.Reporting.Drawing.Unit(6, Telerik.Reporting.Drawing.UnitType.Inch);
            //chartDefinition.Height = new Telerik.Reporting.Drawing.Unit(this.tableTopEmployees.Items.Count, Telerik.Reporting.Drawing.UnitType.Inch);
        
    }
   But height remain the same as it was initialize which is zero.

Thank,
-Saqib

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 02 Nov 2010, 12:42 PM
Hello Khurram Ilyas,

When you're in the context of events, you should set the size to the processing counterpart e.g.:

private void chart1_NeedDataSource(object sender, EventArgs e)
        {
            Telerik.Reporting.Processing.Chart chart = (Telerik.Reporting.Processing.Chart)sender;
            chart.Height = new Telerik.Reporting.Drawing.Unit(10, UnitType.Cm);
        }

Greetings,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Khurram Ilyas
Top achievements
Rank 1
answered on 02 Nov 2010, 01:22 PM
still the same problem . I don't know what's wrong in it.
  Telerik.Reporting.Processing.Chart chart = (Telerik.Reporting.Processing.Chart)sender;
        chart.Height = new Telerik.Reporting.Drawing.Unit(10, Telerik.Reporting.Drawing.UnitType.Inch);
private void chart1_NeedDataSource(object sender, System.EventArgs e)
{
    Telerik.Reporting.Processing.Chart chart = (Telerik.Reporting.Processing.Chart)sender;
    chart.Height = new Telerik.Reporting.Drawing.Unit(10, Telerik.Reporting.Drawing.UnitType.Inch);
    }
0
Steve
Telerik team
answered on 04 Nov 2010, 05:37 PM
Hi Khurram Ilyas,

Please post the reporting version you're using. I've also attached a sample report tested against the latest Q2 SP1 version which works as expected.

Regards,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Khurram Ilyas
Top achievements
Rank 1
Answers by
Steve
Telerik team
Khurram Ilyas
Top achievements
Rank 1
Share this question
or