【问题标题】:Google Bar Graph Chart using php and mysql display will multi colors automatically?Google Bar Graph Chart 使用 php 和 mysql 显示会自动多色吗?
【发布时间】:2019-05-06 06:25:09
【问题描述】:

我需要像饼图这样的多色,如何在条形图中做到这一点?

<?php
$connect = mysqli_connect("localhost", "handsmec_sales", "handsmec_sales", "handsmec_sales_portal");  
$query2 = "SELECT DATE_FORMAT(order_datetime,'%m/%Y') as date, SUM(order_total_after_tax) as number FROM tbl_order where status='Confirmed' GROUP BY DATE_FORMAT(order_datetime,'%Y/%m')";  
$result2 = mysqli_query($connect, $query2); 
?>

<div id="Salesman" style="width: 650px; height: 500px;"></div>   

【问题讨论】:

    标签: javascript php mysql google-developers-console google-developer-tools


    【解决方案1】:

    您可以将 { role: 'style' } 添加到您的数据表中。对于您希望具有相同颜色的所有列,只需指定一个空样式 ''。然后,在您想要红色的列上,您可以指定 'red''#ff0000' 或 'color: red' 等。这里是参考link

    // example from Google
    var data = google.visualization.arrayToDataTable([
        ['Element', 'Density', { role: 'style' }],
        ['Copper', 8.94, '#b87333'],            // RGB value
        ['Silver', 10.49, 'silver'],            // English color name
        ['Gold', 19.30, 'gold'],
        ['Platinum', 21.45, 'color: #e5e4e2' ], // CSS-style declaration
    ]);
    

    【讨论】:

    • var data = google.visualization.arrayToDataTable([ ['Username', 'Total Sales'], ]);
    • var options = { title : 'Month & Yearly Total Sales Values', 'width':450, 'height':500, vAxis: {title: 'Total Sales'}, hAxis: {title : '月 & 年'}, seriesType: 'bars', series: {5: {type: 'line'}} }; var chart = new google.visualization.ComboChart(document.getElementById('Salesman')); chart.draw(数据,选项); }
    • 如何在 PHP 中给颜色
    猜你喜欢
    • 2013-06-22
    • 2017-11-28
    • 2010-12-15
    • 2012-10-11
    • 1970-01-01
    • 2012-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多