示例#1
0
    public MainWindow()
    {
        var doubleMapperWithMonthColors = new LiveCharts.Configurations.CartesianMapper <double>()
                                          .X((value, index) => index)
                                          .Y((value) => value)
                                          .Fill((v, i) =>
        {
            switch (i % 12)
            {
            case  0: return(Brushes.LightBlue);         //january

            case  1: return(Brushes.LightCoral);        //february

            case  2: return(Brushes.PaleGoldenrod);     //march

            case  3: return(Brushes.OrangeRed);         //april

            case  4: return(Brushes.BlueViolet);        //may

            case  5: return(Brushes.Chocolate);         //june

            case  6: return(Brushes.PaleVioletRed);     //july

            case  7: return(Brushes.CornflowerBlue);    //august

            case  8: return(Brushes.Orchid);            //september

            case  9: return(Brushes.Thistle);           //october

            case 10: return(Brushes.BlanchedAlmond);    //november

            case 11: return(Brushes.YellowGreen);       //december

            default: return(Brushes.Red);
            }
        });

        LiveCharts.Charting.For <double>(doubleMapperWithMonthColors, SeriesOrientation.Horizontal);

        senderChart = new SeriesCollection();
        var columnSeries = new ColumnSeries()
        {
            Values = new ChartValues <double>(), DataLabels = true, Title = "Appointments"
        };
        var labels = this.dateValues;

        foreach (var val in dataValues)
        {
            columnSeries.Values.Add(val);
        }
        this.senderChart.Add(columnSeries);
        DataContext = this;
    }
示例#2
0
        public chartUserControl()
        {
            Console.WriteLine("Row Chart Constructor Called");
            InitializeComponent();
            fillChart();
            updateMinMax();

            var doubleMapper = new LiveCharts.Configurations.CartesianMapper <double>()
                               .X((value) => value)
                               .Y((value, index) => index)
                               .Fill((value, index) => (value > 0 ? Brushes.Green : Brushes.Red));

            LiveCharts.Charting.For <double>(doubleMapper, SeriesOrientation.Vertical);

            senderChart = new SeriesCollection();

            var rowSeries = new RowSeries()
            {
                Values = new ChartValues <double>(), DataLabels = true, Title = "P/L", MaxRowHeigth = 20
            };
            var labels = this.dataLabels;

            foreach (var val in dataValues)
            {
                rowSeries.Values.Add(val);
            }

            this.senderChart.Add(rowSeries);

            chart1.AxisX.Add(new Axis
            {
                LabelFormatter = value => value.ToString(),
                Separator      = new LiveCharts.Wpf.Separator()
                {
                    Step = 10
                },
                Title    = "P/L",
                MaxValue = maximum,
                MinValue = (-1) * maximum
            });

            Labels    = dataLabels;
            Formatter = value => value.ToString("N");

            DataContext = this;
        }
        public HistoryUserControlViewModel()
        {
            var mapper = new LiveCharts.Configurations.CartesianMapper <double>().X((values, index) => index).Y((values) => values).Fill((v, i) => i == DateTime.Now.Hour ? Brushes.White : Brushes.White).Stroke((v, i) => i == DateTime.Now.Hour ? Brushes.White : Brushes.White);

            LiveCharts.Charting.For <double>(mapper, LiveCharts.SeriesOrientation.Horizontal);

            Period = new List <string>()
            {
                "Day", "Month", "Year"
            };
            Mesec = new List <string>()
            {
                "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
            };
            Godina = new List <string>()
            {
                "2020", "2019", "2018", "2017", "2016", "2015"
            };
            _itemsDay      = new ObservableCollection <DayItem>();
            _itemsMonth    = new ObservableCollection <MonthItem>();
            _itemsYear     = new ObservableCollection <YearItem>();
            SelectedPeriod = Period[0];
            IsDan          = Visibility.Visible;
            _chartValues   = new ChartValues <double>();
            for (int j = 0; j <= 24; j++)
            {
                _chartValues.Add(0.0);
            }
            _chartValuesMonth = new ChartValues <double>();
            for (int j = 0; j <= 31; j++)
            {
                _chartValuesMonth.Add(0.0);
            }
            _chartValuesYear = new ChartValues <double>();
            for (int j = 0; j <= 12; j++)
            {
                _chartValuesYear.Add(0.0);
            }
            _min         = false;
            _max         = false;
            _avg         = false;
            _selectedGID = 0;
        }