ฉันได้สร้างแผนภูมิแท่งโดยใช้ Google Charts นี่คือแผนภูมิหลัก
ฉันได้ลองทำให้แผนภูมิแท่งเปลี่ยนสีและเพิ่มข้อมูลคำแนะนำเครื่องมือเพิ่มเติม เพื่อให้คำแนะนำเครื่องมือแสดงข้อมูลเพิ่มเติมอีกเล็กน้อย
ฉันได้อ่านเอกสารของ Google แล้ว และฉันไม่เห็นสิ่งที่ฉันทำผิด
เพื่อให้อ่านง่าย นี่คือผลลัพธ์ของโค้ดของฉันในแหล่งที่มา
google.charts.load("current", {packages:['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var exams = [["Date", "Score",({type: 'string', role: 'tooltip'})], ["18 Oct", 39,"TEST"], ["26 Oct", 20,"TEST"], ["26 Oct", 0,"TEST"], ["27 Oct", 0,"TEST"], ["27 Oct", 0,"TEST"]];
if(exams.length > 1){
var data = google.visualization.arrayToDataTable(exams);
var view = new google.visualization.DataView(data);
view.setColumns([0, 1]);
var options = {
title: "Results",
width: 1170,
height: 700,
bar: {groupWidth: "95%"},
legend: { position: "none" }
};
var chart = new google.visualization.ColumnChart(document.getElementById("columnchart_values"));
chart.draw(view, options);
}
else{
$("#columnchart_values").html('No Data found to show graph');
}
}
นี่คือเอกสารของ Google ที่ฉันได้ติดตาม ซึ่งแตกต่างไปจากของฉันเล็กน้อยเนื่องจากฉันได้รับข้อมูลจากฐานข้อมูล แต่ควรให้ผลลัพธ์เดียวกัน
ฉันได้ดูตัวอย่างมากมายและกำลังทำซ้ำให้ใกล้เคียงที่สุดเท่าที่จะทำได้แต่ไม่มีโชคเลย
https://developers.google.com/chart/interactive/docs/customizing_tooltip_content
ฉันยังมีปัญหาเดียวกันกับสีด้วย ฉันไม่สามารถรับสีบนแผนภูมิแท่งเพื่อเปลี่ยนทั้งคู่ที่มีปัญหาเดียวกันจนไม่ได้ทำอะไรเลย
ฉันพลาดอะไรไปรึเปล่า??