private void XYLineChartNodeModel_PortDisconnected(PortModel port)
        {
            // Clear UI when a input port is disconnected
            if (port.PortType == PortType.Input && this.State == ElementState.Active)
            {
                Labels.Clear();
                XValues.Clear();
                YValues.Clear();
                Colors.Clear();

                RaisePropertyChanged("DataUpdated");
            }
        }
Example #2
0
 public void ClearAll()
 {
     XValues.Clear();
     YValues.Clear();
     ZValues.Clear();
 }
Example #3
0
        private void UpdateSample(TimeSpan sampleTime, TimeSpan sampleBackFor)
        {
            var sampleLimit = DateTimeOffset.Now - sampleBackFor;

            XMinimum = sampleLimit.ToUnixTimeMilliseconds();

            var values = _history.SelectTimeSampleBackwards(
                x => x.Date,
                x => x.Balance,
                sampleTime,
                sampleLimit,
                DateTime.Now);

            XValues.Clear();
            YValues.Clear();

            foreach (var(timestamp, balance) in values.Reverse())
            {
                YValues.Add((double)balance.ToDecimal(MoneyUnit.BTC));
                XValues.Add(timestamp.ToUnixTimeMilliseconds());
            }

            if (YValues.Any())
            {
                var maxY = YValues.Max();
                YLabels = new List <string> {
                    "0", (maxY / 2).ToString("F2"), maxY.ToString("F2")
                };
            }
            else
            {
                YLabels = null;
            }

            if (XValues.Any())
            {
                var minX  = XValues.Min();
                var maxX  = XValues.Max();
                var halfX = minX + ((maxX - minX) / 2);

                var range = DateTimeOffset.FromUnixTimeMilliseconds((long)maxX) -
                            DateTimeOffset.FromUnixTimeMilliseconds((long)minX);

                if (range <= TimeSpan.FromDays(1))
                {
                    XLabels = new List <string>
                    {
                        DateTimeOffset.FromUnixTimeMilliseconds((long)minX).DateTime.ToString("t"),
                        DateTimeOffset.FromUnixTimeMilliseconds((long)halfX).DateTime.ToString("t"),
                        DateTimeOffset.FromUnixTimeMilliseconds((long)maxX).DateTime.ToString("t"),
                    };
                }
                else if (range <= TimeSpan.FromDays(7))
                {
                    XLabels = new List <string>
                    {
                        DateTimeOffset.FromUnixTimeMilliseconds((long)minX).DateTime.ToString("ddd MMM-d"),
                        DateTimeOffset.FromUnixTimeMilliseconds((long)halfX).DateTime.ToString("ddd MMM-d"),
                        DateTimeOffset.FromUnixTimeMilliseconds((long)maxX).DateTime.ToString("ddd MMM-d"),
                    };
                }
                else
                {
                    XLabels = new List <string>
                    {
                        DateTimeOffset.FromUnixTimeMilliseconds((long)minX).DateTime.ToString("MMM-d"),
                        DateTimeOffset.FromUnixTimeMilliseconds((long)halfX).DateTime.ToString("MMM-d"),
                        DateTimeOffset.FromUnixTimeMilliseconds((long)maxX).DateTime.ToString("MMM-d"),
                    };
                }
            }
            else
            {
                XLabels = null;
            }
        }