How to put multiple series in 3 dimensions in a highchart correctly?

Asked

Viewed 190 times

0

My goal is to create a chart where I have the name, quantity and period.

I am using Dotnet.Highchart in C# Webforms.

My chart currently looks like this:

inserir a descrição da imagem aqui

And I even know why it’s like this, I’m just not getting it fixed.

This error is due to the following:

Each series of this is coming from only one query, but each query of this was used from formula group by to join the dates and when it will plot the series it takes the last and applies for everything.

This is my code:

    public string TentativaNovoGrafico()
    {
        ProjetoBLL projBLL = new ProjetoBLL();
        Projeto proj = new Projeto();

        List<Tuple<string, int, string>> massivos = projBLL.GrafQtdMassivosAno();

        object[,] chartDataMassivos = new object[massivos.Count, 3];
        int i = 0;

        foreach (Tuple<string, int, string> item in massivos)
        {
            chartDataMassivos.SetValue(item.Item1, i, 0);
            chartDataMassivos.SetValue(item.Item2, i, 1);
            chartDataMassivos.SetValue(item.Item3, i, 2);
            i++;
        }

        List<Tuple<string, int, string>> repAtivos = projBLL.GrafQtdRepAtivosAno();

        object[,] chartDataRepAtivos = new object[massivos.Count, 3];
        int j = 0;

        foreach (Tuple<string, int, string> item in massivos)
        {
            chartDataRepAtivos.SetValue(item.Item1, j, 0);
            chartDataRepAtivos.SetValue(item.Item2, j, 1);
            chartDataRepAtivos.SetValue(item.Item3, j, 2);
            j++;
        }

        List<Tuple<string, int, string>> especiais = projBLL.GrafQtdEspeciaisAno();

        object[,] chartDataEspeciais = new object[massivos.Count, 3];
        int k = 0;

        foreach (Tuple<string, int, string> item in massivos)
        {
            chartDataEspeciais.SetValue(item.Item1, k, 0);
            chartDataEspeciais.SetValue(item.Item2, k, 1);
            chartDataEspeciais.SetValue(item.Item3, k, 2);
            k++;
        }

        Series serieMassivos = new Series();
        Series serieEspecial = new Series();
        Series serieRepAtivos = new Series();

        serieMassivos.Data = new Data(chartDataMassivos);
        serieEspecial.Data = new Data(chartDataEspeciais);
        serieRepAtivos.Data = new Data(chartDataRepAtivos);

        serieMassivos.Name = "Massivos";
        serieEspecial.Name = "Especial";
        serieRepAtivos.Name = "Rep. de Ativos";

        serieMassivos.Type = ChartTypes.Column;
        serieEspecial.Type = ChartTypes.Column;
        serieRepAtivos.Type = ChartTypes.Column;

        Series[] series = new Series[] { serieMassivos, serieEspecial, serieRepAtivos };

        Highcharts chart = new Highcharts("bar").SetTitle(new Title
            {
                Text = "Quantidade Projetos"
            }).SetXAxis(new XAxis
            {
                Categories =
                    new[]
                        {
                            "Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"
                        }
            })

    .SetSeries(series);

        return chart.ToHtmlString();
    }
  • Good afternoon @Marconi I wanted to do one of these http://www.highcharts.com/demo/column-basic

  • Actually my html is just: <Asp:Literal ID="graphic1" runat="server"></Asp:Literal> and my Return of this method I sent up fills this literal and shows the chart

  • It’s this one in the topic. It’s in it that I’m somewhere missing.

  • I got it man, I thought you were using Ajax tbm. It was much easier to do with Ajax.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.