我一直在尝试使用dotnethighcharts库制作一些图表。我设法制作了一些图表,但是当我尝试用StackLabels制作图表时,我收到了这个错误: “System.NullReferenceException:对象引用未设置为对象的实例”。
我的代码有什么问题,或者这是DotNet.Highchart中的错误? 我错过了什么吗?
任何信息都表示赞赏。
提前致谢。
这是我的代码:
Series serie1 = new Series { Name = "Person1", Stack = "1", Data = new Data(Fetch_Value1Data_From_GoalData()) };
Series serie2 = new Series { Name = "Person2", Stack = "1", Data = new Data(Fetch_Value1Data_From_GoalData()) };
Series serie3 = new Series { Name = "Person3", Stack = "2", Data = new Data(Fetch_Value1Data_From_GoalData()) };
Series serie4 = new Series { Name = "Person4", Stack = "2", Data = new Data(Fetch_Value1Data_From_GoalData()) };
Highcharts chart2 = new Highcharts("Chart2")
.InitChart(new Chart { Height = 300, Width = 400, Type = ChartTypes.Column })
.SetYAxis(new YAxis { StackLabels = { Enabled = true } })
.SetSeries(new Series[] { serie1, serie2, serie3, serie4 })
.SetPlotOptions(new PlotOptions
{
Column = new PlotOptionsColumn
{
Stacking = Stackings.Normal,
}
});
ltrChart1.Text = chart2.ToHtmlString();
答案 0 :(得分:0)
我自己解决了。我所缺少的只是制作一个new YAxisStackLabels
以下是SetYAxis的代码:
.SetYAxis(new YAxis
{
StackLabels = new YAxisStackLabels
{
Enabled = true, Style = @"fontWeight: 'bold', color: 'black'"
}
})