Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Charts 您好,我看到堆叠折线图中有一个问题,如果有负数和正数,它们不会堆叠在一起,是否要将它们堆叠在一起?_Charts - Fatal编程技术网

Charts 您好,我看到堆叠折线图中有一个问题,如果有负数和正数,它们不会堆叠在一起,是否要将它们堆叠在一起?

Charts 您好,我看到堆叠折线图中有一个问题,如果有负数和正数,它们不会堆叠在一起,是否要将它们堆叠在一起?,charts,Charts,在chartjs中,有没有一种方法可以在折线图中叠加正数和负数?问题是,Nactive number与正数iam叠加,添加了一个适用于正数叠加的代码,但如果将其中一个值更改为Nactive number,您将看到将alink添加到codepen也不起作用 var ctx = document.getElementById("myChart").getContext("2d"); const colors = { green: { fill:

在chartjs中,有没有一种方法可以在折线图中叠加正数和负数?问题是,Nactive number与正数iam叠加,添加了一个适用于正数叠加的代码,但如果将其中一个值更改为Nactive number,您将看到将alink添加到codepen也不起作用

var ctx = document.getElementById("myChart").getContext("2d");

const colors = {
  green: {
    fill: '#e0eadf',
    stroke: '#5eb84d',
  },
  lightBlue: {
    stroke: '#6fccdd',
  },
  darkBlue: {
    fill: '#92bed2',
    stroke: '#3282bf',
  },
  purple: {
    fill: '#8fa8c8',
    stroke: '#75539e',
  },
};

const loggedIn = [26, 36, 42, 38, 40, 30, 12];
const available = [34, 44, 33, 24, 25, 28, 25];
const availableForExisting = [16, 13, 25, 33, 40, 33, 45];
const unavailable = [5, 9, 10, 9, 18, 19, 20];
const xData = [13, 14, 15, 16, 17, 18, 19];

const myChart = new Chart(ctx, {
  type: 'line',
  data: {
    labels: xData,
    datasets: [{
      label: "Unavailable",
      fill: true,
      backgroundColor: colors.purple.fill,
      pointBackgroundColor: colors.purple.stroke,
      borderColor: colors.purple.stroke,
      pointHighlightStroke: colors.purple.stroke,
      borderCapStyle: 'butt',
      data: unavailable,

    }, {
      label: "Available for Existing",
      fill: true,
      backgroundColor: colors.darkBlue.fill,
      pointBackgroundColor: colors.darkBlue.stroke,
      borderColor: colors.darkBlue.stroke,
      pointHighlightStroke: colors.darkBlue.stroke,
      borderCapStyle: 'butt',
      data: availableForExisting,
    }, {
      label: "Available",
      fill: true,
      backgroundColor: colors.green.fill,
      pointBackgroundColor: colors.lightBlue.stroke,
      borderColor: colors.lightBlue.stroke,
      pointHighlightStroke: colors.lightBlue.stroke,
      borderCapStyle: 'butt',
      data: available,
    }, {
      label: "Logged In",
      fill: true,
      backgroundColor: colors.green.fill,
      pointBackgroundColor: colors.green.stroke,
      borderColor: colors.green.stroke,
      pointHighlightStroke: colors.green.stroke,
      data: loggedIn,
    }]
  },
  options: {
    responsive: false,
    // Can't just just `stacked: true` like the docs say
    scales: {
      yAxes: [{
        stacked: true,
      }]
    },
    animation: {
      duration: 750,
    },
  }
});