【问题标题】:How to convert Gregorian or Timestamp date to persian date in the Higcharts in angular如何在角度的 Highcharts 中将公历或时间戳日期转换为波斯日期
【发布时间】:2021-12-02 19:51:05
【问题描述】:

我希望在 Highcharts 图表上以波斯语显示日期。 我知道您可以使用 jalali-moment 将日期转换为正常日期。有没有办法在 Highcharts 中做到这一点? 我使用 Angular 12 和 Highcharts 9。

 Highcharts.chart('lineChart', {

  chart: {
    scrollablePlotArea: {}
  },

  xAxis: {
    type: 'datetime',
    gridLineWidth: 1,
    labels: {
      align: 'left',
      x: 3,
      y: -3
    }
  },

  yAxis: [{
    title: {
      text: null
    },
    showFirstLabel: false
  }],
  series: [{
    type: 'line',
    data: [
      [
        1633209533000,
        3
      ],
      [
        1635796087000,
        3
      ],
      [
        1635882487000,
        6
      ],
      [
        1636055287000,
        4
      ],
      [
        1638466033000,
        8
      ],
      [
        1638479933000,
        6
      ]
    ]
  }]
});

【问题讨论】:

    标签: angular date charts farsi


    【解决方案1】:

    您可以使用 Highcharts dateFormatsjalali-moment

    Use this link to install jalali-moment

    在 Highcharts 选项中使用 Highcharts.dateFormats

    >   chartDateFormat() {
        Highcharts.dateFormats.a = (ts) => {
          return moment(ts).locale('fa').format('dddd');
        };
        Highcharts.dateFormats.A = (ts) => {
          return moment(ts).locale('fa').format('dddd');
        };
        Highcharts.dateFormats.d = (ts) => {
          return moment(ts).locale('fa').format('DD');
        };
        Highcharts.dateFormats.e = (ts) => {
          return moment(ts).locale('fa').format('D');
        };
        Highcharts.dateFormats.b = (ts) => {
          return moment(ts).locale('fa').format('MMMM');
        };
        Highcharts.dateFormats.B = (ts) => {
          return moment(ts).locale('fa').format('MMMM');
        };
        Highcharts.dateFormats.m = (ts) => {
          return moment(ts).locale('fa').format('MM');
        };
        Highcharts.dateFormats.y = (ts) => {
          return moment(ts).locale('fa').format('YY');
        };
        Highcharts.dateFormats.Y = (ts) => {
          return moment(ts).locale('fa').format('YYYY');
        };
        Highcharts.dateFormats.W = (ts) => {
          return moment(ts).locale('fa').format('ww');
        };
      }
    

    From this link, you can view the codes online

    【讨论】:

      猜你喜欢
      • 2023-03-30
      • 2019-07-17
      • 1970-01-01
      • 1970-01-01
      • 2021-04-29
      • 2014-09-19
      • 1970-01-01
      • 2016-06-04
      相关资源
      最近更新 更多