Exemplo n.º 1
0
        /// <summary>
        /// Creates axises for charts.
        /// </summary>
        /// <param name="x">Values for the X axis</param>
        /// <param name="xtitle">Title of the X axis</param>
        /// <param name="y">Values for the Y axis</param>
        /// <param name="ytitle">Title for the Y axis</param>
        /// <param name="chart">Chart to apply the axises to</param>
        /// <param name="Collection">Values collection</param>
        /// <param name="xStep">How many steps on the x axis</param>
        /// <param name="rotation">Labels roatation on the X axis</param>
        private void CreateAxis(IList <string> x, string xtitle, IList <string> y, string ytitle, CartesianChart chart, SeriesCollection Collection, double xStep = 0.0, double yStep = 0.0, int rotation = 0)
        {
            Axis axisx = new Axis();

            axisx.Labels = x;
            axisx.Title  = xtitle;
            if (xStep > 0)
            {
                axisx.Separator.Step = xStep;
            }
            axisx.LabelsRotation = rotation;

            Axis axisy = new Axis();

            axisy.Labels = y;
            axisy.Title  = ytitle;

            if (yStep > 0)
            {
                axisy.Separator.Step = yStep;
            }

            AxesCollection ax = new AxesCollection();
            AxesCollection ay = new AxesCollection();

            ax.Add(axisx);
            ay.Add(axisy);

            chart.Series      = Collection;
            chart.AxisX       = ax;
            chart.AxisY       = ay;
            chart.DataContext = this;
        }
Exemplo n.º 2
0
        public static Chart Configure(
            ObservableCollection <TechnologicalConditionDTO> itemsDataSourceDTO,
            ObservableCollection <TimeCharacteristicDTO> itemsTimeCharacteristicDTO)
        {
            var series           = GetSeries(itemsDataSourceDTO, itemsTimeCharacteristicDTO);
            var seriesCollection = new SeriesCollection();

            seriesCollection.AddRange(series);

            var axisX = new AxesCollection();

            axisX.Add(new Axis {
                Title = "Продолжительность", MinValue = 0, Position = AxisPosition.RightTop
            });

            var labels = itemsDataSourceDTO.Select((p, i) => (++i).ToString());

            var axisY = new AxesCollection();

            axisY.Add(new Axis {
                Title = "Работа", Labels = labels.ToList()
            });

            return(new CartesianChart
            {
                AxisX = axisX,
                AxisY = axisY,
                Series = seriesCollection
            });
        }
Exemplo n.º 3
0
 //Обновление статистики
 private void UpdateStats()
 {
     //Если на момент вызова метода, контроллер не объявлен, выходим
     if (_taskController == null)
     {
         return;
     }
     _axesCollection = new AxesCollection()
     {
         GetDaysOfMonthAxis()
     };
     Graphic.AxisX  = _axesCollection;
     Graphic.Series = GetGraphicCollection();
 }
Exemplo n.º 4
0
        private void ShowCartesian()
        {
            SeriesCollection sc = lvc_cartesian_chart.Series;
            AxesCollection   ac = lvc_cartesian_chart.AxisX;

            AxesCollection ay    = lvc_cartesian_chart.AxisY;
            Axis           axisY = new Axis();

            ay.Add(axisY);

            App app = (App)Application.Current;

            MemberCollection     members = app.MembersViewModel.Members;
            ChartValues <double> values  = new ChartValues <double>();
            Axis axis = new Axis();

            axis.Title    = "X title";
            axis.MinWidth = 50;
            ColumnSeries columnSeries = new ColumnSeries {
                Title  = "Cartesian",
                Values = values,
            };

            //string[] labelValues = new string[members.Count];
            List <string> labelValues = new List <string>();

            foreach (Member member in members)
            {
                values.Add(member.BindInsto);
                labelValues.Add(member.BindName);
            }
            sc.Add(columnSeries);
            axis.Labels   = labelValues;
            axis.Position = AxisPosition.LeftBottom;
            //axis.SetRange(0,2);
            //axis.MinValue = 0;
            //axis.MaxValue = 3;
            axis.IsMerged  = true;
            axis.Separator = new Separator()
            {
                Step = 1
            };

            Formatter = value => value.ToString("N");
            //axis.LabelFormatter = Formatter;


            ac.Add(axis);
        }
