HighCharts之图表背景设置

 为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();


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值