【问题标题】:ExtJS 6 How to redner date on chartExtJS 6 如何在图表上呈现数据
【发布时间】:2017-07-26 11:58:29
【问题描述】:

请告诉我如何在图表上显示日期?在 x 轴上,id 喜欢以“m-d”格式显示日期。

告诉我请热一下。 不幸的是,我的图表在附件中显示了类似“Y-m-d h-i-s”的日期。

 axes: [{
                        type: 'numeric',
                        position: 'left',
                        grid: true
                    },
                    {
                        type: 'time',
                        position: 'bottom',
                        visibleRange: [0, 1],
                    }

                ],

                series: [{
                    type: 'line',
                    highlight: true,
                    xField: 'date',
                    yField: ['count'],
                    title: ['Настройка из ЛК штук'],
                      // Отображение подсказки при наводке на график
                    tooltip: {
                        trackMouse: true,
                        renderer: function(tip, item) {
                            // Определяем день и месяц для их корректного отображения в tip
                            var date = new Date(item.get('date'));
                            var day = date.getDate();
                            // Прибавляем к месяцу 1 , т.к getMonth почемуто возвращает на месяц меньше
                            var month = date.getMonth() + 1;
                            tip.setTitle('Количество:  ' + item.get('count') + ' шт.');
                            tip.update('Дата: ' + day + "." + month);
                        }
                    }
                }]

【问题讨论】:

    标签: extjs extjs6 extjs6-classic


    【解决方案1】:

    您应该将dateFormat 轴配置设置为“Y-m-d h-i-s”。

    【讨论】:

    • 谢谢。我添加了这个并且没问题axes: [{ type: 'numeric', position: 'left', grid: true }, { type: 'time', dateFormat: 'd.m', position: 'bottom', visibleRange: [0, 1], } ]
    猜你喜欢
    • 1970-01-01
    • 2020-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多