Remove padding or margins from Google Charts

前端 未结 6 1926
礼貌的吻别
礼貌的吻别 2020-12-12 13:45



        
6条回答
  •  被撕碎了的回忆
    2020-12-12 14:03

    I arrived here like most people with this same issue, and left shocked that none of the answer even remotely worked.

    For anyone interested, here is the actual solution:

    ... //rest of options
    width: '100%',
    height: '350',
    chartArea:{
        left:5,
        top: 20,
        width: '100%',
        height: '350',
    }
    ... //rest of options
    

    The key here has nothing to do with the "left" or "top" values. But rather that the:

    Dimensions of both the chart and chart-area are SET and set to the SAME VALUE

    As an amendment to my answer. The above will indeed solve the "excessive" padding/margin/whitespace problem. However, if you wish to include axes labels and/or a legend you will need to reduce the height & width of the chart area so something slightly below the outer width/height. This will "tell" the chart API that there is sufficient room to display these properties. Otherwise it will happily exclude them.

提交回复
热议问题