Google Charts: Pie Chart title position

后端 未结 3 1614
没有蜡笔的小新
没有蜡笔的小新 2021-01-13 03:59

I was assigned to implement some Charts, and the bosses requested me to separate the title of the chart from the Chart, I tried to move the chart\'s area a little from the t

3条回答
  •  广开言路
    2021-01-13 04:28

    It's annoyed when Google did provide title position but with jQuery, you can do it

    $("#YOUR_GRAPH_WRAPPER svg text").first()
     .attr("x", (($("#time-series-graph svg").width() - $("#YOUR_GRAPH_WRAPPER svg text").first().width()) / 2).toFixed(0));
    

    Basically, you want to access the first text tag which is your chart title and change value of x attribute. To center it, take svg width (your graph width) subtract by title widtch, then divide by 2 :) Happy hacking :)

提交回复
热议问题