Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-6015 LiveCharts2 migration for net6 #14209

Merged
merged 23 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
39c0c24
Add LCv2 support
zeusongit Jul 28, 2023
00229e3
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into lc2-mig
zeusongit Jul 28, 2023
827babf
comments
zeusongit Aug 1, 2023
dad9773
Update LiveChartsStyle.xaml
zeusongit Aug 1, 2023
2c063b8
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into lc2-mig
zeusongit Aug 2, 2023
6361735
fix
zeusongit Aug 2, 2023
b902f3c
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into lc2-mig
zeusongit Aug 8, 2023
06355fd
Update DynamoCoreWpf.csproj
zeusongit Aug 8, 2023
071f6b0
Revert "Update DynamoCoreWpf.csproj"
zeusongit Aug 8, 2023
e23d790
Update DynamoCoreWpf.csproj
zeusongit Aug 8, 2023
efebe65
remove net48
zeusongit Aug 8, 2023
a255b19
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into lc2-mig
zeusongit Aug 8, 2023
f96ba19
cleanup
zeusongit Aug 8, 2023
dea1456
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into lc2-mig
zeusongit Aug 8, 2023
e7066d7
Update DynamoCoreWpfTests.csproj
zeusongit Aug 8, 2023
3cf2673
removing test deps-
zeusongit Aug 9, 2023
7b20c59
Merge branch 'master' into pr/14209
pinzart Aug 10, 2023
582c5d8
Update CoreNodeModelsWpf.csproj
pinzart Aug 10, 2023
6d56a26
Revert "Update CoreNodeModelsWpf.csproj"
pinzart Aug 10, 2023
8645fd1
remove try catch
zeusongit Aug 10, 2023
6009de0
Update Export.cs
zeusongit Aug 11, 2023
686e149
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into lc2-mig
zeusongit Aug 11, 2023
c55a216
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into lc2-mig
zeusongit Aug 11, 2023
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
104 changes: 8 additions & 96 deletions src/DynamoCoreWpf/UI/Themes/Modern/LiveChartsStyle.xaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:avalonedit="clr-namespace:ICSharpCode.AvalonEdit;assembly=ICSharpCode.AvalonEdit"
xmlns:clr="clr-namespace:System;assembly=mscorlib"
xmlns:controls="clr-namespace:Dynamo.Views;assembly=DynamoCoreWpf"
xmlns:nodes="clr-namespace:Dynamo.Nodes;assembly=DynamoCoreWpf"
xmlns:dynui="clr-namespace:Dynamo.UI.Controls;assembly=DynamoCoreWpf"
xmlns:fa="http://schemas.fontawesome.com/icons/"
xmlns:p="clr-namespace:Dynamo.Wpf.Properties;assembly=DynamoCoreWpf"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:ui="clr-namespace:Dynamo.UI;assembly=DynamoCoreWpf">
xmlns:ui="clr-namespace:Dynamo.UI;assembly=DynamoCoreWpf"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
zeusongit marked this conversation as resolved.
Show resolved Hide resolved
xmlns:system="clr-namespace:System;assembly=mscorlib">

<ResourceDictionary.MergedDictionaries>
<ui:SharedResourceDictionary Source="{x:Static ui:SharedDictionaryManager.DynamoConvertersDictionaryUri}" />
Expand All @@ -20,8 +13,8 @@
<FontFamily x:Key="ArtifaktElementRegular">../../Fonts/Autodesk/#Artifakt Element Regular</FontFamily>
<FontFamily x:Key="ArtifaktElementBold">../../Fonts/Autodesk/#Artifakt Element Bold</FontFamily>

<lvc:ColorsCollection x:Key="ColorsCollection">
<Color A="255" R="80" G="195" B="218" />
<x:Array Type="Color" x:Key="ColorsCollection">
mjkkirschner marked this conversation as resolved.
Show resolved Hide resolved
<Color A="255" R="80" G="195" B="218" />
<Color A="255" R="212" G="118" B="134" />
<Color A="255" R="224" G="200" B="78" />
<Color A="255" R="113" G="207" B="65" />
Expand All @@ -48,7 +41,7 @@
<Color A="255" R="223" G="197" B="237" />
<Color A="255" R="225" G="225" B="220" />
<Color A="255" R="237" G="191" B="229" />
</lvc:ColorsCollection>
</x:Array>

<system:Double x:Key="Size">12</system:Double>

Expand All @@ -63,95 +56,14 @@
</system:Double>

