GoogleChartsを使用して美しいバブルチャートを作成しました。これがチャートのショットです:
x軸に沿った数字は、個々の顧客を表しています。y軸に沿った数字は、個々の製品を表しています。ご覧のとおり、約23の顧客と7つの製品があります。
問題は、X軸とY軸が数値にしかできないことです(ドキュメントからわかる限り)。代表的な整数だけでなく、軸に沿って顧客と製品の文字列値を表示できるようにしたいと思います。これにより、私たちが見ているものを理解しやすくなります。
誰かがこれをどのように達成できるか知っていますか?
顧客と製品の文字列を含むJS配列があります。それらの整数インデックスは、チャートに表示される数値に対応しています。例えば:
customers[6] = "Microsoft"
customers[7] = "Dell"
...
しかし、今は整数だけが表示されます。
どんな助けでも大歓迎です!ありがとう!
チャートを定義するために使用したコードは次のとおりです。
var options = {
'title':'Customer / Product Grid',
'width': 1000,
'height':500
};
//for customer product grid
var customer_product_grid_data_table = new google.visualization.DataTable();
customer_product_grid_data_table.addColumn('string', 'Customer and Product');
customer_product_grid_data_table.addColumn('number', 'Customer');
customer_product_grid_data_table.addColumn('number', 'Product');
customer_product_grid_data_table.addColumn('number', 'Profit Margin');
customer_product_grid_data_table.addColumn('number', 'Proportion of Sales');
for (var i = 1; i < customer_product_grid_data.length; i ++){
customer_product_grid_data_table.addRow([
'',
customer_product_grid_data[i][0],
customer_product_grid_data[i][1],
(customer_product_grid_data[i][3] - customer_product_grid_data[i][2]) / customer_product_grid_data[i][3] * 100,
customer_product_grid_data[i][3] / qnty_sell_total
]);
}
var chart = new google.visualization.BubbleChart(document.getElementById('customer_product_grid'));
chart.draw(customer_product_grid_data_table, options);