LiveCharts w WPF

0

Cześć staram się dodać wykres do alikacji WPF ale mam bład że żadne dane się nie pokazuje a debuguje i włąsciwości mają prawidłowe dane.

XAML:

        <lvc:CartesianChart>
            <lvc:CartesianChart.Series>
                <lvc:VerticalLineSeries Title="Wynik finansowy" Values="{Binding Path=Series}"/>
            </lvc:CartesianChart.Series>
            <lvc:CartesianChart.AxisX>
                <lvc:Axis Title="Miesiąc" Labels="{Binding Path=Months}">
                    <lvc:Axis.Separator>
                        <lvc:Separator Step="1"/>
                    </lvc:Axis.Separator>
                </lvc:Axis>
            </lvc:CartesianChart.AxisX>
            <lvc:CartesianChart.AxisY>
                <lvc:Axis Title="Kwota"/>
            </lvc:CartesianChart.AxisY>
        </lvc:CartesianChart>

ViewModel:

    public class CompanyStaticViewModel : ObservableObject
    {
        private readonly IEventAggregator eventAggregator;
        private readonly IResponseService responseService;

        public CompanyStaticViewModel(IEventAggregator _eventAggregator, IResponseService _responseService)
        {
            eventAggregator = _eventAggregator;
            responseService = _responseService;

            Load();


        }


        private ChartValues<decimal> _sumFinancialResult;
        public ChartValues<decimal> SumFinancialResult
        {
            get
            {
                return _sumFinancialResult;
            }
            private set
            {
                _sumFinancialResult = value;
                OnPropertyChanged(ref _sumFinancialResult, value);
            }
        }

        public SeriesCollection Series { get; set; }

        public List<string> Months { get; set; }


        public async void Load()
        {
            var result = await responseService.GetAll<CompanyFinancialResultModel>("Company/GetFinancialResult");

            SumFinancialResult = new ChartValues<decimal>(result.Select(x=>x.Sum));

            Months = result.Select(x => x.Date).ToList();

            Series = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title = "Wynik finansowy",
                    Values = SumFinancialResult
                }
            };
        }

    }

Co robię źle ? :)

2

OnPropertyChanged jest Ci potrzebny na Months i Series bo do nich się przypinasz. Nie jest natomiast potrzebny na SumFinancialResult więc masz wszystko dosłownie odwrotnie

1 użytkowników online, w tym zalogowanych: 0, gości: 1