<Style TargetType="lvc:CartesianChart" x:Key="CartesianLiveChart">
<Setter Property="AnimationsSpeed" Value="0:0:0.420"></Setter>
<Setter Property="SeriesColors" Value="{StaticResource ColorsCollection}"/>
<Setter Property="AnimationsSpeed" Value="00:00:00.420"></Setter>
</Style>

<Style TargetType="lvc:PieChart" x:Key="PieLiveChart">
<Setter Property="AnimationsSpeed" Value="0:0:0.420"></Setter>
<Setter Property="SeriesColors" Value="{StaticResource ColorsCollection}"/>
<Setter Property="AnimationsSpeed" Value="00:00:00.420"></Setter>
<Setter Property="SnapsToDevicePixels" Value="True"/>
</Style>

<Style TargetType="lvc:Axis" x:Key="LiveAxis">
<Setter Property="FontSize" Value="{StaticResource Size}" />
<Setter Property="FontFamily" Value="{StaticResource ArtifaktElementRegular}" />
<Setter Property="Foreground" Value="{StaticResource LightGreyBrush}" />
</Style>

<Style TargetType="lvc:Separator" x:Key="LiveSeparator">
<Setter Property="StrokeThickness"
Value="{StaticResource SeparatorStrokeThickness}" />
<Setter Property="Stroke" Value="{StaticResource MidGreyBrush}" />
<Setter Property="Opacity" Value="81" />
<Style.Triggers>
<Trigger Property="AxisOrientation" Value="X">
<Setter Property="IsEnabled" Value="False"></Setter>
</Trigger>
</Style.Triggers>
</Style>

<Style TargetType="lvc:Separator" x:Key="LiveSeparatorDashed">
<Setter Property="StrokeThickness"
Value="{StaticResource SeparatorStrokeThickness}" />
<Setter Property="StrokeDashArray"
Value="{StaticResource SeparatorStrokeDashArray}" />
<Setter Property="Stroke" Value="{StaticResource MidGreyBrush}" />
<Setter Property="Opacity" Value="81" />
<Style.Triggers>
<Trigger Property="AxisOrientation" Value="X">
<Setter Property="IsEnabled" Value="False"></Setter>
</Trigger>
</Style.Triggers>
</Style>

<Style TargetType="lvc:DefaultLegend">
<Setter Property="Foreground" Value="#DCDCDC"/>
</Style>

<Style TargetType="lvc:Series" x:Key="SeriesStyle">
<Setter Property="FontFamily" Value="{StaticResource ArtifaktElementRegular}" />
<Setter Property="FontSize" Value="{StaticResource Size}" />
<Setter Property="StrokeThickness"
Value="{StaticResource SeriesStrokeThickness}" />
</Style>

<Style TargetType="lvc:CandleSeries"
BasedOn="{StaticResource SeriesStyle}"/>
<Style TargetType="lvc:ColumnSeries"
BasedOn="{StaticResource SeriesStyle}"/>
<Style TargetType="lvc:HeatSeries"
BasedOn="{StaticResource SeriesStyle}"/>
<Style TargetType="lvc:LineSeries"
BasedOn="{StaticResource SeriesStyle}">
<Setter Property="PointGeometrySize"
Value="{StaticResource Size}" />
</Style>
<Style TargetType="lvc:StepLineSeries"
BasedOn="{StaticResource SeriesStyle}">
<Setter Property="PointGeometrySize"
Value="{StaticResource Size}" />
</Style>
<Style TargetType="lvc:VerticalLineSeries"
BasedOn="{StaticResource SeriesStyle}">
<Setter Property="PointGeometrySize"
Value="{StaticResource Size}" />
</Style>
<Style TargetType="lvc:OhlcSeries"
BasedOn="{StaticResource SeriesStyle}"/>
<Style TargetType="lvc:RowSeries"
BasedOn="{StaticResource SeriesStyle}"/>
<Style TargetType="lvc:ScatterSeries"
BasedOn="{StaticResource SeriesStyle}"/>
<Style TargetType="lvc:StackedAreaSeries"
BasedOn="{StaticResource SeriesStyle}"/>
<Style TargetType="lvc:StackedColumnSeries"
BasedOn="{StaticResource SeriesStyle}"/>
<Style TargetType="lvc:StackedRowSeries"
BasedOn="{StaticResource SeriesStyle}"/>
<Style TargetType="lvc:VerticalStackedAreaSeries"
BasedOn="{StaticResource SeriesStyle}"/>


