[英]Change Style of Title in HighCharts in ActionResult
Here is my code: 这是我的代码:
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);
}
This is rendering in a partial View.. so my code for that is just: 这是在部分视图中呈现的..因此,我的代码仅为:
@model DotNet.Highcharts.Highcharts
@(Model)
I have done research on this topic but it deals with JS which I know is what HighCharts runs off of, but am I able to change the style, font-size of the title within the ActionResult? 我已经对该主题进行了研究,但是它处理的是JS,我知道HighCharts会从中运行,但是我可以在ActionResult中更改标题的样式,字体大小吗?
In your SetTitle() function you can pass css like font, color etc. as follows : 在您的SetTitle()函数中,您可以按如下方式传递CSS,例如字体,颜色等:
.SetTitle(new Title { Text = "Series Wins", Style = "font: 'normal 14px Verdana, sans-serif',color : 'red'" })
Let me know if it helps! 让我知道是否有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.