Skip to content

Commit ec1b049

Browse files
committed
InteractiveDataDisplay quickstart
1 parent c392907 commit ec1b049

File tree

13 files changed

+666
-0
lines changed

13 files changed

+666
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="IDDQuickstart452.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:IDDQuickstart452"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace IDDQuickstart452
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{AED92CDC-8131-4DD4-ADAD-048CB2E62865}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>IDDQuickstart452</RootNamespace>
10+
<AssemblyName>IDDQuickstart452</AssemblyName>
11+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<WarningLevel>4</WarningLevel>
15+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
16+
<Deterministic>true</Deterministic>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<PlatformTarget>AnyCPU</PlatformTarget>
20+
<DebugSymbols>true</DebugSymbols>
21+
<DebugType>full</DebugType>
22+
<Optimize>false</Optimize>
23+
<OutputPath>bin\Debug\</OutputPath>
24+
<DefineConstants>DEBUG;TRACE</DefineConstants>
25+
<ErrorReport>prompt</ErrorReport>
26+
<WarningLevel>4</WarningLevel>
27+
</PropertyGroup>
28+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
29+
<PlatformTarget>AnyCPU</PlatformTarget>
30+
<DebugType>pdbonly</DebugType>
31+
<Optimize>true</Optimize>
32+
<OutputPath>bin\Release\</OutputPath>
33+
<DefineConstants>TRACE</DefineConstants>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
</PropertyGroup>
37+
<ItemGroup>
38+
<Reference Include="InteractiveDataDisplay.WPF, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
39+
<HintPath>..\IDDQuickstart\packages\InteractiveDataDisplay.WPF.1.0.0\lib\net452\InteractiveDataDisplay.WPF.dll</HintPath>
40+
</Reference>
41+
<Reference Include="Microsoft.Maps.MapControl.WPF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
42+
<HintPath>..\IDDQuickstart\packages\Microsoft.Maps.MapControl.WPF.1.0.0.3\lib\net40-Client\Microsoft.Maps.MapControl.WPF.dll</HintPath>
43+
</Reference>
44+
<Reference Include="System" />
45+
<Reference Include="System.Data" />
46+
<Reference Include="System.Reactive.Core, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
47+
<HintPath>..\IDDQuickstart\packages\System.Reactive.Core.3.1.1\lib\net45\System.Reactive.Core.dll</HintPath>
48+
</Reference>
49+
<Reference Include="System.Reactive.Interfaces, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
50+
<HintPath>..\IDDQuickstart\packages\System.Reactive.Interfaces.3.1.1\lib\net45\System.Reactive.Interfaces.dll</HintPath>
51+
</Reference>
52+
<Reference Include="System.Reactive.Linq, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
53+
<HintPath>..\IDDQuickstart\packages\System.Reactive.Linq.3.1.1\lib\net45\System.Reactive.Linq.dll</HintPath>
54+
</Reference>
55+
<Reference Include="System.Reactive.PlatformServices, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
56+
<HintPath>..\IDDQuickstart\packages\System.Reactive.PlatformServices.3.1.1\lib\net45\System.Reactive.PlatformServices.dll</HintPath>
57+
</Reference>
58+
<Reference Include="System.Reactive.Windows.Threading, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
59+
<HintPath>..\IDDQuickstart\packages\System.Reactive.Windows.Threading.3.1.1\lib\net45\System.Reactive.Windows.Threading.dll</HintPath>
60+
</Reference>
61+
<Reference Include="System.Windows" />
62+
<Reference Include="System.Xml" />
63+
<Reference Include="Microsoft.CSharp" />
64+
<Reference Include="System.Core" />
65+
<Reference Include="System.Xml.Linq" />
66+
<Reference Include="System.Data.DataSetExtensions" />
67+
<Reference Include="System.Net.Http" />
68+
<Reference Include="System.Xaml">
69+
<RequiredTargetFramework>4.0</RequiredTargetFramework>
70+
</Reference>
71+
<Reference Include="WindowsBase" />
72+
<Reference Include="PresentationCore" />
73+
<Reference Include="PresentationFramework" />
74+
</ItemGroup>
75+
<ItemGroup>
76+
<ApplicationDefinition Include="App.xaml">
77+
<Generator>MSBuild:Compile</Generator>
78+
<SubType>Designer</SubType>
79+
</ApplicationDefinition>
80+
<Page Include="MainWindow.xaml">
81+
<Generator>MSBuild:Compile</Generator>
82+
<SubType>Designer</SubType>
83+
</Page>
84+
<Compile Include="App.xaml.cs">
85+
<DependentUpon>App.xaml</DependentUpon>
86+
<SubType>Code</SubType>
87+
</Compile>
88+
<Compile Include="MainWindow.xaml.cs">
89+
<DependentUpon>MainWindow.xaml</DependentUpon>
90+
<SubType>Code</SubType>
91+
</Compile>
92+
</ItemGroup>
93+
<ItemGroup>
94+
<Compile Include="Properties\AssemblyInfo.cs">
95+
<SubType>Code</SubType>
96+
</Compile>
97+
<Compile Include="Properties\Resources.Designer.cs">
98+
<AutoGen>True</AutoGen>
99+
<DesignTime>True</DesignTime>
100+
<DependentUpon>Resources.resx</DependentUpon>
101+
</Compile>
102+
<Compile Include="Properties\Settings.Designer.cs">
103+
<AutoGen>True</AutoGen>
104+
<DependentUpon>Settings.settings</DependentUpon>
105+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
106+
</Compile>
107+
<EmbeddedResource Include="Properties\Resources.resx">
108+
<Generator>ResXFileCodeGenerator</Generator>
109+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
110+
</EmbeddedResource>
111+
<None Include="packages.config" />
112+
<None Include="Properties\Settings.settings">
113+
<Generator>SettingsSingleFileGenerator</Generator>
114+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
115+
</None>
116+
</ItemGroup>
117+
<ItemGroup>
118+
<None Include="App.config" />
119+
</ItemGroup>
120+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
121+
</Project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Window x:Class="IDDQuickstart452.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:IDDQuickstart452" xmlns:d3="clr-namespace:InteractiveDataDisplay.WPF;assembly=InteractiveDataDisplay.WPF"
7+
mc:Ignorable="d"
8+
Title="Interactive Data Display Quickstart" Height="450" Width="800">
9+
<DockPanel>
10+
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="5">
11+
<Button Content="Bar Graph" Margin ="0 0 5 0" Click="PlotBar"/>
12+
<Button Content="Scatter Plot" Margin ="0 0 5 0" Click="PlotScatter"/>
13+
<Button Content="Line Plot" Margin ="0 0 5 0" Click="PlotLines"/>
14+
</StackPanel>
15+
<d3:Chart Name="myChart">
16+
<Grid Name="myGrid"/>
17+
</d3:Chart>
18+
</DockPanel>
19+
</Window>
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace IDDQuickstart452
17+
{
18+
/// <summary>
19+
/// Interaction logic for MainWindow.xaml
20+
/// </summary>
21+
public partial class MainWindow : Window
22+
{
23+
public MainWindow()
24+
{
25+
InitializeComponent();
26+
PlotLines(null, null);
27+
}
28+
29+
private Random rand = new Random(0);
30+
private double[] RandomWalk(int points = 5, double start = 100, double mult = 50)
31+
{
32+
// return an array of difting random numbers
33+
double[] values = new double[points];
34+
values[0] = start;
35+
for (int i = 1; i < points; i++)
36+
values[i] = values[i - 1] + (rand.NextDouble() - .5) * mult;
37+
return values;
38+
}
39+
40+
private double[] Consecutive(int points, double offset = 0, double stepSize = 1)
41+
{
42+
// return an array of ascending numbers starting at 1
43+
double[] values = new double[points];
44+
for (int i = 0; i < points; i++)
45+
values[i] = i * stepSize + 1 + offset;
46+
return values;
47+
}
48+
49+
private void PlotBar(object sender, RoutedEventArgs e)
50+
{
51+
// generate some random Y data
52+
int pointCount = 5;
53+
double[] xs1 = Consecutive(pointCount, offset: 0);
54+
double[] xs2 = Consecutive(pointCount, offset: .4);
55+
double[] ys1 = RandomWalk(pointCount);
56+
double[] ys2 = RandomWalk(pointCount);
57+
58+
// create the series and describe their styling
59+
var bar1 = new InteractiveDataDisplay.WPF.BarGraph()
60+
{
61+
Color = Brushes.Blue,
62+
Description = "Group A",
63+
BarsWidth = .35,
64+
};
65+
66+
var bar2 = new InteractiveDataDisplay.WPF.BarGraph()
67+
{
68+
Color = Brushes.Red,
69+
Description = "Group B",
70+
BarsWidth = .35,
71+
};
72+
73+
// load data into each series
74+
bar1.PlotBars(xs1, ys1);
75+
bar2.PlotBars(xs2, ys2);
76+
77+
// add the series to the grid
78+
myGrid.Children.Clear();
79+
myGrid.Children.Add(bar1);
80+
myGrid.Children.Add(bar2);
81+
82+
// customize styling
83+
myChart.Title = $"Bar Graph";
84+
myChart.BottomTitle = $"Horizontal Axis Label";
85+
myChart.LeftTitle = $"Vertical Axis Label";
86+
myChart.IsAutoFitEnabled = false;
87+
myChart.LegendVisibility = Visibility.Visible;
88+
89+
// set axis limits manually
90+
myChart.PlotOriginX = .5;
91+
myChart.PlotWidth = 5.5;
92+
myChart.PlotOriginY = 0;
93+
myChart.PlotHeight = 200;
94+
}
95+
96+
private void PlotScatter(object sender, RoutedEventArgs e)
97+
{
98+
// generate some random X and Y data
99+
int pointCount = 500;
100+
double[] xs1 = RandomWalk(pointCount);
101+
double[] ys1 = RandomWalk(pointCount);
102+
double[] xs2 = RandomWalk(pointCount);
103+
double[] ys2 = RandomWalk(pointCount);
104+
double[] sizes = Consecutive(pointCount, 10, 0);
105+
106+
// create the lines and describe their styling
107+
var line1 = new InteractiveDataDisplay.WPF.CircleMarkerGraph()
108+
{
109+
Color = new SolidColorBrush(Colors.Blue),
110+
Description = "Group A",
111+
StrokeThickness = 1
112+
};
113+
114+
var line2 = new InteractiveDataDisplay.WPF.CircleMarkerGraph()
115+
{
116+
Color = new SolidColorBrush(Colors.Red),
117+
Description = "Group B",
118+
StrokeThickness = 1
119+
};
120+
121+
// load data into the lines
122+
line1.PlotSize(xs1, ys1, sizes);
123+
line2.PlotSize(xs2, ys2, sizes);
124+
125+
// add lines into the grid
126+
myGrid.Children.Clear();
127+
myGrid.Children.Add(line1);
128+
myGrid.Children.Add(line2);
129+
130+
// customize styling
131+
myChart.Title = $"Line Plot ({pointCount:n0} points each)";
132+
myChart.BottomTitle = $"Horizontal Axis Label";
133+
myChart.LeftTitle = $"Vertical Axis Label";
134+
myChart.IsAutoFitEnabled = true;
135+
myChart.LegendVisibility = Visibility.Hidden;
136+
}
137+
138+
private void PlotLines(object sender, RoutedEventArgs e)
139+
{
140+
int pointCount = 10_000;
141+
double[] xs = Consecutive(pointCount);
142+
double[] ys1 = RandomWalk(pointCount);
143+
double[] ys2 = RandomWalk(pointCount);
144+
145+
// create the lines and describe their styling
146+
var line1 = new InteractiveDataDisplay.WPF.LineGraph
147+
{
148+
Stroke = new SolidColorBrush(Colors.Blue),
149+
Description = "Line A",
150+
StrokeThickness = 2
151+
};
152+
153+
var line2 = new InteractiveDataDisplay.WPF.LineGraph
154+
{
155+
Stroke = new SolidColorBrush(Colors.Red),
156+
Description = "Line B",
157+
StrokeThickness = 2
158+
};
159+
160+
// load data into the lines
161+
line1.Plot(xs, ys1);
162+
line2.Plot(xs, ys2);
163+
164+
// add lines into the grid
165+
myGrid.Children.Clear();
166+
myGrid.Children.Add(line1);
167+
myGrid.Children.Add(line2);
168+
169+
// customize styling
170+
myChart.Title = $"Line Plot ({pointCount:n0} points each)";
171+
myChart.BottomTitle = $"Horizontal Axis Label";
172+
myChart.LeftTitle = $"Vertical Axis Label";
173+
myChart.IsAutoFitEnabled = true;
174+
myChart.LegendVisibility = Visibility.Visible;
175+
}
176+
177+
}
178+
}

0 commit comments

Comments
 (0)