Charting - Ellipse

Jul 20, 2009 at 9:07 AM

Is it possible to draw a rotated ellipse in a WPF chart, either by using one of the chart types, or by another means?

Any help would be appreciated.

Thanks, John

 

Coordinator
Jul 20, 2009 at 8:17 PM

I'm not sure I understand the question, but re-Templating is always an option to customize the visuals of a WPF control.

Sep 13, 2009 at 10:12 AM

Ok, thanks.  That was very helpful.

I have managed to display rotated ellipses by customizing the ControlTemplate for a ScatterDataPoint (see code below), however I want to specify the width and height of each ellipse in terms of the chart axis coordinates not the WPF coordinates.  For example (ignoring the rotation for now), if I have an ellipse centered at X=5 with Width=2 my code correctly displays the ellipse on the chart at 5 on the independant axis but the ellipse does not span 4 to 6.   Is it possible to convert to chart coordinates?

Many thanks, John

<Style x:Key="dataPointStyle" TargetType="charting:ScatterDataPoint">
  <Setter Property="Width" Value="{Binding Path=Width}"/>
  <Setter Property="Height" Value="{Binding Path=Height}"/>
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="charting:ScatterDataPoint">
        <Grid x:Name="Root" Opacity="1">
          <Ellipse StrokeThickness="{TemplateBinding BorderThickness}" Stroke="{TemplateBinding BorderBrush}" Fill="{TemplateBinding Background}">
            <Ellipse.LayoutTransform>
              <RotateTransform Angle="{Binding Path=Angle}"/>
            </Ellipse.LayoutTransform>
          </Ellipse>
        </Grid>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>