<DrawingBrush x:Key="DefaultBrush" Viewport="0 0 8 8" ViewportUnits="Absolute" TileMode="Tile">
<DrawingBrush.Drawing>
Expand Down
47 changes: 17 additions & 30 deletions src/Libraries/CoreNodeModelsWpf/Charts/BarChartNodeModel.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Autodesk.DesignScript.Runtime;
using CoreNodes.ChartHelpers;
using CoreNodeModelsWpf.Charts.Controls;
using CoreNodeModelsWpf.Charts.Utilities;
using Dynamo.Graph.Nodes;
using Newtonsoft.Json;
using ProtoCore.AST.AssociativeAST;
using CoreNodes.ChartHelpers;
using Dynamo.Controls;
using Dynamo.Nodes;
using Dynamo.Wpf;
using LiveCharts.Wpf;
using Dynamo.UI;
using DynamoServices;
using Dynamo.Wpf.Properties;
using Dynamo.Graph.Connectors;
using System.Linq;
using Newtonsoft.Json.Linq;
using Dynamo.Graph.Nodes;
using Dynamo.ViewModels;
using Dynamo.Wpf;
using Dynamo.Wpf.Properties;
using LiveChartsCore.SkiaSharpView.Painting;
using Newtonsoft.Json;
using ProtoCore.AST.AssociativeAST;
using SkiaSharp.Views.WPF;

namespace CoreNodeModelsWpf.Charts
{
Expand All @@ -44,7 +41,6 @@ namespace CoreNodeModelsWpf.Charts
public class BarChartNodeModel : NodeModel
{
#region Properties
private Random rnd = new Random();
private bool isNestedList;

/// <summary>
Expand All @@ -60,7 +56,7 @@ public class BarChartNodeModel : NodeModel
/// <summary>
/// Bar chart color values.
/// </summary>
public List<SolidColorBrush> Colors { get; set; }
public List<Color> Colors { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is public - ideally we would obsolete the old property, and redirect it to to use and update the new one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense since this was officially added in 2.18

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in addition @zeusongit @QilongTang - if this is going into 2.19 then we'll need to keep the old live charts binaries in the legacy_remove_me folder so they get copied.

If this is only going into a 3.0 release then we can forget the API break, and not include the binaries. I'm not sure that is an option though...? @jasonstratton @pinzart90 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can RC branch 2.19 early and make this a Dynamo 3.0 change, the downside is that chart nodes will not be tested in test fest early because that event is targeting 2.19 NET6 build.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can always merge and then revert - it's not clear to me this will be done by than anyway...?


/// <summary>
/// Triggers when port is connected or disconnected
Expand Down Expand Up @@ -163,7 +159,7 @@ private void DataBridgeCallback(object data)
// Update chart properties
Labels = new List<string>();
Values = new List<List<double>>();
Colors = new List<SolidColorBrush>();
Colors = new List<Color>();

var anyNullData = labels == null || values == null;

Expand Down Expand Up @@ -194,11 +190,11 @@ private void DataBridgeCallback(object data)

Color color;
if (colors == null || colors.Count == 0 || colors.Count != labels.Count)
{
{
if (InPorts[2].IsConnected) return;

// In case colors are not provided, we supply some from the default library of colors
Info(Dynamo.Wpf.Properties.CoreNodeModelWpfResources.ProvideDefaultColorsWarningMessage);
Info(CoreNodeModelWpfResources.ProvideDefaultColorsWarningMessage);

color = Utilities.Colors.GetColor();
}
Expand All @@ -207,10 +203,7 @@ private void DataBridgeCallback(object data)
var dynColor = (DSCore.Color)colors[i];
color = Color.FromArgb(dynColor.Alpha, dynColor.Red, dynColor.Green, dynColor.Blue);
}

SolidColorBrush brush = new SolidColorBrush(color);
brush.Freeze();
Colors.Add(brush);
Colors.Add(color);
}
}
else
Expand All @@ -221,8 +214,6 @@ private void DataBridgeCallback(object data)
{
Labels.Add((string)labels[i]);

var labelValues = new List<double>();

Values.Add(new List<double>{Convert.ToDouble(values[i])} );

Color color;
Expand All @@ -231,7 +222,7 @@ private void DataBridgeCallback(object data)
if (InPorts[3].IsConnected) return;

// In case colors are not provided, we supply some from the default library of colors
Info(Dynamo.Wpf.Properties.CoreNodeModelWpfResources.ProvideDefaultColorsWarningMessage);
Info(CoreNodeModelWpfResources.ProvideDefaultColorsWarningMessage);

color = Utilities.Colors.GetColor();
}
Expand All @@ -240,13 +231,9 @@ private void DataBridgeCallback(object data)
var dynColor = (DSCore.Color)colors[i];
color = Color.FromArgb(dynColor.Alpha, dynColor.Red, dynColor.Green, dynColor.Blue);
}

