2017-01-02 77 views
-1

如何使用Highcharts在折线图中添加背景框?Highcharts背景选项

类型:折线图

enter image description here

+2

使用网格线和次要网格线http://jsfiddle.net/g26xwgzp/。有关更多选项,请参阅API http://api.highcharts.com/highcharts/yAxis.minorGridLineWidth – morganfree

+0

感谢Morgon。我尝试使用minorGridLineColor选项,但它只显示yAxis行而不是x轴。冷杉x轴我使用gridLineWidth:1选项,但它的水平线。但箱宽将是巨大的,它不能满足我的要求。 xAxis:{gridLineWidth:1},yAxis:{minorGridLineColor:'#E0E0E0'​​,minorGridLineWidth:2,minorTickLength:0,minorTickInterval:'auto'} – rafik

+0

您必须为两个轴 - xAxis和yAxis设置小网格线。看看我在上面的评论中发布的小提琴。 – morganfree

回答

0

您可以通过enabling plot lines for both x和y轴添加这种背景图表的绘图区。

xAxis:[{ 
    gridLineWidth: 1 
}] // for yAxis grid lines are visible by default 

演示:http://jsfiddle.net/0md5s7cz/

或者你可以为background of a chart's plot area设置图像。

chart: { 
    plotBackgroundImage: 'https://i.stack.imgur.com/BBTab.png' 
}, 

演示:http://jsfiddle.net/4wLvu94s/1/

+0

感谢您的快速响应。其实我不想添加背景图片。使用gridLineWidth选项我尝试过,但框的大小很大。其实我正在寻找我在附件中分享的小盒子。 – rafik

+0

@rafik在这种情况下,请在您的问题下看到** morganfree **的评论 - minorGridLine应该是您的解决方案。 –

+0

谢谢Kacper。我尝试使用minorGridLineColor选项,但它只显示yAxis行而不是x轴。冷杉x轴我使用gridLineWidth:1选项,但它的水平线。但箱宽将是巨大的,它不能满足我的要求。 x轴:{ gridLineWidth:1 }, YAXIS:{ minorGridLineColor: '#E0E0E0'​​, \t minorGridLineWidth:2, minorTickLength:0, 会将minorTickInterval: '自动' } – rafik