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

Synchronize size/width for two RadCartesianChart's

8 Answers 115 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Maurer
Top achievements
Rank 2
Maurer asked on 07 Aug 2017, 01:53 PM

Dear Support Team

I need to sync position and width for two RadCartesianChart's considering multiple axes.

Please see attached image, the vertical axes to first and second chart start unsynchronized.

How can we solve this issue?

Thanks in advance!

Best regards,

Henrique

8 Answers, 1 is accepted

Sort by
0
Maurer
Top achievements
Rank 2
answered on 07 Aug 2017, 02:00 PM
Please see, other image
0
Accepted
Dimitar
Telerik team
answered on 08 Aug 2017, 05:53 AM
Hello Henrique,

You need to adjust the margin of the first chart. To calculate the offset you can use the GetLocationOfValue method and get the location of the first point on the horizontal axis. For example:
private void radButton1_Click(object sender, EventArgs e)
{
    var value1 = ((CategoricalAxis)radChartView1.Axes[0]).GetLocationOfValue("Jan");
    var value2 = ((CategoricalAxis)radChartView2.Axes[0]).GetLocationOfValue("Jan");
 
    double leftPadding = (value2 - value1) + 40;
 
    radChartView1.View.Margin = new Padding((int)leftPadding, 40, 40, 40);
}

Please note that the default margin is 40 pixels on each side.

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Maurer
Top achievements
Rank 2
answered on 16 Aug 2017, 09:04 PM

Dear Dimitar your sugestion is very usefull thanks,

Today we applies your solution with some adjusts and works perfectly, but when the legends are applied  in right or left position the second chart does not adjusts the margin automatically. 

I need get the start position of legends from first chart to sync the margins of second chart.

Please see attached image.

How can we solve this issue?

Thanks in advance!

Best regards,

Henrique

0
Accepted
Dimitar
Telerik team
answered on 17 Aug 2017, 07:48 AM
Hi Henrique,

Here is how you can get the legend width:
var value1 = ((CategoricalAxis)radChartView1.Axes[0]).GetLocationOfValue("Jan");
var value2 = ((CategoricalAxis)radChartView2.Axes[0]).GetLocationOfValue("Jan");
 
double leftPadding = (value2 - value1) + radChartView2.View.Margin.Left + radChartView2.ChartElement.LegendElement.Size.Width;
 
radChartView1.View.Margin = new Padding((int)leftPadding, 40, 40, 40);

I hope this will be useful. 

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Maurer
Top achievements
Rank 2
answered on 21 Aug 2017, 12:30 PM

Dear Dimitar,

we need get the event when the ChartElement.LegendPosition is changed

How can we find this event?

Thanks in advance!

Best regards,

Henrique

0
Accepted
Dimitar
Telerik team
answered on 22 Aug 2017, 05:56 AM
Hi Henrique,

The following snippet shows how you can detect that the title position is changed:
//subscribe to this event
radChartView2.ChartElement.LegendElement.PropertyChanged += ChartElement_PropertyChanged;
 
// use the Dock property
private void ChartElement_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
    if (e.PropertyName == "Dock")
    {
 
    }
}

I hope this will be useful. 

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Maurer
Top achievements
Rank 2
answered on 22 Aug 2017, 06:48 PM

Hi Dimitar,

Thank you very much for your support!

your suggestion was very good to adjust two chart views considering the first chart wich a Multi-Axes support and the second Chart where does not support Multi-Axes.

We did sync size/width for two RadCartesianChart's based in the 'ChartElement.LegendPosition' ! 

Best regards,

Henrique

0
Dimitar
Telerik team
answered on 23 Aug 2017, 06:43 AM
Hi Henrique,

I am glad that this is working fine now. Do not hesitate to contact us if you have other questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
ChartView
Asked by
Maurer
Top achievements
Rank 2
Answers by
Maurer
Top achievements
Rank 2
Dimitar
Telerik team
Share this question
or