public HeatSeriesControl(HeatSeriesNodeModel model)
        {
            InitializeComponent();

            model.PropertyChanged += NodeModel_PropertyChanged;

            BuildUI(model);

            DataContext = this;
        }
        private GradientStopCollection BuildColors(HeatSeriesNodeModel model)
        {
            var colors = new GradientStopCollection();

            // If provided with a single color create range from transparent white to color
            if (model.Colors.Count == 1)
            {
                colors.Add(new GradientStop()
                {
                    Offset = 0,
                    Color  = Color.FromArgb(255, 255, 255, 255)
                });

                colors.Add(new GradientStop()
                {
                    Offset = 1,
                    Color  = model.Colors[0]
                });
            }

            // If provided with several colors create a range for provided colors
            else if (model.Colors.Count > 1)
            {
                var count = model.Colors.Count;

                for (var i = 0; i < count; i++)
                {
                    colors.Add(new GradientStop()
                    {
                        Offset = i / (count - 1),
                        Color  = model.Colors[i]
                    });
                }
            }

            return(colors);
        }
        private void BuildUI(HeatSeriesNodeModel model)
        {
            // Load sample data if any ports are not connected
            if (!model.InPorts[0].IsConnected && !model.InPorts[1].IsConnected && !model.InPorts[2].IsConnected && !model.InPorts[3].IsConnected)
            {
                // X - Products
                var XLabels = new[]
                {
                    "Item-1",
                    "Item-2",
                    "Item-3",
                    "Item-4",
                    "Item-5"
                };

                // Y - Day of the week
                var YLabels = new[]
                {
                    "Monday",
                    "Tuesday",
                    "Wednesday",
                    "Thursday",
                    "Friday",
                    "Saturday",
                    "Sunday"
                };

                // Value for each product on every day of the week
                var chartValues = new ChartValues <HeatPoint>();

                for (var i = 0; i < XLabels.Length; i++)
                {
                    for (var j = 0; j < YLabels.Length; j++)
                    {
                        chartValues.Add(new HeatPoint(i, j, rnd.Next(0, 10)));
                    }
                }

                XAxis.Labels = XLabels;
                YAxis.Labels = YLabels;
                HeatSeriesUI.Series.Add(new HeatSeries()
                {
                    Values         = chartValues,
                    DrawsHeatRange = false,
                    DataLabels     = true
                });
            }
            // Else load input data
            else if (model.InPorts[0].IsConnected && model.InPorts[1].IsConnected && model.InPorts[2].IsConnected && model.InPorts[3].IsConnected)
            {
                if (model.XLabels.Count == model.Values.Count && model.XLabels.Count > 0)
                {
                    var chartValues = new ChartValues <HeatPoint>();

                    for (var i = 0; i < model.XLabels.Count; i++)
                    {
                        for (var j = 0; j < model.YLabels.Count; j++)
                        {
                            chartValues.Add(new HeatPoint(i, j, model.Values[i][j]));
                        }
                    }

                    var colors         = BuildColors(model);
                    var hoverIconColor = new SolidColorBrush(Color.FromArgb(255, 94, 92, 90));

                    XAxis.Labels = model.XLabels;
                    YAxis.Labels = model.YLabels;
                    HeatSeriesUI.Series.Add(new HeatSeries()
                    {
                        Values                 = chartValues,
                        DrawsHeatRange         = false,
                        GradientStopCollection = colors,
                        Fill          = hoverIconColor,
                        PointGeometry = DefaultGeometries.Square
                                        //DataLabels = true
                    });
                }
            }
        }