0

即使配置正确,框注释也不会呈现


chartjs 版本:3.6.0

chartjs-plugin-annotation 版本:1.0.2


该插件是这样注册的:

import { Chart } from 'chart.js';
import annotationPlugin from 'chartjs-plugin-annotation';
Chart.register(annotationPlugin);

我将插件用作添加到图形配置中的常量:

plugins = {
            autocolors: false,
            annotation: {
                annotations: {
                    box1: {
                        type: 'box',
                        yMin: 2,
                        yMax: 4,
                        backgroundColor: 'rgba(221, 29, 33, 0.3)',
                        borderColor: 'rgba(0,0,0,0)',
                    },
                    box2: {
                        type: 'box',
                        yMin: 0,
                        yMax: 2,
                        backgroundColor: 'rgba(251, 206, 7, 0.3)',
                        borderColor: 'rgba(0,0,0,0)',
                    },
                    box3: {
                        type: 'box',
                        yMin: -2,
                        yMax: 0,
                        backgroundColor: 'rgba(92, 171, 42, 0.3)',
                        borderColor: 'rgba(0,0,0,0)',
                    },
                    box4: {
                        type: 'box',
                        yMin: -4,
                        yMax: -2,
                        backgroundColor: 'rgba(166, 166, 166, 0.3)',
                        borderColor: 'rgba(0,0,0,0)',
                    },
                },
            },
        };

我将图形渲染为 base64 字符串,以便可以将其转换为静态图像。绘制了数据,但没有绘制方框。两周前它还在工作,现在不行了。

4

0 回答 0