Column Width
This web site builds the control from code behind but you could also grab it from the toolbox, this sample also uses a ViewModel to populate the properties of the control(s) in this sample.
![sample image](https://raw.githubusercontent.com/beto-rodriguez/LiveCharts2/dev//docs/samples/bars/spacing/result.png)
View model
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using LiveChartsCore;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.Painting;
using SkiaSharp;
namespace ViewModelsSamples.Bars.Spacing;
public partial class ViewModel : ObservableObject
{
public ISeries[] Series { get; set; } =
{
new ColumnSeries<double>
{
Values = new ObservableCollection<double> { 20, 50, 40, 20, 40, 30, 50, 20, 50, 40 },
// Defines the distance between every bars in the series
Padding = 0,
// Defines the max width a bar can have
MaxBarWidth = double.PositiveInfinity
}
};
}
Form code behind
using System.Windows.Forms;
using LiveChartsCore.SkiaSharpView.WinForms;
using ViewModelsSamples.Bars.Spacing;
namespace WinFormsSample.Bars.Spacing;
public partial class View : UserControl
{
/// <summary>
/// Initializes a new instance of the <see cref="View"/> class.
/// </summary>
public View()
{
InitializeComponent();
Size = new System.Drawing.Size(50, 50);
var viewModel = new ViewModel();
var cartesianChart = new CartesianChart
{
Series = viewModel.Series,
// out of livecharts properties...
Location = new System.Drawing.Point(0, 0),
Size = new System.Drawing.Size(50, 50),
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
};
Controls.Add(cartesianChart);
}
}