ColumnSeries class does not exist in my OxyPlot.Series namespace

66 Views Asked by At

I recently downloaded and installed OxyPlot.WindowsForms to create some plot charts using C# and winsforms and I did it via NuGet Packages Manager in Visual Studio.

But when I try to use the ColumnSeries class I got the error:

Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'ColumnSeries' could not be found (are you missing a using directive or an assembly reference?)

I am new using OxyPlot.WindowsForms and I have been looking for the solution in the web and I have not found any. I am using OxyPlot.WindowsForms version 2.1.2 and Visual Studio 2022 Community.

Also I do Ctrl + c when typing OxyPlot.Series. and the class ColumnSeries does not apper!

This is my code:

using System.Configuration;
using System.Windows.Forms;
using OxyPlot;
using OxyPlot.Axes;
using OxyPlot.Series;


namespace SistemaRegistroAgua
{
    public partial class Form1 : Form
    {
         public Form1()
         {
             InitializeComponent();

             plotView1.Model = CreateHistogramModel();
         }

     private PlotModel CreateHistogramModel()
     {
         var model = new PlotModel { Title = "Histograma de Etiquetas" };

         // Datos de ejemplo (pueden ser tus datos reales)
         var etiquetas = new List<string> { "18L", "10L", "5L", "PersonalizadoL" };
         var cantidades = new List<int> { 5, 10, 7, 3 };

         // Crear las columnas del histograma
         var series = new ColumnSeries();

         for (int i = 0; i < etiquetas.Count; i++)
         {
             series.Items.Add(new ColumnItem(cantidades[i], i + 1));
         }

         model.Series.Add(series);

        // Personalizar el eje X
        var categoryAxis = new CategoryAxis { Position = AxisPosition.Bottom };
        categoryAxis.Labels.AddRange(etiquetas);
        model.Axes.Add(categoryAxis);

        // Personalizar el eje Y
        model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = 0 });

        return model;
    }

Thanks in advance!

0

There are 0 best solutions below