简体   繁体   English

Google可视化:节点的组织结构图背景色不起作用

[英]Google Visualization: Organizational Chart background color for Node not working

I'm using Google Org Chart to create an organisation chart and with different coloured boxes for each person. 我正在使用Google组织结构图创建组织结构图,并为每个人使用不同的彩色框。 However, I can't get either the 'style' or 'selectedStyle' to work in the data.setRowProperty for background-color. 但是,我无法在背景色的data.setRowProperty中使用“样式”或“ selectedStyle”。 It works for the border property. 它适用于border属性。 I'm new to javascript and google visualization so apologies if this is obvious. 我是javascript和google可视化的新手,所以很抱歉,如果这很明显。

<head>
    <script type='text/javascript' src='https://www.google.com/jsapi'></script>
    <script type='text/javascript'>
      google.load('visualization', '1', {packages:['orgchart']});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
      var data = new google.visualization.DataTable();
      data.addColumn('string', 'Name');
      data.addColumn('string', 'Manager');
      data.addColumn('string', 'ToolTip');
      data.addRows([
        [{v:'Row0', f:'Row0'}, '', 'The President'],
        [{v:'Row1', f:'Row1<div style="color:red; font-style:italic">Vice
                President</div>'}, 'Row0', 'VP'],
          ['Row2', 'Row0', ''],
          ['Row3', 'Row0', ''],
          ['Row4', 'Row0', ''],
          ['Row5', 'Row0', ''],
          ['Row6', 'Row1', 'Bob Sponge']
          ]);
// This works and puts a border round the node
        data.setRowProperty(3, 'style', 'border: 1px solid red');

// Neither of these work
        data.setRowProperty(4, 'style', 'background-color:red');
        data.setRowProperty(5, 'selectedStyle', 'background-color:red');

        var chart = new 
           google.visualization.OrgChart(document.getElementById('chart_div'));
        chart.draw(data, {allowHtml:true});
    }
    </script>
</head>
<body>
    <div id='chart_div'></div>
</body>
</html>

It is working correctly, problem is that the nodes have a background image property, so you do not see it as red. 它工作正常,问题在于节点具有背景图像属性,因此您不会将其视为红色。 So to be able to view the nodes red, you also need to set the background-image to none. 因此,要能够查看红色的节点,还需要将背景图像设置为none。 This should work: 这应该工作:

      data.setRowProperty(4, 'style', 'background-color:red;background-image:none');
      data.setRowProperty(5, 'selectedStyle', 'background-color:red;background-image:none');

您应该使用background:red而不是background-color:red

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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