SfChart SeriesClipRect Top is always zero

Hello,

I'm listening to MouseMove events for an SfChart. I need to convert the mouse position to a position in the actual chart area. The code I'm suggested to use is:

private void MyChart_MouseMove(object sender, MouseEventArgs e)
{
  var x = e.GetPosition(myChart).X - myChart.SeriesClipRect.Left;
  var y = e.GetPosition(myChart).Y - myChart.SeriesClipRect.Top;
  ...
  
But even though my chart has a header and a legend above the actual chart area myChart.SeriesClipRect.Top is always zero. Have I missunderstood something, or is this a bug?

I've attached an example.

Best regards,
Marcus

Attachment: example_e3cd97c6.zip

3 Replies 1 reply marked as answer

YP Yuvaraj Palanisamy Syncfusion Team April 12, 2021 12:30 PM UTC

Hi Marcus, 
 
Greetings from Syncfusion. 
 
We have analyzed your query and we are validating the behavior of the reported query “SeriesClipRect Top position is zero even we have header and legend”. And we will update you with complete details on or before 14th April, 2021. 
 
Regards, 
Yuvaraj. 



YP Yuvaraj Palanisamy Syncfusion Team April 14, 2021 03:26 PM UTC

Hi Marcus, 
 
Thanks for your patience. 
 
We understood your requirement “Get chart series rendering area top position” and currently we are validating this and we will provide you with complete details on or before 16th April, 2021. 
 
Regards, 
Yuvaraj.


YP Yuvaraj Palanisamy Syncfusion Team April 16, 2021 01:24 AM UTC

Hi Marcus, 
 
Thanks for your patience. 
 
Currently SeriesClipRect does not considering the Header and Legend desired size. And we can get the series rendering position with the help of internal property “InternalCanvas” of SfChart using reflection. 
 
Also, for better UI we have margin becomes “5” in source level. Hence, we can set the margin to zero by using below code snippet. 
 
CodeSnippet: 
public class SfChartExt : SfChart 
{ 
    public override void OnApplyTemplate() 
    { 
        base.OnApplyTemplate(); 
        var dockPanel = GetTemplateChild("Part_DockPanel") as ChartDockPanel; 
        if (dockPanel != null) 
            (dockPanel.Children[0] as ContentPresenter).Margin = new Thickness(0); 
    } 
} 
 
[Xaml]: 
<local:SfChartExt  x:Name="chart" Grid.Row="0" Header="I'm a Header"> 
    <local:SfChartExt.PrimaryAxis> 
        <syncfusion:NumericalAxis/> 
    </local:SfChartExt.PrimaryAxis> 
 
   . . . 
 
</local:SfChartExt > 
 
Getting series position: 
private void Button_Click(object sender, RoutedEventArgs e) 
{ 
    PropertyInfo propertyinfo = typeof(SfChart).GetProperty("InternalCanvas", BindingFlags.NonPublic | BindingFlags.Instance); 
 
    if (propertyinfo != null) 
    { 
        var panel = (Panel)propertyinfo.GetValue(chart); 
        var seriesPos = panel.TransformToVisual(chart).Transform(new Point(0, 0)); 
 
        Debug.WriteLine($"SeriesPosition= {seriesPos}"); 
        Debug.WriteLine($"TopPosition= {seriesPos.Y}"); 
    } 
} 
 
 
Also, we have attached the sample for your reference. Please find the sample from the below link. 
 
  
Regards, 
Yuvaraj. 


Marked as answer
Loader.
Up arrow icon