这是我的代码:

public ActionResult SeriesWinsChart()
    {
        Highcharts chart = new Highcharts("chart")
            .InitChart(new Chart { PlotShadow = false })
            .SetTitle(new Title { Text = "Series Wins" })
            .SetCredits(new Credits { Enabled = false })
            //.SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.y; }" })
            .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.y; }"
                    }
                }
            })
            .SetSeries(new Series
            {
                Type = ChartTypes.Pie,
                Name = "Series Wins",
                Data = new Data(new object[]
                {
                    new object[] { "Test1", db.Teams.Where(x => x.TeamName == "Team1").Sum(x => x.SeriesWins)},
                    new object[] { "Test2", db.Teams.Where(x => x.TeamName == "Team2").Sum(x => x.SeriesWins)}
                })

            });

        return View(chart);
    }


这是在部分视图中呈现的..因此,我的代码仅为:

@model DotNet.Highcharts.Highcharts


@(Model)


我已经对此主题进行了研究,但是它处理的是JS,我知道HighCharts会用到它,但是我可以在ActionResult中更改标题的样式,字体大小吗?

最佳答案

在您的SetTitle()函数中,您可以按如下方式传递CSS,例如字体,颜色等:

.SetTitle(new Title { Text = "Series Wins", Style = "font: 'normal 14px Verdana, sans-serif',color : 'red'" })


让我知道是否有帮助!

09-26 04:40