C3 JS-时间序列刻度反转格式

C3 JS - time series tick reverses the format

本文关键字:格式 JS- 时间序列 C3      更新时间:2023-09-26

我有一个c3时间表,配置如下:

const labels = ['labels',
  ...map(
    (d) => d.format('L'),
    pluck('date')(data)
  )
]
const initial = [
  labels,
  [facetName, ...pluck('count')(data)]
]
const settings = {
  axis: {
    x: {
      tick: {
        multiline: false,
        rotate: 75,
      },
      type: 'timeseries'
    },
    y: {
      tick: {
        format: d3.format(',')
      }
    }
  },
  bar: {width: { ratio: 0.5 }},
  data: {
    colors: {x: 'rgb(185, 221, 147)'},
    columns: initial,
    type: 'bar',
    x: 'labels',
    xFormat: '%m/%d/%Y'
  },
  grid: {y: { show: true }},
  legend: { show: false }
}

理想情况下,标签最终应显示为1/1/2000。相反,它们以2000/1/1的形式出现。格式中缺少什么?

在轴声明中使用format选项。http://c3js.org/reference.html#axis-x-tick格式

axis: {
    x: {
          tick: {
            multiline: false,
            rotate: 75,
            format: '%d/%m/%Y', // NEW LINE
          },
          type: 'timeseries'
        },
    ... etc