gpt4 book ai didi

javascript - 在 ActionResult 中更改 HighCharts 中的标题样式

转载 作者:行者123 更新时间:2023-11-30 16:11:39 27 4
gpt4 key购买 nike

这是我的代码:

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);
}

这是在部分 View 中呈现的。所以我的代码只是:

@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'" })

如果有帮助,请告诉我!

关于javascript - 在 ActionResult 中更改 HighCharts 中的标题样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36157276/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com