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

Change chart skin at runtime

4 Answers 152 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dwight
Top achievements
Rank 1
Dwight asked on 07 May 2012, 05:51 AM
Hi

I am making a database web application which uses a telerik reporting report to display some statistical charts based on parameters that the user selects.

What I would like to provide to the end user is a combobox that allows the users the chance to select the skin they want the charts inside the report to have.

The report is shown using a report viewer control on an aspx page.

Is it possible to put the combobox on the aspx page and then reference the charts skin property when the combobox is changed

ie reporviewer.report.chart1.skin = combobox.selectedvalue

Thx for any advice that you can give

Regards

Dwight

4 Answers, 1 is accepted

Sort by
0
Accepted
Steve
Telerik team
answered on 07 May 2012, 04:40 PM
Hi Dwight,

Here is a sample code snippet for the combobox's SelectedIndexChanged event handler:
Copy Code
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
      {
          ComboBox cmb = (ComboBox)sender;
          Telerik.Reporting.Report report = (Telerik.Reporting.Report)this.reportViewer1.Report;
          Telerik.Reporting.Chart chart = (Telerik.Reporting.Chart)report.Items.Find("chart1", true)[0];
          chart.Skin = cmb.SelectedItem.ToString();
          reportViewer1.RefreshReport();
      }

All the best,
Steve
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

0
Dwight
Top achievements
Rank 1
answered on 08 May 2012, 12:55 AM

Thx so much, that worked fantastically :)

I know this is probably an obvious question but my original chart has had the plot area moved using the Plot Area / Appearance / Dimensions values but when I apply the new skin it seems to default back to the original values - see the images

Each time I apply a new skin do I have to rebuild those dimensions via code at runtime or is there a way to preserve them and only change the skin?

If i do have to rebuild them do I do something like this

Use the code above that you gave me to reference the chart then do something like this?

chart.plotarea.appearance.dimensions = (15px, 25px, 5px, 5px)

Thx again for your assistance
0
Steve
Telerik team
answered on 08 May 2012, 12:48 PM
Hi Dwight,

Yes, the chart skin overrides many of the settings (not just the colors) and you would need to set those after the Skin declaration. Another option is to style the chart manually without utilizing the built-in skins.

Regards,
Steve
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

0
Dwight
Top achievements
Rank 1
answered on 09 May 2012, 02:01 AM

Thx so much for the advice, very helpful

Tags
General Discussions
Asked by
Dwight
Top achievements
Rank 1
Answers by
Steve
Telerik team
Dwight
Top achievements
Rank 1
Share this question
or