【问题标题】:CanvasJS labels are wrongly positionedCanvasJS 标签位置错误
【发布时间】:2021-06-12 18:21:40
【问题描述】:

我正在使用 CanvasJS 显示一些天气数据,但标签相对于它们的数据点的位置似乎有误。

这是什么原因?

这是我的图表配置:

animationEnabled: true,
        exportEnabled: true,
        title: {
            text: 'Pronóstico 8 Días',
        },
        axisX: {
            valueFormatString: 'DD MMM,YYYY',
            labelAngle: -30,
            labelPlacement: 'outside',
            labelTextAlign: 'left',
        },
        axisY: {
            title: 'Temperatura',
            suffix: ' °C',
            minimum: 18,
            maximum: 40,
            interval: 2,
        },
        data: [
            {
                name: 'Mínimas',
                type: 'line',
                yValueFormatString: '#0.## °C',
                showInLegend: true,
                indexLabelWrap: true,
                indexLabelMaxWidth: 80,
                dataPoints: min,
            },
            {
                name: 'Máximas',
                type: 'line',
                yValueFormatString: '#0.## °C',
                showInLegend: true,
                indexLabelWrap: true,
                indexLabelMaxWidth: 80,
                dataPoints: max,
            },
        ],

【问题讨论】:

  • 似乎传递的数据点在时间分量上有所不同,即小时/分钟。如果把xValueFormatString改成“DD MM YYYY hh:mm”,把valueFormatString:改成'DD MMM,YYYY hh:mm',就可以清楚地观察到它们之间的区别。

标签: canvasjs


【解决方案1】:

问题是日期发生了变化,因为它们包括时间,所以我只变成了日/月/年。

【讨论】:

    猜你喜欢
    • 2021-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多