javascript - 如何为画布标签赋予样式?
问题描述
我有一个用 javascript 和 canvas 标签制作的图表。但我不能给图表提供css。我想要做的是改变轴的 dataPoints 的颜色(X 和 Y 轴的数据编号)
这是我的javascript代码;
<script>
var xValues = {{past_data1|safe}} ;
var yValues={{past_data2|safe}}
new Chart("myChart-bottom", {
type: "line",
data: {
labels: xValues,
datasets: [{
data: yValues,
labelFontColor: "green",
borderColor: "red",
fill: false,
}]
},
options: {
legend: {display: false}
}
});
</script>
这也是我的画布标签的html代码;
<canvas id="myChart-bottom" style="width: 90%; max-width:600px; margin-top: 10px;
border-style: solid; border-color: grey; padding-top: 20px; padding-right: 20px; border-radius: 10px;
background-color: dark-grey"></canvas>
'labelFontColor: "green"' 部分实际上不起作用。那么我该怎么做才能给线条上的 dataPoints 赋予颜色呢?
解决方案
推荐阅读
- python - 给定地址的本地日期时间
- php - 即使值确实存在,in_array() 也不起作用
- android - 将 build compileSdkVersion 升级到 30 后无法确定是否安装了应用
- python - Python-我需要我的程序来计算掷出 2 个骰子的每个结果发生了多少次。(2-12 是可能的结果)
- apache-spark - 使用 Dask 和 pyarrow-dataset 引擎读取 Spark 编写的分区 parquet 数据集
- python - 在 2 个字符串之间更改 int
- javascript - 如何在 Xamarin 中使用 AI 模型
- laravel - 使用laravel和inertiaJs上传文件更新数据时加载响应数据失败
- docker - 执行 docker run 后容器启动时运行 .sh 脚本
- javascript - 将 TypeScript 类型打印到控制台/文件中