最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to add a border to the title in highcharts - Stack Overflow

programmeradmin2浏览0评论

I want to add custom css rules to the title of a chart generated by highcharts. More precisely i am trying to add a backgound and a border. i tried several approaches however the most stable one is as follows;

 title: {
            style: {
                color: '#FF00FF',
                fontWeight: 'bold',
                background-color: 'green',
                border: '1px'
            }
        },

This code works for the color and weight of the font but other options do not work , i also tried (backgroundColor)

ex.=> .7.2/highslide-software/highcharts/tree/master/samples/highcharts/title/style/

I want to add custom css rules to the title of a chart generated by highcharts. More precisely i am trying to add a backgound and a border. i tried several approaches however the most stable one is as follows;

 title: {
            style: {
                color: '#FF00FF',
                fontWeight: 'bold',
                background-color: 'green',
                border: '1px'
            }
        },

This code works for the color and weight of the font but other options do not work , i also tried (backgroundColor)

ex.=> http://jsfiddle/gh/get/jquery/1.7.2/highslide-software/highcharts./tree/master/samples/highcharts/title/style/

Share Improve this question asked Nov 8, 2013 at 10:47 GunnitGunnit 1,0745 gold badges22 silver badges46 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

The problem is that SVG text elements doesn't have border property, so it can't be set. Solution then is to set useHTML:true for title, and render HTML tags instead. For example: http://jsfiddle/3bQne/668/

var chart = new Highcharts.Chart({
    chart: {
        renderTo: 'container'
    },
    title: {
        useHTML: true,
        style: {
            color: '#FF00FF',
            fontWeight: 'bold',
            'background-color': 'green',
            border: '1px solid black'
        }
    },
    xAxis: {
        categories: ['01/02/2012','01/03/2012','01/04/2012','01/05/2012','01/06/2012','01/07/2012'],
        labels: {
            rotation: -90,
            align: 'right'
        }
    },

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0]        
    }]
});
发布评论

评论列表(0)

  1. 暂无评论