我使用图表,Chart.js并使用额外的插件chartjs-plugin-annotation.js。以下是此代码的示例:
https://codepen.io/compwright/pen/mmQMrZ
我想在线上应用阴影。我假设你可以使用:
ctx.shadowColor = "#000"
ctx.shadowBlur = 3
ctx.shadowOffsetX = 2
ctx.shadowOffsetY = 3
谁能说怎么做?
您可以使用以下插件:
https://nagix.github.io/chartjs-plugin-style/
示例代码供参考:
var ctx = document.getElementById('canvasId').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: ["a", "b", "c", "d", "e" ],
datasets: [{
data: ["10", "11", "12", "1", "5"],
shadowOffsetX: 2,
shadowOffsetY: 4,
shadowBlur: 5,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}]
},
});