Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grouped Bar Chart #42

Closed
vinicius121 opened this issue May 18, 2021 · 3 comments
Closed

Grouped Bar Chart #42

vinicius121 opened this issue May 18, 2021 · 3 comments

Comments

@vinicius121
Copy link

Hi,

I'm trying to use the grouped column chart. But it doesn't show on the interface after I click a button to display the chart.
Here is the code behind:

public ObservableCollection<ISeries> SeriesCollectionBar { get; set; }

SeriesCollectionBar = new System.Collections.ObjectModel.ObservableCollection<ISeries>();

foreach (DataColumn column in performanceTable.Columns)
{
    SeriesCollectionBar.Add(new ColumnSeries<double>
    {           
        Name = column.ColumnName,
        Values = new ObservableCollection<double> { 2, 4, 6, 1, 7, -2 }
    });
}

I also want to append a new value so I'm doing the following:
SeriesCollectionBar[column.Ordinal].Values.Append(3);
To append, I've declared an extension method as follows:

public static IEnumerable Append(this IEnumerable first, params object[] second)
{
    return first.OfType<object>().Concat(second);
}

The xaml code:
<lvc:CartesianChart Series="{Binding SeriesCollectionBar}"></lvc:CartesianChart>

Any help?

Thanks

@beto-rodriguez
Copy link
Owner

beto-rodriguez commented May 18, 2021

Hi

Where are you initializing the SeriesCollectionBar property?

// this should be called in the constructor of your VM, otherwise your VM must implement INotifyPropertyChanged
SeriesCollectionBar = new System.Collections.ObjectModel.ObservableCollection<ISeries>();

@vinicius121
Copy link
Author

Hi,

I'm not using MVVM. So, I initialize inside the button event. And I have also declared the INotifyPropertyChanged, as below:

private ObservableCollection<ISeries> seriesCollectionBar;
public ObservableCollection<ISeries> SeriesCollectionBar
{
    get { return seriesCollectionBar; }
    set { seriesCollectionBar = value; OnPropertyChanged("SeriesCollectionBar"); }
}
private void OnPropertyChanged(string propertyName)
{
    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

I don't know what I'm missing...
Any other suggestions?
Thanks

@beto-rodriguez
Copy link
Owner

I am closing this issue for now, please feel free to create a new issue if the error persist, please try to include a small repository or the steps to recreate the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants