Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Commit

Permalink
Change example to ColorGrid binding.
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-steema committed Apr 27, 2021
1 parent 9916dcb commit 1023944
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 46 deletions.
5 changes: 4 additions & 1 deletion TeeChart.Xaml.WPF Demo/Demos/BindingDataProperties.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
<teechart:TChart.Legend>
<teechart:Legend Visible="False" />
</teechart:TChart.Legend>
<series:Bar ItemsSource="{Binding Data}" />
<teechart:TChart.BottomAxis>
<teechart:Axis Visible="True" Increment="0.5"/>
</teechart:TChart.BottomAxis>
<series:ColorGrid ItemsSource="{Binding Data}" UseColorRange="False" UsePalette="True"/>
</teechart:TChart>

<!-- TODO: Set min / max to axis -->
Expand Down
86 changes: 46 additions & 40 deletions TeeChart.Xaml.WPF Demo/Demos/BindingDataPropertiesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,51 @@

namespace XamlWPFDemo.Demos
{
public class BindingDataPropertiesViewModel : ViewModelBase
{
private const int Height = 20;
private const int Amount = 20;

private double _offset;

private readonly DispatcherTimer _timer;

public SeriesData[] Data { get; }

public BindingDataPropertiesViewModel()
public class BindingDataPropertiesViewModel : ViewModelBase
{
Data = new SeriesData[Amount];
for (var i = 0; i < Amount; i++)
{
Data[i] = new SeriesData {Y = Math.Sin(i / (double)Amount * Math.PI * 2) * Height};
}

_timer = new DispatcherTimer(DispatcherPriority.Normal) {Interval = TimeSpan.FromSeconds(0.05)};
_timer.Tick += OnTick;
_timer.Start();
}

private void OnTick(object sender, EventArgs eventArgs)
{
_offset += 0.5;
for (var i = 0; i < Amount; i++)
{
Data[i].Y = Math.Sin((i + _offset) / Amount * Math.PI * 2) * Height;
}
}

public override void Cleanup()
{
base.Cleanup();

_timer.Stop();
_timer.Tick -= OnTick;
private const int Height = 20;
private const int Amount = 100;

private double _offset;

private readonly DispatcherTimer _timer;

public Series3DData[] Data { get; }

public BindingDataPropertiesViewModel()
{
Data = new Series3DData[Amount];

int i = 0;
for (int x = 0; x < 10; x++)
{
for (int z = 0; z < 10; z++)
{
Data[i] = new Series3DData { X = x, Y = Math.Sin(i / (double)Amount * Math.PI * 2) * Height, Z = z };
i++;
}
}

_timer = new DispatcherTimer(DispatcherPriority.Normal) { Interval = TimeSpan.FromSeconds(0.05) };
_timer.Tick += OnTick;
_timer.Start();
}

private void OnTick(object sender, EventArgs eventArgs)
{
_offset += 2;
for (var i = 0; i < Amount; i++)
{
Data[i].Y = Math.Sin((i + _offset) / Amount * Math.PI * 2) * Height;
}
}

public override void Cleanup()
{
base.Cleanup();

_timer.Stop();
_timer.Tick -= OnTick;
}
}
}
}
}
7 changes: 2 additions & 5 deletions TeeChart.Xaml.WPF Demo/XamlWPFDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,15 @@
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="TeeChart, Version=4.2021.4.21, Culture=neutral, PublicKeyToken=9c8126276c77bdb7, processorArchitecture=MSIL">
<HintPath>..\packages\Steema.TeeChart.NET.4.2021.4.21\lib\net40\TeeChart.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="TeeChart.WPF, Version=4.2021.4.21, Culture=neutral, PublicKeyToken=98e8c3f289a4e286, processorArchitecture=MSIL">
<HintPath>..\packages\Steema.TeeChart.NET.4.2021.4.21\lib\net40\TeeChart.WPF.dll</HintPath>
</Reference>
<Reference Include="TeeChart.Xaml.WPF, Version=4.2021.4.21, Culture=neutral, PublicKeyToken=9406d226170aa089, processorArchitecture=MSIL">
<HintPath>..\packages\Steema.TeeChart.NET.4.2021.4.21\lib\net40\TeeChart.Xaml.WPF.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
Expand Down

0 comments on commit 1023944

Please sign in to comment.