React-chartjs-2条形图用图像替换标签[已关闭]

wsewodh2  于 2023-01-30  发布在  Chart.js
关注(0)|答案(1)|浏览(147)

**已关闭。**此问题需要debugging details。当前不接受答案。

编辑问题以包含desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
昨天关门了。
Improve this question
我用React-chartjs-2构建了这个水平条形图。

我的用例是,而不是标签易趣,亚马逊,吴...我想显示这些标志。
我试着用afterDraw钩子来做这个。但是好像不起作用。我该怎么解决这个问题?
这是我的Code

eufgjt7s

eufgjt7s1#

插件配置不正确。
你可以

const myPlugin = {
  id: 'myPlugin',
  afterDraw: (chart: { ctx: any; scales: { [x: string]: any; }; }) => {
    /// your logic
  }
};

然后将其设置到图表中

export default function App() {
  return <Bar options={options} data={data} plugins={[myPlugin]} />;
}

相关问题