我正在使用 Google Charts 使用從 Mysql 數(shù)據(jù)庫獲取的數(shù)據(jù)創(chuàng)建一個(gè)簡(jiǎn)單的條形圖。圖表顯示正確,但我無法設(shè)置圖表標(biāo)題的格式。我參考過很多網(wǎng)站,我確信“titleTextStyle”的語法沒問題。但是標(biāo)題根本不會(huì)隨著選項(xiàng)而改變。有人可以告訴我問題出在哪里嗎?我在下面附上了我的完整代碼。提前致謝。<?php include("toconnect.php"); $result = mysqli_query($connection,"SELECT Product_name,COUNT(*) FROM Items_Sold GROUP BY Product_name");?><!DOCTYPE html><html> <head> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['bar']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Product Name', 'Frequency'], <?php if(mysqli_num_rows($result) > 0){ while($row = mysqli_fetch_array($result)) { echo "['".$row["Product_name"]."','".$row["COUNT(*)"]."'],"; } } ?> ]); var options = { chart: { title: "Frequently Bought items",titleTextStyle:{ color: '#007DB0',fontName: "Times",fontSize: 60,bold: true}, } }; var chart = new google.charts.Bar(document.getElementById('columnchart_material')); chart.draw(data, google.charts.Bar.convertOptions(options)); } </script> </head> <body> <div id="columnchart_material" style="width: 800px; height: 500px;display:inline-block;"></div> </body></html>
1 回答

料青山看我應(yīng)如是
TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超8個(gè)贊
您正在使用材料圖表...
google.charts.Bar
可以在此處找到 在材料圖表中不起作用的功能列表...
包括...
titleTextStyle
嘗試使用經(jīng)典圖表代替...
google.visualization.ColumnChart
有選項(xiàng)...
theme: 'material'
- 1 回答
- 0 關(guān)注
- 91 瀏覽
添加回答
舉報(bào)
0/150
提交
取消