Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions src/DynamicDataDisplay.Markers/DevMarkerChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,22 @@ public override void OnPlotterAttached(Plotter plotter)
DrawAllMarkers(false);
}

#region DataSource

protected override void OnDataSourceChanged(PointDataSourceBase prevSource, PointDataSourceBase currSource)
{
base.OnDataSourceChanged(prevSource, currSource);

if (currSource != null)
{
MakeStandartPredictions(currSource);
DrawAllMarkers(true);
}
else
{
// todo clear
}

// this is for PieChart in legend.
RaiseDataSourceChanged(prevSource, currSource);
}

private void MakeStandartPredictions(PointDataSourceBase currSource)
#region DataSource

protected override void OnDataSourceChanged(PointDataSourceBase prevSource, PointDataSourceBase currSource)
{
// Clear any existing children before redrawing collection
CurrentItemsPanel?.Children.Clear();
if (currSource != null)
{
MakeStandartPredictions(currSource);
DrawAllMarkers(true);
}

base.OnDataSourceChanged(prevSource, currSource);
}

private void MakeStandartPredictions(PointDataSourceBase currSource)
{
Type dataType = currSource.GetDataType() as Type;
if (dataType != null)
Expand Down
5 changes: 4 additions & 1 deletion src/DynamicDataDisplay.Samples/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@
<m:Demonstration Description="Infinite Timeline Chart" Uri="/Demos/Custom/InfiniteTimelineChartTest.xaml"/>
<m:Demonstration Description="Mouse Navigation Switching" Uri="/Demos/Custom/MouseNaviationSwitchingSample.xaml"/>
<m:Demonstration Description="WMS Maps" Uri="/Demos/Custom/WmsMaps.xaml"/>
</m:ReleaseInfo>
</m:ReleaseInfo>
<m:ReleaseInfo Version="Developer Testing">
<m:Demonstration Description="Changing the ItemsSource" Uri="/Demos/UserTests/TestSwitchingMarkersDataSource.xaml"/>
</m:ReleaseInfo>
</m:SamplesCollection>

<local:VersionToBrushConverter x:Key="versionConverter"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Page x:Class="DynamicDataDisplay.Samples.Demos.UserTest.TestSwitchingMarkersDataSource"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"
xmlns:sys="clr-namespace:System.Windows;assembly=WindowsBase"
Title="Different built-in markers">
<Grid>
<d3:ChartPlotter Name="plotter">
<d3:DevMarkerChart Name="chart1" LegendDescription="Cross">
<d3:CrossMarker MarkerWidth="10" MarkerHeight="10" MarkerStroke="Blue"/>
</d3:DevMarkerChart>
<d3:DevMarkerChart Name="chart2" LegendDescription="Ellipse">
<d3:EllipseMarker MarkerStroke="Green" MarkerFill="{x:Null}"/>
</d3:DevMarkerChart>
<d3:DevMarkerChart Name="chart3" LegendDescription="Plus">
<d3:PlusMarker MarkerStroke="Red"/>
</d3:DevMarkerChart>
<d3:DevMarkerChart Name="chart4" LegendDescription="Down triangle">
<d3:DownTriangleMarker MarkerFill="Orange" MarkerStroke="{x:Null}"/>
</d3:DevMarkerChart>
<d3:DevMarkerChart Name="chart5" LegendDescription="Up triangle">
<d3:UpTriangleMarker MarkerFill="Olive" MarkerStroke="{x:Null}"/>
</d3:DevMarkerChart>
<d3:DevMarkerChart Name="chart6" LegendDescription="Diamond">
<d3:DiamondMarker MarkerFill="Violet" MarkerStroke="{x:Null}"/>
</d3:DevMarkerChart>
<d3:DevMarkerChart Name="chart7" LegendDescription="Rectangle">
<d3:RectangleMarker MarkerFill="Chartreuse" MarkerStroke="{x:Null}"/>
</d3:DevMarkerChart>
<d3:DevMarkerChart Name="chart8" LegendDescription="Numbers">
<d3:NewLegend.SampleData>
<sys:Point X="0" Y="0.71"/>
</d3:NewLegend.SampleData>

<d3:TemplateMarkerGenerator>
<DataTemplate>
<TextBlock Text="{Binding Y, StringFormat=F2}"/>
</DataTemplate>
</d3:TemplateMarkerGenerator>
</d3:DevMarkerChart>
</d3:ChartPlotter>
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
using DynamicDataDisplay.Charts.Markers;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;

namespace DynamicDataDisplay.Samples.Demos.UserTest
{
/// <summary>
/// Interaction logic for DifferentBuildInMarkersPage.xaml
/// </summary>
public partial class TestSwitchingMarkersDataSource : Page
{
/// <summary>
/// Maximum number of markers to display in a line
/// </summary>
private const int _maxCount = 50;
/// <summary>
/// Minimum number of markers to display in a line
/// </summary>
private const int _minCount = 2;
/// <summary>
/// Current number of markers to display in a line
/// </summary>
private int _count = 1;
/// <summary>
/// Used to increase or decrease the number of markers
/// </summary>
private int _countDirection = 1;
/// <summary>
/// Time we started in CPU ticks, used for getting a relative time
/// </summary>
private int _startTime;
/// <summary>
/// Timer used to update the markers
/// </summary>
private DispatcherTimer _timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(10) };
/// <summary>
/// A list of chart controls that we are updating
/// </summary>
private List<DevMarkerChart> _charts = new List<DevMarkerChart>();

public TestSwitchingMarkersDataSource()
{
InitializeComponent();
Loaded += OnLoaded;
Unloaded += OnUnloaded;
}

/// <summary>
/// Called when the control is loaded
/// </summary>
private void OnLoaded(object sender, RoutedEventArgs e)
{
_startTime = Environment.TickCount;
_charts.AddMany([
chart1,
chart2,
chart3,
chart4,
chart5,
chart6,
chart7,
chart8]);

_timer.Tick += Timer_Tick;
_timer.Start();
}

private void OnUnloaded(object sender, RoutedEventArgs e)
{
_timer.Tick -= Timer_Tick;
_timer.Stop();
}

/// <summary>
/// Periodic chart updater
/// </summary>
private void Timer_Tick(object sender, EventArgs e)
{
if (_count >= _maxCount)
{
_countDirection = -1;
}
else if (_count <= _minCount)
{
_countDirection = 1;
}
_count += _countDirection;

for (int i = 0; i < _charts.Count; i++)
{
_charts[i].ItemsSource = CreateCollection(i+1);
}
}

/// <summary>
/// Creates an immutable collection of points from the current time, and data source number
/// </summary>
private ImmutableList<Point> CreateCollection(int dataSourceNumber)
{
int time = Environment.TickCount;

var points = new Point[_count];

for (int i = 0; i < _count; i++)
{
double x = i / (double)_count;
points[i] = new Point(x, 0.1 * dataSourceNumber + 0.06 * Math.Sin(10 * x + Math.Sqrt(dataSourceNumber + 1) * 0.0005 * (time - _startTime)));
}

return ImmutableList.Create(points);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<EmbeddedResource Include="Demos\v03\Repressilator.txt" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="6.0.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
Expand Down
Loading