Exemplo n.º 5
0
 public TrendViewModel()
 {
     YAxes = new AxesCollection
     {
         new Axis {
             Title = "Y Axis 1", Foreground = Brushes.Gray
         },
         new Axis {
             Title = "Y Axis 2", Foreground = Brushes.Red
         },
         new Axis {
             Title = "Y Axis 3", Foreground = Brushes.Brown
         }
     };
 }
Exemplo n.º 6
0
        private void UiButtonUpdate_Click(object sender, RoutedEventArgs e)
        {
            List <string>    units  = new List <string>();
            SeriesCollection charts = new SeriesCollection();

            foreach (var chartData in chartDatas)
            {
                if (chartData.IsChecked)
                {
                    var i = units.FindIndex(x => x.Equals(chartData.Value.Units));
                    if (i == -1)
                    {
                        units.Add(chartData.Value.Units);
                        i = units.Count - 1;
                    }
                    var chart = new GLineSeries()
                    {
                        Values         = new ChartValues <float>(chartData.Value.Data.Select(x => x.Item2).ToList()),
                        DataLabels     = false,
                        LineSmoothness = 0,
                        ScalesYAt      = i,
                    };
                    charts.Add(chart);
                }
            }
            uiChartControl.uiChart.Series = charts;

            AxesCollection axes       = new AxesCollection();
            AxisPosition   pos        = AxisPosition.LeftBottom;
            int            colorIndex = 0;

            foreach (var unit in units)
            {
                axes.Add(new Axis
                {
                    Title      = unit,
                    Position   = pos,
                    ShowLabels = true,
                    Foreground = new SolidColorBrush(CartesianChart.Colors[colorIndex]),
                });
                if (pos == AxisPosition.LeftBottom)
                {
                    pos = AxisPosition.RightTop;
                }
                colorIndex++;
            }
            uiChartControl.uiChart.AxisY = axes;
        }
Exemplo n.º 7
0
    public Chart(ICanvas canvas, ICanvas drawMargin, IPopup tooltipContainer)
    {
        _canvas           = canvas;
        _drawMargin       = drawMargin;
        _tooltipContainer = tooltipContainer;

        _canvas.AddChildren(_drawMargin);

        MinHeightProperty = 50;
        MinWidthProperty  = 80;

        AnimationsSpeedProperty = TimeSpan.FromMilliseconds(300);
        TooltipTimeoutProperty  = TimeSpan.FromMilliseconds(800);

        AxisXProperty = new AxesCollection();
    }
        public LineChartControl(List <GraphableSeries> values)
        {
            InitializeComponent();

            SeriesCollection = new SeriesCollection();
            YFormatter       = new AxesCollection();
            XFormatter       = new AxesCollection();

            YFormatter.Add(new Axis
            {
                IsMerged  = true,
                Separator = new Separator
                {
                    Step      = 1,
                    IsEnabled = true
                }
            });

            XFormatter.Add(new Axis
            {
                IsMerged  = true,
                Separator = new Separator
                {
                    Step      = 1,
                    IsEnabled = true
                }
            });

            foreach (GraphableSeries graphableSeries in values)
            {
                SeriesCollection.Add(
                    new LineSeries
                {
                    Title         = graphableSeries.Title,
                    Values        = graphableSeries.Values,
                    PointGeometry = null
                });
            }


            Chart.LegendLocation = LegendLocation.Bottom;
            DataContext          = this;
        }
