需要几个月之间完整的高图表条形图

2023-12-09

我已经创建了高图表来完全满足我的要求,如附图所示,并且我在小提琴中尝试了下面的代码 fiddle中的示例代码如下

https://jsfiddle.net/vsLr07ak/

下面是我的代码

   Highcharts.chart('container', {
 chart: {
    type: 'column'
 },
 title: {
    text: 'HISTORICAL NEWS SENTIMENT'
 },
  yAxis: {
    title: {
        text: ''
    },
     labels: {
            enabled: false
        },
    min: -100,
    max: 100,
    tickInterval: 10,
    showLastdataLabel: true,
  },
  xAxis: {
    categories: ['26. Nov', '24. Dec', '21. Jan', '18. Feb', '18. March']
  },
  credits: {
    enabled: false
  },
  series: [{
    name: null,
    data: [15, 13, 14, 17, 12]

     }, {
    name: null,
    data: [12, -12, -13, 21, 11]
  }]
  });

Html代码如下

  <script src="https://code.highcharts.com/highcharts.js"></script>
  <script src="https://code.highcharts.com/modules/exporting.js">. 
  </script>
  <script src="https://code.highcharts.com/modules/export-data.js"></script>
  <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

但它显示每月 2 个栏,我希望它显示如下附图。

谁能帮我吗?

and I want my chart as shown in image chart image


代替category,你应该使用datetimexAxis 类型和定义x作为时间戳的值:

series: [{
    ...,
    data: [
        [17227780000, 15],
        [18523780000, 13],
        [19819780000, 14],
        [21115780000, 17],
        [22411780000, 12],
        [23707780000, 12],
        [25003780000, -12],
        [26299780000, -13],
        [27595780000, 21],
        [28891780000, 11]
    ]
}]

现场演示: https://jsfiddle.net/BlackLabel/83us07cx/

or use pointStart and pointInterval特性:

series: [{
    pointStart: 17227780000,
    pointInterval: 1000 * 60 * 60 * 24 * 15, // 15 days
    name: null,
    color: 'red',
    negativeColor: 'blue',
    data: [15, 13, 14, 17, 12, 12, -12, -13, 21, 11]
}]

现场演示: https://jsfiddle.net/BlackLabel/sqtha8xm/


API参考:

https://api.highcharts.com/highcharts/series.column.data

https://api.highcharts.com/highcharts/series.column.pointStart

https://api.highcharts.com/highcharts/series.column.pointInterval

https://api.highcharts.com/highcharts/series.column.negativeColor

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

需要几个月之间完整的高图表条形图 的相关文章

随机推荐