aks*_*and 5 javascript php mysql charts chart.js
我使用Chart.js v2.6输出饼图.数据从MySQL数据库获得.图表正确呈现,但我需要向数据值添加箭头,如下面的屏幕截图所示.
带箭头的示例饼图:
下面是我使用Chart.js输出饼图的代码:
var chartdata_order_status = {
labels: status,
datasets: [{
label: 'Order status',
backgroundColor: ["#00b0f0","#92d050","#ffc000","#ff6dd9"],
data: count_status
}]
};
var pieGraph = new Chart(ctx3, {
type: 'pie',
data: chartdata_country_orders,
options: {
pieceLabel: {
mode: 'value',
position: 'outside',
fontColor: '#000',
format: function (value) {
return '$' + value;
}
},
title: {
display: true,
text: 'Total Sales by Country - Top 5',
fontSize: 15,
fontStyle: 'bold'
},
legend: {
display: true,
position: 'bottom',
},
}
});
Run Code Online (Sandbox Code Playgroud)
我没有包含用于从MySQLtable获取数据的PHP代码.
Saj*_*ran 10
您现在可以Chart.PieceLabel.js
在 slices.s 之外使用和获取标签,
演示
angular.module("app", ["chart.js"]).controller("ChartCtrl", function($scope) {
$scope.labels = ["January", "February", "March", "April", "May", "June", "July"];
$scope.data = [65, 59, 80, 81, 56, 55, 40];
$scope.options = {
pieceLabel: {
render: 'label',
fontColor: '#000',
position: 'outside',
segment: true
}
};
});
Run Code Online (Sandbox Code Playgroud)
angular.module("app", ["chart.js"]).controller("ChartCtrl", function($scope) {
$scope.labels = ["January", "February", "March", "April", "May", "June", "July"];
$scope.data = [65, 59, 80, 81, 56, 55, 40];
$scope.options = {
pieceLabel: {
render: 'label',
fontColor: '#000',
position: 'outside',
segment: true
}
};
});
Run Code Online (Sandbox Code Playgroud)