Exemplo n.º 9
0
    public ViewModel()
    {
        SeriesCollection = new SeriesCollection
        {
            new LineSeries
            {
                Title  = "Series 1",
                Values = new ChartValues <double> {
                    4, 66, 5, 2, 4
                },
                ScalesYAt = 0
            },
            new LineSeries
            {
                Title  = "Series 2",
                Values = new ChartValues <double> {
                    6, 7, 3, 4, 6
                },
                ScalesYAt = 1
            },
            new LineSeries
            {
                Title  = "Series 3",
                Values = new ChartValues <double> {
                    4, 2, 7, 2, 7
                },
                ScalesYAt = 2
            }
        };

        AxisYCollection = new AxesCollection
        {
            new Axis {
                Title = "Y Axis 1", Foreground = Brushes.Gray
            },
            new Axis {
                Title = "Y Axis 2", Foreground = Brushes.Red
            },
            new Axis {
                Title = "Y Axis 3", Foreground = Brushes.Brown
            }
        };
    }
Exemplo n.º 10
0
        private static void OnTitlesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var view      = (SignalsLiveView)d;
            var newTitles = (IList <string>)e.NewValue;

            if (newTitles == null || newTitles.Count == 0)
            {
                return;
            }

            // Add cartesian charts vertically for each title in titles
            var grid = view.PART_Grid;

            for (var index = 0; index < newTitles.Count; index++)
            {
                var title = newTitles[index];
                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                var axisY = new AxesCollection {
                    new Axis()
                    {
                        Title = title
                    }
                };
                var chart = new CartesianChart()
                {
                    AxisY = axisY
                };
                grid.Children.Add(chart);
                Grid.SetRow(chart, index);
                // Add to dictionary for convenience when updating chart values
                view._chartDict[newTitles[index]] = chart;
            }
        }
Exemplo n.º 11
0
        public SpeedChartViewModel(GpuSpeedViewModel gpuSpeedVm)
        {
            _gpuSpeedVm = gpuSpeedVm;
            var mapper = Mappers.Xy <MeasureModel>()
                         .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X
                         .Y(model => model.Value);         //use the value property as Y

            //lets save the mapper globally.
            Charting.For <MeasureModel>(mapper);

            Func <double, string> emptyDateTimeFormatter = (d) => { return(string.Empty); };
            Func <double, string> emptySpeedFormatter    = (d) => { return(string.Empty); };
            Func <double, string> dateTimeFormatter      = value => new DateTime((long)value).ToString("HH:mm");
            Func <double, string> speedFormatter         = value => value.ToUnitSpeedText();
            //AxisStep forces the distance between each separator in the X axis
            double axisStep = TimeSpan.FromMinutes(1).Ticks;
            //AxisUnit forces lets the axis know that we are plotting Minutes
            //this is not always necessary, but it can prevent wrong labeling
            double axisUnit = TimeSpan.TicksPerMinute;

            ChartValues <MeasureModel> mainCoinSpeedValues       = new ChartValues <MeasureModel>();
            ChartValues <MeasureModel> mainCoinSpeedValuesShadow = new ChartValues <MeasureModel>();
            LineSeries mainCoinSpeedLs = new LineSeries {
                Title             = gpuSpeedVm.GpuVm.IndexText,
                DataLabels        = false,
                PointGeometrySize = 0,
                StrokeThickness   = 1,
                Values            = mainCoinSpeedValues
            };
            LineSeries mainCoinSpeedLsShadow = new LineSeries {
                Title             = gpuSpeedVm.GpuVm.IndexText,
                DataLabels        = false,
                PointGeometrySize = 0,
                StrokeThickness   = 1,
                Values            = mainCoinSpeedValuesShadow
            };

            this.Series.Add(mainCoinSpeedLs);
            this.SeriesShadow.Add(mainCoinSpeedLsShadow);
            SolidColorBrush black         = new SolidColorBrush(Colors.Black);
            Axis            axisYMainCoin = new Axis()
            {
                LabelFormatter = emptySpeedFormatter,
                MinValue       = 0,
                Separator      = new Separator()
            };

            this._axisY = new AxesCollection()
            {
                axisYMainCoin
            };
            DateTime now = DateTime.Now;

            this._axisX = new AxesCollection()
            {
                new Axis()
                {
                    LabelFormatter = emptyDateTimeFormatter,
                    MaxValue       = now.Ticks,
                    MinValue       = now.Ticks - TimeSpan.FromMinutes(NTMinerRoot.Current.SpeedHistoryLengthByMinute).Ticks,
                    Unit           = axisUnit,
                    Separator      = new Separator()
                    {
                        Step = axisStep
                    }
                }
            };
            Axis axisYShadowMainCoin = new Axis()
            {
                LabelFormatter = speedFormatter,
                MinValue       = 0,
                FontSize       = 14,
                Foreground     = black,
                Separator      = new Separator()
            };

            this._axisYShadow = new AxesCollection()
            {
                axisYShadowMainCoin
            };
            this._axisXShadow = new AxesCollection()
            {
                new Axis()
                {
                    LabelFormatter = dateTimeFormatter,
                    Foreground     = black,
                    MaxValue       = 0,
                    FontSize       = 14,
                    MinValue       = 0,
                    Unit           = axisUnit,
                    Separator      = new Separator()
                    {
                        Step = axisStep
                    }
                }
            };
        }
