【发布时间】:2019-10-10 00:36:29
【问题描述】:
我正在使用这个金字塔图。 https://canvasjs.com/php-charts/pyramid-chart/ 数组可以点击吗?比如数组是这样的
$dataPoints = array (
array ("label" => "www.google.com", "y" => 8531),
array ("label" => "www.yahoo.com", "y" => 4550),
array ("label" => "www.facebook.com", "y" => 4395)
)
这是我尝试过的.. 我点击的每一行都需要一个不同的链接。但是这个 window.location 唯一的作用是每次我点击任何位置时都会转到同一个链接
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
title: {
text: "Order Fulfillment"
},
data: [{
click: function (e) {
window.location = 'https://www.google.com';
},
type: "pyramid",
indexLabel: "{label} - {y}",
yValueFormatString: "#,##0",
dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
}]
});
chart.render();
}
【问题讨论】:
标签: javascript php arrays canvas