如何解决如何访问饼图的系列数据并根据过滤显示?
我正在与Highcharts合作。 基本上,这是一个饼图,它通过rest API接收数据以显示它们。我还通过总线(基于上下文挂钩)接收了一个变量,我必须根据该变量从图中显示的其余API过滤数据。例如,如果过滤器变量为“ a”,则饼图必须仅显示名称为“ a”的数据,即,它仅显示系列的第一行。 我在互联网上发现我们可以使用setvisible,但是我不知道如何访问序列数据以根据过滤器变量告诉它的问题显示了这一点。因为我不是制作HighchartReact组件的人。 你不知道我怎么做吗? 我该如何实现?
我的代码的结构如下,它还没有完成,但是我尝试放置重要部分:
import React from "react";
import {Async} from "react-async";
import * as highchartsReact from "highcharts-react-official"
import * as highcharts from "highcharts";
type Taglist = | {
pid : String;
Stage : String;
legal_basis : String;
processing : string
}[]
| undefined;
const dataBus="filtrer";
const pie : React.FC=({})=> {
const filtre=usewidgetBusData<string>(dataBus); // filtre is the variable of the filter
const fetch =React.useCallback(async () => {
const response=await fetch('...');
const data = (await response.json()) as taglist;
return data;
} [fetch]);
return ( <Async promiseFn={fetch}>
.
.
.
<Async.Fulfilled>
{ ( data : Taglist) =>
(
<HighchartsReact highcharts={highcharts} options={ chart : {..},title : {..},series : [ { type : 'pie',name : 'value',data : [{ name : 'a',y: data!.map(x=>x.pid).length},{ name : 'b',y: data!.map(x=>x.Stage).length} ] }] })} />
......
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。