您的位置:首页 > 其它

HighCharts之图表背景设置

2016-05-10 19:29 274 查看
 为HighCharts设置XAxis的PlotBands属性,全部代码如下:
Highcharts chart = new Highcharts("HC" + divName)
.InitChart(new Chart
{
DefaultSeriesType = CT_type,
Width = _width,
Height = _height,
ClassName = _Title,
BackgroundColor = null
}).SetCredits(new Credits { Enabled = false })
.SetTitle(new Title
{
Text = _Title
})
.SetXAxis(new XAxis
{
Title = new XAxisTitle { Text = "单位:" + unitName },
Categories = xCategoryList.ToArray(),
Reversed = false,
Opposite = false,
PlotBands = new[]{
new XAxisPlotBands{
Color=ColorTranslator.FromHtml("#FCFFC5"),
From=7,
To=12,
Label=new XAxisPlotBandsLabel {Text="上午工作时间"}
},
new XAxisPlotBands{
Color=ColorTranslator.FromHtml("#FCFFC5"),
From=13,
To=18,
Label=new XAxisPlotBandsLabel {Text="下午工作时间"}
}
}
})
.SetYAxis(new YAxis
{
Title = new YAxisTitle { Text = "单位:" + SeriesUnit },
Min = 0,
PlotLines = new[]
{
new YAxisPlotLines
{
Value = 0,
Width = 1,
Color = ColorTranslator.FromHtml("#808080")
} }
})
.SetTooltip(new Tooltip
{
Formatter = ToolTip_info,
ValueDecimals = 2
})
.SetPlotOptions(new PlotOptions
{
Column = new PlotOptionsColumn
{
BorderWidth = 2,
BorderColor = ColorTranslator.FromHtml("#edc240")
}
})
.SetLegend(new Legend
{
Enabled = false
})
.SetSeries(new[]
{
new Series { Name ="", Data = new Data(yDataSeriesList.ToArray()),Color=ColorTranslator.FromHtml("#f5e2a7")}
}
);
return chart.ToHtmlString();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: