小编use*_*881的帖子

Chart.js Line,负点的不同填充颜色

当点为负时,我需要更改Line Chart.js中的填充颜色(内部区域).

代码简单而基本:

$(document).ready(function(){

  var ctx = $("#myChart").get(0).getContext("2d");

  var data = {
      labels: ["January", "February", "March", "April", "May", "June", "July"],
      datasets: [
          {
              label: "My First dataset",
              //fillColor : "rgba(60,91,87,1)",
              // String - the color to fill the area under the line with if fill is true
              backgroundColor: "rgba(75,192,192,0.4)",
              strokeColor : "rgba(60,91,87,1)",
              pointColor : "rgba(60,91,87,1)",
              pointStrokeColor : "#58606d",
              // The actual data
              data: [65, 59, 80, -81, 56, 55, -40],

              // String - If specified, binds the dataset to a …
Run Code Online (Sandbox Code Playgroud)

javascript background colors dataset chart.js

7
推荐指数
2
解决办法
7180
查看次数

标签 统计

background ×1

chart.js ×1

colors ×1

dataset ×1

javascript ×1