0

我一直在尝试使用 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();
4

1 回答 1

0

我自己解决了。我所缺少的只是做一个new YAxisStackLabels

这是 SetYAxis 的代码:

                .SetYAxis(new YAxis 
                {               
                    StackLabels = new YAxisStackLabels 
                    { 
                        Enabled = true, Style = @"fontWeight: 'bold', color: 'black'" 
                    } 
                })
于 2014-03-07T11:54:36.740 回答