Page 1 of 1

Polar series's ClockWiseLabels

Posted: Thu Mar 05, 2009 7:24 am
by 13050248
Hi

Why does the order of setting ClockWiseLabels and adding the series data affect the output?

Shouldn't case 4 & 5 give the same plot?

(case 4)
BEFORE adding data:
series.ClockWiseLabels = true;

(case 5)
AFTER adding data:
series.ClockWiseLabels = true;


<Window x:Class="WPFDemo.Window5"
xmlns="http://schemas.microsoft.com/winfx/2006 ... esentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WPF="clr-namespace:Steema.TeeChart.WPF;assembly=TeeChart.WPF"
Title="Window5" Height="600" Width="800">
<TabControl>
<TabItem Header="4">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<Label Grid.Row="0" x:Name="m_Label4"/>
<WPF:TChart Grid.Row="1" x:Name="m_Chart4"/>
</Grid>
</TabItem>
<TabItem Header="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<Label Grid.Row="0" x:Name="m_Label5"/>
<WPF:TChart Grid.Row="1" x:Name="m_Chart5"/>
</Grid>
</TabItem>
</Window>

public partial class Window5
{
public Window5()
{
InitializeComponent();
initChart4(m_Chart4, m_Label4);
initChart5(m_Chart5, m_Label5);
}

public void setupChart(TChart chart)
{
chart.SnapsToDevicePixels = true;
chart.Aspect.View3D = false;
chart.Axes.Left.Automatic = false;
chart.Axes.Left.AutomaticMinimum = false;
chart.Axes.Left.AutomaticMaximum = false;
chart.Axes.Left.Minimum = 0;
chart.Axes.Left.Maximum = 1;
}

public void setupPolar(Polar series)
{
series.CircleLabels = true;
series.Circled = true;
series.AngleIncrement = 30; // 30 degrees increments
}

public void initChart4(TChart chart, Label label)
{
setupChart(chart);
label.Content = "BEFORE adding data:\nseries.ClockWiseLabels = true;";

Polar series = new Polar();
setupPolar(series);

series.RotationAngle = 90;
series.ClockWiseLabels = true;

series.Add(0, 1.0 / Math.Sqrt(2));
series.Add(45, 1);

chart.Series.Add(series);
}

public void initChart5(TChart chart, Label label)
{
setupChart(chart);
label.Content = "AFTER adding data:\nseries.ClockWiseLabels = true;";

Polar series = new Polar();
setupPolar(series);
series.RotationAngle = 90;

series.Add(0, 1.0 / Math.Sqrt(2));
series.Add(45, 1);

series.ClockWiseLabels = true;

chart.Series.Add(series);
}
}

Posted: Thu Mar 05, 2009 11:32 am
by narcis
Hi Christo,

No, the correct one is setting ClockWiseLabels after adding data because setting ClockWiseLabels to true modifies data accordingly:

Code: Select all

    public bool ClockWiseLabels
    {
      get { return clockWiseLabels; }
      set 
      {
        SetBooleanProperty(ref clockWiseLabels, value);
        ModifyData();
      }
    }

    private void ModifyData()
    {
      for (int i = 0; i < XValues.Count; i++)
      {
        XValues[i] = 360 - XValues[i];
      }
    }

Posted: Thu Mar 05, 2009 1:48 pm
by 13050248
If I've got code which does:

polar.ClockWiseLabels = true;
polar.ClockWiseLabels = true;
polar.ClockWiseLabels = true;
polar.ClockWiseLabels = true;
...

The data get transformed everytime! We are therefore never guaranteed that the state of the ClockWiseLabels is in anyway consistent with the data. The order sensitivity of calls will be a major issue for us in the future if we want to optimise for performance.

Could you add to your wish list that this could gets reworked/cleaned up/fixed?

Posted: Thu Mar 05, 2009 2:03 pm
by narcis
Hi Christo,

Yes, I agree this may need to be redesigned. I've added your request to the wish-list.