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:
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
– Lucas Vasconcelos
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
– Lucas Vasconcelos
It’s this one in the topic. It’s in it that I’m somewhere missing.
– Lucas Vasconcelos
I got it man, I thought you were using Ajax tbm. It was much easier to do with Ajax.
– Marconi