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
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
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
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
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
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
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
I am glad that this is working fine now. Do not hesitate to contact us if you have other questions.
Regards,
Dimitar
Progress Telerik