yii框架结合charjs统计上一年与当前年数据的方法(2)
js
// 订单总量对比
var yearOrderCountChartCanvas = $('#yearOrderCountChart').get(0).getContext('2d')
var yearOrderCountChartData = {
labels : <?= json_encode($orderChar['labels'], true) ?>,
datasets: [
{
label : '<?= $orderChar['lastYear'] ?>',
backgroundColor : 'rgba(0, 192, 239, 0.5)',
data : <?= json_encode($orderChar['lastYearCounts'], true) ?>
},
{
label : '<?= $orderChar['currentYear'] ?>',
backgroundColor : 'rgba(0, 135, 239, 0.5)',
data : <?= json_encode($orderChar['currentYearCounts'], true) ?>
}
]
}
var yearOrderCountChartOptions = {
scales: {
xAxes: [{
gridLines: {
display: false
}
}],
yAxes: [{
gridLines: {
display: false
}
}]
}
}
var yearOrderCountChart = new Chart(yearOrderCountChartCanvas, {
type: 'line',
data: yearOrderCountChartData,
options: yearOrderCountChartOptions
});
// 支付订单总量对比
var yearOrderPayCountChartCanvas = $('#yearOrderPayCountChart').get(0).getContext('2d')
var yearOrderPayCountChartData = {
labels : <?= json_encode($orderChar['labels'], true) ?>,
datasets: [
{
label : '<?= $orderChar['lastYear'] ?>',
backgroundColor : 'rgba(0, 166, 90, 0.5)',
data : <?= json_encode($orderChar['lastYearPayCounts'], true) ?>
},
{
label : '<?= $orderChar['currentYear'] ?>',
backgroundColor : 'rgba(0, 166, 11, 0.5)',
data : <?= json_encode($orderChar['currentYearPayCounts'], true) ?>
}
]
}
var yearOrderPayCountChartOptions = {
scales: {
xAxes: [{
gridLines: {
display: false
}
}],
yAxes: [{
gridLines: {
display: false
}
}]
}
}
var yearOrderPayCountChart = new Chart(yearOrderPayCountChartCanvas, {
type: 'line',
data: yearOrderPayCountChartData,
options: yearOrderPayCountChartOptions
});
// 订单总额对比
var yearOrderAmountChartCanvas = $('#yearOrderAmountChart').get(0).getContext('2d')
var yearOrderAmountChartData = {
labels : <?= json_encode($orderChar['labels'], true) ?>,
datasets: [
{
label : '<?= $orderChar['lastYear'] ?>',
backgroundColor : 'rgba(0, 192, 239, 0.5)',
data : <?= json_encode($orderChar['lastYearAmounts'], true) ?>
},
{
label : '<?= $orderChar['currentYear'] ?>',
backgroundColor : 'rgba(0, 135, 239, 0.5)',
data : <?= json_encode($orderChar['currentYearAmounts'], true) ?>
}
]
}
var yearOrderAmountChartOptions = {
scales: {
xAxes: [{
gridLines: {
display: false
}
}],
yAxes: [{
gridLines: {
display: false
}
}]
}
}
var yearOrderAmountChart = new Chart(yearOrderAmountChartCanvas, {
type: 'line',
data: yearOrderAmountChartData,
options: yearOrderAmountChartOptions
});
// 支付订单总额对比
var yearOrderPayAmountChartCanvas = $('#yearOrderPayAmountChart').get(0).getContext('2d')
var yearOrderPayAmountChartData = {
labels : <?= json_encode($orderChar['labels'], true) ?>,
datasets: [
{
label : '<?= $orderChar['lastYear'] ?>',
backgroundColor : 'rgba(0, 166, 90, 0.5)',
data : <?= json_encode($orderChar['lastYearPayAmounts'], true) ?>
},
{
label : '<?= $orderChar['currentYear'] ?>',
backgroundColor : 'rgba(0, 166, 11, 0.5)',
data : <?= json_encode($orderChar['currentYearPayAmounts'], true) ?>
}
]
}
var yearOrderPayAmountChartOptions = {
scales: {
xAxes: [{
gridLines: {
display: false
}
}],
yAxes: [{
gridLines: {
display: false
}
}]
}
}
var yearOrderPayAmountChart = new Chart(yearOrderPayAmountChartCanvas, {
type: 'line',
data: yearOrderPayAmountChartData,
options: yearOrderPayAmountChartOptions
});
内容版权声明:除非注明,否则皆为本站原创文章。
