Is there a way to disable the Title and Subtitle i

2020-02-20 05:35发布

I'm just going to hardcode it in using html that is around the graph, I don't want to use the built in.

I don't see a "disable: true" option in the API.

Can anybody help me out here.

How do you disable the title / subtitle in highcharts?

(if you simply leave the text blank it still carves out a whitespace in that spot where the title is, i'd like to not have this happen)

标签: highcharts
13条回答
一纸荒年 Trace。
2楼-- · 2020-02-20 06:03

For those that use Typescript you can set the Highcharts.TitleOptions to hide the chart title.

title: {
  text: undefined
},
subtitle: {
  text: undefined
}
查看更多
家丑人穷心不美
3楼-- · 2020-02-20 06:05

It´s simple... Only set the title´s text to null. Like this

    $(function () {
$('#container').highcharts({
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },
    title: {
        text: null  
    },
    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]        
    }]
});

});

see@APIreference: http://api.highcharts.com/highcharts#title.text

查看更多
何必那么认真
4楼-- · 2020-02-20 06:06

From the highcharts doc:

text: String The title of the chart. To disable the title, set the text to null. Defaults to Chart title.

fiddle: http://jsfiddle.net/daub10dr/

title:{
      text: null
      }
查看更多
狗以群分
5楼-- · 2020-02-20 06:06

This is a bit of a hack but you can also try that:

title: {
    text: '<span class="hidden">My custom Hello</span>',
    align:"left",
    useHTML:true
}
查看更多
劳资没心,怎么记你
6楼-- · 2020-02-20 06:09

Set the text field to null

From the documentation at http://api.highcharts.com/highcharts#title.text

text: String

The title of the chart. To disable the title, set the text to null. Defaults to Chart title.

查看更多
SAY GOODBYE
7楼-- · 2020-02-20 06:10

You can always do this:

chart:{
    marginTop: 30
}

title:{
    text: ''
}

That worked for me :-)

note: this answer was for version 2.*, for newer versions there are better answers.

查看更多
登录 后发表回答