2017-05-25 83 views

回答

0

正如所说的WhiteHat,没有内置的选项。 对于我的特定情况下(我一直都在我的甘特图的结构相同),我做了以下(放置一些div上栏的顶端 - 这些资料核实,你可以做任何你想要的):

// callback after draw (afterDraw() function is called after chart is drawn) 

google.visualization.events.addListener(图表,'ready',afterDraw);

功能afterDraw(){

// the container element to append our generated DIVs (with the labels) 
    // it has to be outside the SVG element, but inside the chart container 
    var toContainer = $('#chart_div > div > div'); 

    // in order to create DIVs to place them on top of the bars, we first need to get bars SVG/RECTs positions and sizes 
    // in my case, the RECT elements with the necessary top/left/width/height are in the 6th G element 
    $("#chart_div g:eq(5) rect").each(function() { 
     toContainer.append("<div style='top:"+$(this).attr('y')+"px; left: "+$(this).attr('x')+"px; width: "+$(this).attr('width')+"px; height: "+$(this).attr('height')+"px;text-align: center;position:absolute;line-height:2' >Some text</div>"); 
    }); 

}