javascript - highcharts 带有 x 和 y 值的面积图?

标签 javascript highcharts stacked-area-chart

我尝试使用面积图创建此图表,但无法使其工作:enter image description here

这是 jsfiddle :http://jsfiddle.net/okc8q0zn/

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'area'
        },
        xAxis: {
            categories: [67,69]
        },
        credits: {
            enabled: false
        },
        series: [ {
            name: '67',
            data: [24,24],
            color: '#0F0'
        }, {
            name: '69',
            data: [ 17,17],
             color: '#00F'
        }]
    });
});

谢谢。

最佳答案

您将需要自定义xAxisyAxis以仅显示所需的值以及对系列的一些修改,如下所示:

xAxis: {
  max: 80,
  tickInterval: 1,
  tickWidth: 0,
  labels: {
    step: 1,
    formatter: function() {
      if (this.value === 67 || this.value === 69) {
        return this.value;
      }
    }
  }
},
yAxis: {
  max: 30,
  tickInterval: 1,
  tickWidth: 0,
  gridLineWidth:0,
  labels: {
    step: 1,
    formatter: function() {
      if (this.value === 17 || this.value === 24) {
        return this.value;
      }
    }
  }
},
series: [{
  name: '67',
  data: [{
    x: 0,
    y: 17
  }, {
    x: 69,
    y: 17
  }],
  color: 'rgba(30,80,250,0.5)'
}, {
  name: '69',
  data: [{
    x: 0,
    y: 24
  }, {
    x: 67,
    y: 24
  }],
  color: 'rgba(250,250,50,0.3)'
}]

Fiddle

关于javascript - highcharts 带有 x 和 y 值的面积图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55557951/

相关文章:

javascript - 如何根据 JavaScript 中包含对象的属性值对关联对象进行排序

javascript - 将电话号码前缀的正则表达式限制为两个数字

javascript - (angular2-highcharts) 静态解析符号值时遇到错误中的错误

javascript - highcharts:类型错误:无法读取未定义的属性 '0'

javafx - 更改不同值的图表颜色

javascript - Magento2 部署 CSS/JS

javascript - 如何从 Angular Component 获取环境为 "Library"?

javascript - 自定义工具提示,使烛台保持原样

r - geom_area 不堆叠(ggplot)

r - 在R中获取堆积面积图