简体   繁体   中英

How to Control Highchart.js Dom Elements Through CSS Rules

Can you please take a look at this Demo and let me know How I can control CSS rules of Highchart element like Title or Back color? I know that Highchart is providing this with some internal properties and functions but I need to do this through CSS and Dom Manipulation , as well.

Here is a code That I tried to change the color of the Highchart Title:

.highcharts-title{color:red !important;}

but it didn't work!

Thanks

As far as I know, this is the preferred way to do it.

Demo http://jsfiddle.net/o7jrucf6/2/

    $('#container').highcharts({

    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 
            'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },
    title: {
         style: {
            color: 'red'          
         }            
      },

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }]



});

在此处输入图片说明

Highcharts uses SVG for drawing, so you'll need to use the proper SVG attribute . In your example above it's fill not color:

.highcharts-title{fill:red !important;}

Updated example .

You need to set useHTML flag in title, as true.

title:{ 
   text: 'any',
   useHTML: true
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM