Skip to content

Commit f20e5f6

Browse files
Added application for json to chart
1 parent 17baaac commit f20e5f6

18 files changed

+982
-0
lines changed

JsonToChart/App.config

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
5+
</startup>
6+
<runtime>
7+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
8+
<dependentAssembly>
9+
<assemblyIdentity name="Syncfusion.Licensing" publicKeyToken="632609b4d040f6b4" culture="neutral" />
10+
<bindingRedirect oldVersion="0.0.0.0-20.1460.0.58" newVersion="20.1460.0.58" />
11+
</dependentAssembly>
12+
<dependentAssembly>
13+
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
14+
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
15+
</dependentAssembly>
16+
</assemblyBinding>
17+
</runtime>
18+
</configuration>

JsonToChart/App.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="ChartSample.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:ChartSample"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>

JsonToChart/App.xaml.cs

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 ChartSample
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}

JsonToChart/ChartSample.csproj

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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>{54289026-BD00-484B-8F0A-DF9DCC9B2B07}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>ChartSample</RootNamespace>
10+
<AssemblyName>ChartSample</AssemblyName>
11+
<TargetFrameworkVersion>v4.8</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+
<TargetFrameworkProfile />
18+
</PropertyGroup>
19+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
20+
<PlatformTarget>AnyCPU</PlatformTarget>
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>full</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Debug\</OutputPath>
25+
<DefineConstants>DEBUG;TRACE</DefineConstants>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<PlatformTarget>AnyCPU</PlatformTarget>
31+
<DebugType>pdbonly</DebugType>
32+
<Optimize>true</Optimize>
33+
<OutputPath>bin\Release\</OutputPath>
34+
<DefineConstants>TRACE</DefineConstants>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
</PropertyGroup>
38+
<ItemGroup>
39+
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
40+
<HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
41+
</Reference>
42+
<Reference Include="Syncfusion.Licensing, Version=20.1460.0.58, Culture=neutral, PublicKeyToken=632609b4d040f6b4, processorArchitecture=MSIL">
43+
<HintPath>packages\Syncfusion.Licensing.20.1.0.58\lib\net46\Syncfusion.Licensing.dll</HintPath>
44+
</Reference>
45+
<Reference Include="Syncfusion.SfChart.WPF, Version=20.1460.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
46+
<HintPath>packages\Syncfusion.SfChart.WPF.20.1.0.58\lib\net46\Syncfusion.SfChart.WPF.dll</HintPath>
47+
</Reference>
48+
<Reference Include="System" />
49+
<Reference Include="System.Data" />
50+
<Reference Include="System.Xml" />
51+
<Reference Include="Microsoft.CSharp" />
52+
<Reference Include="System.Core" />
53+
<Reference Include="System.Xml.Linq" />
54+
<Reference Include="System.Data.DataSetExtensions" />
55+
<Reference Include="System.Net.Http" />
56+
<Reference Include="System.Xaml">
57+
<RequiredTargetFramework>4.0</RequiredTargetFramework>
58+
</Reference>
59+
<Reference Include="WindowsBase" />
60+
<Reference Include="PresentationCore" />
61+
<Reference Include="PresentationFramework" />
62+
</ItemGroup>
63+
<ItemGroup>
64+
<ApplicationDefinition Include="App.xaml">
65+
<Generator>MSBuild:Compile</Generator>
66+
<SubType>Designer</SubType>
67+
</ApplicationDefinition>
68+
<Compile Include="ViewModel\ViewModel.cs" />
69+
<Page Include="MainWindow.xaml">
70+
<Generator>MSBuild:Compile</Generator>
71+
<SubType>Designer</SubType>
72+
</Page>
73+
<Compile Include="App.xaml.cs">
74+
<DependentUpon>App.xaml</DependentUpon>
75+
<SubType>Code</SubType>
76+
</Compile>
77+
<Compile Include="MainWindow.xaml.cs">
78+
<DependentUpon>MainWindow.xaml</DependentUpon>
79+
<SubType>Code</SubType>
80+
</Compile>
81+
</ItemGroup>
82+
<ItemGroup>
83+
<Compile Include="Properties\AssemblyInfo.cs">
84+
<SubType>Code</SubType>
85+
</Compile>
86+
<Compile Include="Properties\Resources.Designer.cs">
87+
<AutoGen>True</AutoGen>
88+
<DesignTime>True</DesignTime>
89+
<DependentUpon>Resources.resx</DependentUpon>
90+
</Compile>
91+
<Compile Include="Properties\Settings.Designer.cs">
92+
<AutoGen>True</AutoGen>
93+
<DependentUpon>Settings.settings</DependentUpon>
94+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
95+
</Compile>
96+
<EmbeddedResource Include="Properties\Resources.resx">
97+
<Generator>ResXFileCodeGenerator</Generator>
98+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
99+
</EmbeddedResource>
100+
<None Include="packages.config" />
101+
<None Include="Properties\Settings.settings">
102+
<Generator>SettingsSingleFileGenerator</Generator>
103+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
104+
</None>
105+
</ItemGroup>
106+
<ItemGroup>
107+
<None Include="App.config" />
108+
</ItemGroup>
109+
<ItemGroup />
110+
<ItemGroup>
111+
<Resource Include="ImageIcons\bar_icon.png" />
112+
<Resource Include="ImageIcons\line_icon.png" />
113+
<Resource Include="ImageIcons\pie_icon.png" />
114+
<Resource Include="ImageIcons\scatter_icon.png" />
115+
</ItemGroup>
116+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
117+
</Project>

