【问题标题】:Morris Chart space between name in "data:"“数据:”中名称之间的莫里斯图表空间
【发布时间】:2021-12-02 22:31:48
【问题描述】:

我正在寻找一种方法来中断显示名称,但对我来说这似乎是不可能的。 我是正确的?我的意思是数据属性:[{}]

例如,我需要一个 空格 在名称中:link nameA/B,我不想使用 link_nameA

       Morris.Area({
      element: 'myfirstchart',
      data: [{
          date: '2021-10-19',
          link nameA: 2,
          link nameB: 3,
          extra: 0
        },
        {
          date: '2021-10-20',
          link nameA: 5,
          link nameB: 4,
          extra: 0
        }
      ],
      xkey: 'date',
      ykeys:  ['link nameA', 'link nameB', 'extra'],
      xLabels: 'day',
      labels: ['link nameA', 'link nameB', 'extra'],
      pointSize: 3,
      fillOpacity: 0,
      pointStrokeColors: ['#00bfc7', '#00bfc7', '#9675ce'],
      behaveLikeLine: true,
      gridLineColor: '#e0e0e0',
      lineWidth: 3,
      hideHover: 'auto',
      lineColors: ['#0bc36e', '#00bfc7', '#9675ce'],
      dateFormat: function(date) {
        d = new Date(date);
        return d.getDate() + '/' + (d.getMonth() + 1) + '/' + d.getFullYear();
      },
      resize: true
    });

有什么方法可以满足我的需求吗?因为使用空格脚本将无法正常工作。

谢谢。

【问题讨论】:

    标签: morris.js


    【解决方案1】:

    在 JavaScript 中,如果键包含在引号中,则对象键可以包含空格。

    const data = {
      "link nameA": "foobar",
    }
    console.log(data['link nameA'])

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多