Bom, como não encontrei saída para este problema, resolvi criando um vetor para receber as informações do gráfico e depois fazendo varias verificações Ifs para saber a quantidade de informações que aparecerão no gráfico, segue o código caso alguém esteja com o mesmo problema e ainda não soube como resolver.
if (contador == 1)
{
DotNet.Highcharts.Highcharts chart3 = new DotNet.Highcharts.Highcharts("chart3")
.InitChart(new Chart { PlotShadow = false })
.SetTitle(new Title { Text = "Demonstrativo das Despesas - Periodo de " + ini + " a " + fim + "." })
.SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }" })
.SetPlotOptions(new PlotOptions
{
Pie = new PlotOptionsPie
{
AllowPointSelect = true,
Cursor = Cursors.Pointer,
DataLabels = new PlotOptionsPieDataLabels
{
Color = ColorTranslator.FromHtml("#000000"),
ConnectorColor = ColorTranslator.FromHtml("#000000"),
Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }"
}
}
})
.SetSeries(new Series
{
Type = ChartTypes.Pie,
Name = "Browser share",
Data = new Data(new object[]
{
new object[] { chartValuesC[0], chartValuesV[0]}
})
});
return View(chart3);
}
else if (contador == 2)
{
DotNet.Highcharts.Highcharts chart3 = new DotNet.Highcharts.Highcharts("chart3")
.InitChart(new Chart { PlotShadow = false })
.SetTitle(new Title { Text = "Demonstrativo das Despesas - Periodo de " + ini + " a " + fim + "." })
.SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }" })
.SetPlotOptions(new PlotOptions
{
Pie = new PlotOptionsPie
{
AllowPointSelect = true,
Cursor = Cursors.Pointer,
DataLabels = new PlotOptionsPieDataLabels
{
Color = ColorTranslator.FromHtml("#000000"),
ConnectorColor = ColorTranslator.FromHtml("#000000"),
Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }"
}
}
})
.SetSeries(new Series
{
Type = ChartTypes.Pie,
Name = "Browser share",
Data = new Data(new object[]
{
new object[] { chartValuesC[0], chartValuesV[0]},
new object[] { chartValuesC[1], chartValuesV[1]}
})
});
return View(chart3);
}
else if (contador == 3)
{
DotNet.Highcharts.Highcharts chart3 = new DotNet.Highcharts.Highcharts("chart3")
.InitChart(new Chart { PlotShadow = false })
.SetTitle(new Title { Text = "Demonstrativo das Despesas - Periodo de " + ini + " a " + fim + "." })
.SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }" })
.SetPlotOptions(new PlotOptions
{
Pie = new PlotOptionsPie
{
AllowPointSelect = true,
Cursor = Cursors.Pointer,
DataLabels = new PlotOptionsPieDataLabels
{
Color = ColorTranslator.FromHtml("#000000"),
ConnectorColor = ColorTranslator.FromHtml("#000000"),
Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }"
}
}
})
.SetSeries(new Series
{
Type = ChartTypes.Pie,
Name = "Browser share",
Data = new Data(new object[]
{
new object[] { chartValuesC[0], chartValuesV[0]},
new object[] { chartValuesC[1], chartValuesV[1]},
new object[] { chartValuesC[2], chartValuesV[2]}
})
});
return View(chart3);
}
else if (contador == 4)
{
DotNet.Highcharts.Highcharts chart3 = new DotNet.Highcharts.Highcharts("chart3")
.InitChart(new Chart { PlotShadow = false })
.SetTitle(new Title { Text = "Demonstrativo das Despesas - Periodo de " + ini + " a " + fim + "." })
.SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }" })
.SetPlotOptions(new PlotOptions
{
Pie = new PlotOptionsPie
{
AllowPointSelect = true,
Cursor = Cursors.Pointer,
DataLabels = new PlotOptionsPieDataLabels
{
Color = ColorTranslator.FromHtml("#000000"),
ConnectorColor = ColorTranslator.FromHtml("#000000"),
Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }"
}
}
})
.SetSeries(new Series
{
Type = ChartTypes.Pie,
Name = "Browser share",
Data = new Data(new object[]
{
new object[] { chartValuesC[0], chartValuesV[0]},
new object[] { chartValuesC[1], chartValuesV[1]},
new object[] { chartValuesC[2], chartValuesV[2]},
new object[] { chartValuesC[3], chartValuesV[3]}
})
});
return View(chart3);
}
else if (contador >= 5)
{
DotNet.Highcharts.Highcharts chart3 = new DotNet.Highcharts.Highcharts("chart3")
.InitChart(new Chart { PlotShadow = false })
.SetTitle(new Title { Text = "Demonstrativo das Despesas - Periodo de " + ini + " a " + fim + "." })
.SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }" })
.SetPlotOptions(new PlotOptions
{
Pie = new PlotOptionsPie
{
AllowPointSelect = true,
Cursor = Cursors.Pointer,
DataLabels = new PlotOptionsPieDataLabels
{
Color = ColorTranslator.FromHtml("#000000"),
ConnectorColor = ColorTranslator.FromHtml("#000000"),
Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }"
}
}
})
.SetSeries(new Series
{
Type = ChartTypes.Pie,
Name = "Browser share",
Data = new Data(new object[]
{
new object[] { chartValuesC[0], chartValuesV[0]},
new object[] { chartValuesC[1], chartValuesV[1]},
new object[] { chartValuesC[2], chartValuesV[2]},
new object[] { chartValuesC[3], chartValuesV[3]},
new object[] { chartValuesC[4], chartValuesV[4]}
})
});
return View(chart3);
}
else
{
TempData["1"] = "Demostrativo mensal de Despesas sem dados para o período selecionado!";
return View();
}