JsonToChart/ChartSample.sln

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31825.309
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChartSample", "ChartSample.csproj", "{54289026-BD00-484B-8F0A-DF9DCC9B2B07}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
Release-Xml|Any CPU = Release-Xml|Any CPU
13+
EndGlobalSection
14+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
15+
{54289026-BD00-484B-8F0A-DF9DCC9B2B07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
16+
{54289026-BD00-484B-8F0A-DF9DCC9B2B07}.Debug|Any CPU.Build.0 = Debug|Any CPU
17+
{54289026-BD00-484B-8F0A-DF9DCC9B2B07}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{54289026-BD00-484B-8F0A-DF9DCC9B2B07}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{54289026-BD00-484B-8F0A-DF9DCC9B2B07}.Release-Xml|Any CPU.ActiveCfg = Release|Any CPU
20+
{54289026-BD00-484B-8F0A-DF9DCC9B2B07}.Release-Xml|Any CPU.Build.0 = Release|Any CPU
21+
EndGlobalSection
22+
GlobalSection(SolutionProperties) = preSolution
23+
HideSolutionNode = FALSE
24+
EndGlobalSection
25+
GlobalSection(ExtensibilityGlobals) = postSolution
26+
SolutionGuid = {25D56EEE-43CE-4EAF-BF02-F1B306B38511}
27+
EndGlobalSection
28+
EndGlobal

JsonToChart/ImageIcons/bar_icon.png

44 KB
Loading

JsonToChart/ImageIcons/line_icon.png

43.5 KB
Loading

JsonToChart/ImageIcons/pie_icon.png

39.3 KB
Loading
39 KB
Loading

JsonToChart/MainWindow.xaml

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
<Window x:Class="ChartSample.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:ChartSample"
7+
xmlns:chart="http://schemas.syncfusion.com/wpf"
8+
xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
9+
mc:Ignorable="d"
10+
Title="MainWindow" Height="600" Width="800">
11+
<Window.Resources>
12+
13+
<chart:ChartColorModel x:Key="CustomColor">
14+
<chart:ChartColorModel.CustomBrushes>
15+
<SolidColorBrush Color="#0078DE" />
16+
<SolidColorBrush Color="#00CC6A" />
17+
<SolidColorBrush Color="#B146C2" />
18+
<SolidColorBrush Color="#FFB900" />
19+
<SolidColorBrush Color="#7A7574" />
20+
<SolidColorBrush Color="#7200E6" />
21+
<SolidColorBrush Color="#007F00" />
22+
<SolidColorBrush Color="#FA9901" />
23+
</chart:ChartColorModel.CustomBrushes>
24+
</chart:ChartColorModel>
25+
</Window.Resources>
26+
27+
<Window.DataContext>
28+
<local:ViewModel x:Name="viewModel"/>
29+
</Window.DataContext>
30+
31+
<Grid Margin="10">
32+
<Grid.RowDefinitions>
33+
<RowDefinition Height="Auto"/>
34+
<RowDefinition Height="Auto"/>
35+
<RowDefinition />
36+
</Grid.RowDefinitions>
37+
<Border Grid.Row="0" >
38+
<TextBlock Text="Create beautiful charts using JSON data in WPF" Margin="10" TextAlignment="Center" FontSize="20" />
39+
</Border>
40+
<Border Grid.Row="1">
41+
42+
<Border Margin="2" CornerRadius="20" BorderBrush="Gray" BorderThickness="1" Grid.Column="0">
43+
<StackPanel Orientation="Vertical">
44+
<Grid>
45+
<TextBox x:Name="JsonBox" Margin="10" Height="150" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" TextAlignment="Left" MaxLength="50000" IsReadOnly="False" AcceptsReturn="True" />
46+
<TextBlock IsHitTestVisible="False" FontSize="16" Margin="10" Height="150" Text="To start, paste your JSON data or web service link. As you make text changes, the data will be processed and verified." TextWrapping="Wrap" TextAlignment="Left" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="Gray">
47+
<TextBlock.Style>
48+
<Style TargetType="{x:Type TextBlock}">
49+
<Setter Property="Visibility" Value="Collapsed"/>
50+
<Style.Triggers>
51+
<DataTrigger Binding="{Binding Text, ElementName=JsonBox}" Value="">
52+
<Setter Property="Visibility" Value="Visible"/>
53+
</DataTrigger>
54+
</Style.Triggers>
55+
</Style>
56+
</TextBlock.Style>
57+
</TextBlock>
58+
</Grid>
59+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
60+
<Button Margin="5" Background="LightBlue" Click="LoadJson" Width="150" HorizontalContentAlignment="Center" HorizontalAlignment="Center" Content="Load Example Data" />
61+
<Button Margin="5" Background="LightBlue" Content="Generate Chart" HorizontalContentAlignment="Center" Width="150" Click="PrepareChart">
62+
</Button>
63+
</StackPanel>
64+
</StackPanel>
65+
</Border>
66+
</Border>
67+
<Grid Grid.Row="2">
68+
<Grid.ColumnDefinitions>
69+
<ColumnDefinition Width="*"/>
70+
<ColumnDefinition Width="250"/>
71+
</Grid.ColumnDefinitions>
72+
<Border Margin="2" CornerRadius="20" BorderBrush="Gray" BorderThickness="1" Grid.Column="0">
73+
<TabControl Margin="10" Name="tab" >
74+
<TabItem>
75+
<TabItem.Header>
76+
<StackPanel Orientation="Horizontal" Margin="2">
77+
<Image Source="/ChartSample;component/ImageIcons/bar_icon.png" Width="10" Height="10" Margin="2"/>
78+
<TextBlock Text="Column"/>
79+
</StackPanel>
80+
</TabItem.Header>
81+
<chart:SfChart Background="White">
82+
<chart:SfChart.PrimaryAxis>
83+
<chart:CategoryAxis LabelPlacement="BetweenTicks" ShowGridLines="False" />
84+
</chart:SfChart.PrimaryAxis>
85+
86+
<chart:SfChart.SecondaryAxis>
87+
<chart:NumericalAxis/>
88+
</chart:SfChart.SecondaryAxis>
89+
90+
<chart:FastColumnBitmapSeries ItemsSource="{Binding Data}" XBindingPath="{Binding XBindingPath}" YBindingPath="{Binding YBindingPath}" ColorModel="{StaticResource CustomColor}" Palette="Custom"/>
91+
</chart:SfChart>
92+
</TabItem>
93+
<TabItem>
94+
<TabItem.Header>
95+
<StackPanel Orientation="Horizontal" Margin="2">
96+
<Image Source="/ChartSample;component/ImageIcons/line_icon.png" Width="10" Height="10" Margin="2"/>
97+
<TextBlock Text="Line"/>
98+
</StackPanel>
99+
</TabItem.Header>
100+
<chart:SfChart Background="White" ColorModel="{StaticResource CustomColor}" Palette="Custom">
101+
<chart:SfChart.PrimaryAxis>
102+
<chart:CategoryAxis LabelPlacement="BetweenTicks" ShowGridLines="False"/>
103+
</chart:SfChart.PrimaryAxis>
104+
105+
<chart:SfChart.SecondaryAxis>
106+
<chart:NumericalAxis />
107+
</chart:SfChart.SecondaryAxis>
108+
109+
<chart:FastLineSeries ItemsSource="{Binding Data}" XBindingPath="{Binding XBindingPath}" YBindingPath="{Binding YBindingPath}" />
110+
</chart:SfChart>
111+
</TabItem>
112+
<TabItem>
113+
<TabItem.Header>
114+
<StackPanel Orientation="Horizontal" Margin="2">
115+
<Image Source="/ChartSample;component/ImageIcons/bar_icon.png" Width="10" Height="10" Margin="2"/>
116+
<TextBlock Text="Bar"/>
117+
</StackPanel>
118+
</TabItem.Header>
119+
<chart:SfChart Background="White">
120+
<chart:SfChart.PrimaryAxis>
121+
<chart:CategoryAxis LabelPlacement="BetweenTicks" ShowGridLines="False"/>
122+
</chart:SfChart.PrimaryAxis>
123+
124+
<chart:SfChart.SecondaryAxis>
125+
<chart:NumericalAxis />
126+
</chart:SfChart.SecondaryAxis>
127+
<chart:FastBarBitmapSeries ItemsSource="{Binding Data}" XBindingPath="{Binding XBindingPath}" YBindingPath="{Binding YBindingPath}" ColorModel="{StaticResource CustomColor}" Palette="Custom"/>
128+
</chart:SfChart>
129+
</TabItem>
130+
<TabItem>
131+
<TabItem.Header>
132+
<StackPanel Orientation="Horizontal" Margin="2">
133+
<Image Source="/ChartSample;component/ImageIcons/scatter_icon.png" Width="10" Height="10" Margin="2"/>
134+
<TextBlock Text="Scatter"/>
135+
</StackPanel>
136+
</TabItem.Header>
137+
<chart:SfChart Background="White">
138+
<chart:SfChart.PrimaryAxis>
139+
<chart:CategoryAxis LabelPlacement="BetweenTicks" ShowGridLines="False"/>
140+
</chart:SfChart.PrimaryAxis>
141+
142+
<chart:SfChart.SecondaryAxis>
143+
<chart:NumericalAxis />
144+
</chart:SfChart.SecondaryAxis>
145+
146+
<chart:ScatterSeries ItemsSource="{Binding Data}" XBindingPath="{Binding XBindingPath}" YBindingPath="{Binding YBindingPath}" ColorModel="{StaticResource CustomColor}" Palette="Custom" >
147+
148+
</chart:ScatterSeries>
149+
</chart:SfChart>
150+
</TabItem>
151+
<TabItem>
152+
<TabItem.Header>
153+
<StackPanel Orientation="Horizontal" Margin="2">
154+
<Image Source="/ChartSample;component/ImageIcons/pie_icon.png" Width="10" Height="10" Margin="2"/>
155+
<TextBlock Text="Pie"/>
156+
</StackPanel>
157+
</TabItem.Header>
158+
<chart:SfChart >
159+
160+
<chart:PieSeries ItemsSource="{Binding Data}" XBindingPath="{Binding XBindingPath}" YBindingPath="{Binding YBindingPath}" ColorModel="{StaticResource CustomColor}" Palette="Custom" />
161+
</chart:SfChart>
162+
</TabItem>
163+
</TabControl>
164+
</Border>
165+
<Border Margin="2" CornerRadius="20" BorderBrush="Gray" BorderThickness="1" Grid.Column="1">
166+
<StackPanel Margin="2" Orientation="Vertical">
167+
<TextBlock HorizontalAlignment="Center" Text="Data" FontSize="20" Margin="5"/>
168+
<TextBlock Text="Select X Value" FontSize="12" Margin="5"/>
169+
<ComboBox Text="XBindingPath" Margin="5" ItemsSource="{Binding XColumns}" SelectedIndex="0" SelectedItem="{Binding XBindingPath,Mode=TwoWay}" />
170+
<TextBlock Text="Select Y Value" FontSize="12" Margin="5"/>
171+
<ComboBox Text="XBindingPath" Margin="5" ItemsSource="{Binding YColumns}" SelectedIndex="0" SelectedItem="{Binding YBindingPath,Mode=TwoWay}" />
172+
<Button Margin="5,30,5,5" HorizontalContentAlignment="Center" Width="200" Background="LightBlue" Content="Download Image" Click="Button_Click"/>
173+
</StackPanel>
174+
</Border>
175+
176+
</Grid>
177+
</Grid>
178+
</Window>

0 commit comments

Comments
 (0)