SolidColorBrush brush = new SolidColorBrush(color);
brush.Freeze();
Colors.Add(brush);
Colors.Add(color);
}
}

Utilities.Colors.ResetColors();

// Notify UI the data has been modified
Expand Down Expand Up @@ -417,7 +404,7 @@ private void UpdateDefaultInPortValues()

private void ExportImage_Click(object sender, RoutedEventArgs e)
{
Export.ToPng(barChartControl.BarChart);
Export.ToPng(barChartControl.BarChartNode);
}

/// <summary>
Expand Down
19 changes: 7 additions & 12 deletions src/Libraries/CoreNodeModelsWpf/Charts/BasicLineChartNodeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ namespace CoreNodeModelsWpf.Charts
public class BasicLineChartNodeModel : NodeModel
{
#region Properties
private Random rnd = new Random();

/// <summary>
/// A list of Labels for each line to be plotted.
Expand All @@ -56,7 +55,7 @@ public class BasicLineChartNodeModel : NodeModel
/// <summary>
/// A list of color values, one for each plotted line.
/// </summary>
public List<SolidColorBrush> Colors { get; set; }
public List<Color> Colors { get; set; }
zeusongit marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Triggers when port is connected or disconnected
Expand Down Expand Up @@ -160,7 +159,7 @@ private void DataBridgeCallback(object data)
// Clear current chart values
Labels = new List<string>();
Values = new List<List<double>>();
Colors = new List<SolidColorBrush>();
Colors = new List<Color>();

var anyNullData = labels == null || values == null;

Expand All @@ -176,24 +175,22 @@ private void DataBridgeCallback(object data)
if (InPorts[2].IsConnected) return;

// In case colors are not provided, we supply some from the default library of colors
Info(Dynamo.Wpf.Properties.CoreNodeModelWpfResources.ProvideDefaultColorsWarningMessage);
Info(CoreNodeModelWpfResources.ProvideDefaultColorsWarningMessage);

for (var i = 0; i < labels.Count; i++)
{
var outputValues = new List<double>();

foreach (var plotVal in values[i] as ArrayList)
{
outputValues.Add(System.Convert.ToDouble(plotVal));
outputValues.Add(Convert.ToDouble(plotVal));
}

Labels.Add((string)labels[i]);
Values.Add(outputValues);

Color color = Utilities.Colors.GetColor();
SolidColorBrush brush = new SolidColorBrush(color);
brush.Freeze();
Colors.Add(brush);
Colors.Add(color);
}

Utilities.Colors.ResetColors();
Expand All @@ -206,17 +203,15 @@ private void DataBridgeCallback(object data)

foreach (var plotVal in values[i] as ArrayList)
{
outputValues.Add(System.Convert.ToDouble(plotVal));
outputValues.Add(Convert.ToDouble(plotVal));
}

Labels.Add((string)labels[i]);
Values.Add(outputValues);

var dynColor = (DSCore.Color)colors[i];
var convertedColor = Color.FromArgb(dynColor.Alpha, dynColor.Red, dynColor.Green, dynColor.Blue);
SolidColorBrush brush = new SolidColorBrush(convertedColor);
brush.Freeze();
Colors.Add(brush);
Colors.Add(convertedColor);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CoreNodeModelsWpf.Charts.Controls"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
xmlns:ui="clr-namespace:Dynamo.UI;assembly=DynamoCoreWpf"
xmlns:p="clr-namespace:Dynamo.Wpf.Properties"
mc:Ignorable="d"
Expand All @@ -20,21 +20,10 @@
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<lvc:CartesianChart Style="{StaticResource CartesianLiveChart}" Name="BarChart" LegendLocation="Bottom" Grid.Row="1">
<lvc:CartesianChart.AxisX>
<lvc:Axis Style="{StaticResource LiveAxis}" Title="Index" >
<lvc:Axis.Separator >
<lvc:Separator IsEnabled="False" Step="1"></lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX >
<lvc:CartesianChart.AxisY>
<lvc:Axis Style="{StaticResource LiveAxis}" Title="Values">
<lvc:Axis.Separator >
<lvc:Separator Style="{StaticResource LiveSeparator}"></lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart Grid.Row="1" Name="BarChartNode"
XAxes="{Binding XAxes}"
YAxes="{Binding YAxes}"
LegendPosition="Bottom">
</lvc:CartesianChart>
<Thumb Name ="resizeThumb"
Grid.Row="1"
Expand Down
Loading