Exemplo n.º 12
0
        public ChartViewModel(CoinViewModel coinVm)
        {
            this.Hide = new DelegateCommand(() => {
                this.IsShow = false;
            });
            _coinVm = coinVm;
            var mapper = Mappers.Xy <MeasureModel>()
                         .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X
                         .Y(model => model.Value);         //use the value property as Y

            //lets save the mapper globally.
            Charting.For <MeasureModel>(mapper);

            string DateTimeFormatter(double value) => new DateTime((long)value).ToString("HH:mm");
            string SpeedFormatter(double value) => value.ToUnitSpeedText();

            //AxisStep forces the distance between each separator in the X axis
            double axisStep = TimeSpan.FromMinutes(1).Ticks;
            //AxisUnit forces lets the axis know that we are plotting Minutes
            //this is not always necessary, but it can prevent wrong labeling
            double axisUnit   = TimeSpan.TicksPerMinute;
            var    axisYSpeed = new Axis()
            {
                LabelFormatter = SpeedFormatter,
                MinValue       = 0,
                Separator      = new Separator(),
                Foreground     = SAxisForeground,
                FontSize       = 13,
                Position       = AxisPosition.RightTop
            };
            var axisYOnlineCount = new Axis()
            {
                LabelFormatter = value => Math.Round(value, 0) + "miner",
                Separator      = new Separator(),
                Foreground     = SAxisForeground,
                MinValue       = 0,
                FontSize       = 11
            };
            var axisYShareCount = new Axis()
            {
                LabelFormatter = value => Math.Round(value, 0) + "share",
                Separator      = new Separator(),
                Foreground     = SAxisForeground,
                MinValue       = 0,
                FontSize       = 11,
                Position       = AxisPosition.RightTop
            };

            this._axisY = new AxesCollection {
                axisYOnlineCount, axisYSpeed, axisYShareCount
            };
            DateTime now = DateTime.Now;

            this._axisX = new AxesCollection()
            {
                new Axis()
                {
                    LabelFormatter = DateTimeFormatter,
                    MaxValue       = now.Ticks,
                    MinValue       = now.Ticks - TimeSpan.FromMinutes(NTMinerRoot.SpeedHistoryLengthByMinute).Ticks,
                    Unit           = axisUnit,
                    Separator      = new Separator()
                    {
                        Step = axisStep
                    },
                    Foreground = SAxisForeground,
                    FontSize   = 12,
                }
            };
            LineSeries mainCoinSpeedLs = new LineSeries {
                Title             = "speed",
                DataLabels        = false,
                PointGeometrySize = 0,
                StrokeThickness   = 1,
                ScalesYAt         = 1,
                Values            = new ChartValues <MeasureModel>()
            };
            LineSeries onlineCountLs = new LineSeries {
                Title             = "onlineCount",
                DataLabels        = false,
                PointGeometrySize = 0,
                StrokeThickness   = 1,
                ScalesYAt         = 0,
                Fill   = STransparent,
                Stroke = OnlineColor,
                Values = new ChartValues <MeasureModel>()
            };
            LineSeries miningCountLs = new LineSeries {
                Title             = "miningCount",
                DataLabels        = false,
                PointGeometrySize = 0,
                StrokeThickness   = 1,
                ScalesYAt         = 0,
                Fill   = STransparent,
                Stroke = MiningColor,
                Values = new ChartValues <MeasureModel>()
            };

            _rejectValues = new ChartValues <MeasureModel>();
            _acceptValues = new ChartValues <MeasureModel>();
            StackedColumnSeries rejectScs = new StackedColumnSeries {
                Title          = "rejectShare",
                Values         = _rejectValues,
                DataLabels     = false,
                ScalesYAt      = 2,
                MaxColumnWidth = 7
            };
            StackedColumnSeries acceptScs = new StackedColumnSeries {
                Title          = "acceptShare",
                Values         = _acceptValues,
                DataLabels     = false,
                ScalesYAt      = 2,
                MaxColumnWidth = 7
            };

            this._series = new SeriesCollection()
            {
                mainCoinSpeedLs, rejectScs, acceptScs, miningCountLs, onlineCountLs
            };
        }
        public ControlCenterChartViewModel(CoinViewModel coinVm)
        {
            _coinVm = coinVm;
            var mapper = Mappers.Xy <MeasureModel>()
                         .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X
                         .Y(model => model.Value);         //use the value property as Y

            //lets save the mapper globally.
            Charting.For <MeasureModel>(mapper);

            Func <double, string> dateTimeFormatter = value => new DateTime((long)value).ToString("HH:mm");
            Func <double, string> speedFormatter    = value => value.ToUnitSpeedText();
            //AxisStep forces the distance between each separator in the X axis
            double axisStep = TimeSpan.FromMinutes(1).Ticks;
            //AxisUnit forces lets the axis know that we are plotting Minutes
            //this is not always necessary, but it can prevent wrong labeling
            double axisUnit   = TimeSpan.TicksPerMinute;
            var    axisYSpeed = new Axis()
            {
                LabelFormatter = speedFormatter,
                MinValue       = 0,
                Separator      = new Separator(),
                Foreground     = black,
                FontSize       = 13,
                Position       = AxisPosition.RightTop
            };
            var axisYOnlineCount = new Axis()
            {
                LabelFormatter = value => Math.Round(value, 0).ToString(),
                Separator      = new Separator(),
                Foreground     = black,
                MinValue       = 0,
                FontSize       = 13
            };

            this._axisY = new AxesCollection {
                axisYOnlineCount, axisYSpeed
            };
            DateTime now = DateTime.Now;

            this._axisX = new AxesCollection()
            {
                new Axis()
                {
                    LabelFormatter = dateTimeFormatter,
                    MaxValue       = now.Ticks,
                    MinValue       = now.Ticks - TimeSpan.FromMinutes(NTMinerRoot.Current.SpeedHistoryLengthByMinute).Ticks,
                    Unit           = axisUnit,
                    Separator      = new Separator()
                    {
                        Step = axisStep
                    },
                    Foreground = black,
                    FontSize   = 13,
                }
            };
            LineSeries mainCoinSpeedLs = new LineSeries {
                Title             = "speed",
                DataLabels        = false,
                PointGeometrySize = 0,
                StrokeThickness   = 1,
                ScalesYAt         = 1,
                Values            = new ChartValues <MeasureModel>()
            };
            LineSeries onlineCountLs = new LineSeries {
                Title             = "onlineCount",
                DataLabels        = false,
                PointGeometrySize = 0,
                StrokeThickness   = 1,
                ScalesYAt         = 0,
                Fill   = transparent,
                Stroke = OnlineColor,
                Values = new ChartValues <MeasureModel>()
            };
            LineSeries miningCountLs = new LineSeries {
                Title             = "miningCount",
                DataLabels        = false,
                PointGeometrySize = 0,
                StrokeThickness   = 1,
                ScalesYAt         = 0,
                Fill   = transparent,
                Stroke = MiningColor,
                Values = new ChartValues <MeasureModel>()
            };

            this._series = new SeriesCollection()
            {
                mainCoinSpeedLs, onlineCountLs, miningCountLs
            };
        }