Dynamic Visibility

The [ObservableObject], [ObservableProperty] and [ICommand] attributes come from the CommunityToolkit.Mvvm package, you can read more about it here.

This web site wraps every sample using a UserControl instance, but LiveCharts controls can be used inside any container.

sample image

View model

using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using LiveChartsCore;
using LiveChartsCore.SkiaSharpView;

namespace ViewModelsSamples.General.Visibility;

public partial class ViewModel : ObservableObject
{
    public ISeries[] Series { get; set; } =
    {
        new ColumnSeries<double>
        {
            Values = new ObservableCollection<double> { 2, 5, 4, 3 },
            IsVisible = true
        },
        new ColumnSeries<double>
        {
            Values = new ObservableCollection<double> { 6, 3, 2, 8 },
            IsVisible = true
        },
        new ColumnSeries<double>
        {
            Values = new ObservableCollection<double> { 4, 2, 8, 7 },
            IsVisible = true
        }
    };

    [RelayCommand]
    public void ToggleSeries0()
    {
        Series[0].IsVisible = !Series[0].IsVisible;
    }

    [RelayCommand]
    public void ToggleSeries1()
    {
        Series[1].IsVisible = !Series[1].IsVisible;
    }

    [RelayCommand]
    public void ToggleSeries2()
    {
        Series[2].IsVisible = !Series[2].IsVisible;
    }
}

XAML

<UserControl x:Class="AvaloniaSample.General.Visibility.View"
             xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:lvc="using:LiveChartsCore.SkiaSharpView.Avalonia"
             xmlns:vms="using:ViewModelsSamples.General.Visibility">
  <UserControl.DataContext>
    <vms:ViewModel/>
  </UserControl.DataContext>
  <Grid>
      <Grid.RowDefinitions>
          <RowDefinition Height="30"/>
          <RowDefinition Height="*"/>
      </Grid.RowDefinitions>
      <StackPanel Grid.Row="0" Orientation="Horizontal">
          <Button Command="{Binding ToggleSeries0Command}" Margin="8 0">Toggle first</Button>
          <Button Command="{Binding ToggleSeries1Command}" Margin="8 0">Toggle second</Button>
          <Button Command="{Binding ToggleSeries2Command}" Margin="8 0">Toggle third</Button>
      </StackPanel>
      <lvc:CartesianChart Grid.Row="1" Series="{Binding Series}" />
  </Grid>  
</UserControl>

Articles you might also find useful: