Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何修改JSON标签_Javascript_Reactjs_Fusioncharts - Fatal编程技术网

Javascript 如何修改JSON标签

Javascript 如何修改JSON标签,javascript,reactjs,fusioncharts,Javascript,Reactjs,Fusioncharts,我正在尝试在一个页面中添加一个图表。在同一页中,我在表格中得到了数据,我希望这些数据与我的图表相同。我的图表是这样的: export const myDataSourcePie ={ chart: { caption: "Title", subcaption: "Friends' chart", startingangle: "120", showlabels: "0", showlegend: "1",

我正在尝试在一个页面中添加一个图表。在同一页中,我在表格中得到了数据,我希望这些数据与我的图表相同。我的图表是这样的:

export const myDataSourcePie ={
    chart: {
        caption: "Title",
        subcaption:  "Friends' chart",
        startingangle: "120",
        showlabels: "0",
        showlegend: "1",
        enablemultislicing: "0",
        slicingdistance: "15",
        showpercentvalues: "1",
        showpercentintooltip: "0",
        plottooltext: "Friend's email : $label Total messages : $datavalue",
        theme: "ocean"
},
    data: [
        {
            label: 'email',
            value: '17',
        },
        {
            label: 'email',
            value: '100',
        },
        {
            label: 'email',
            value: '17',
        },
        {
            label: 'email',
            value: '17',
        },
        {
            label: 'email',
            value: '17',
        },
        {
            label: 'email',
            value: '17',
        },
        {
            label: 'email',
            value: '100',
        },
        {
            label: 'email',
            value: '17',
        },
]
}

export const chartConfigs = {
    type: 'pie3d',
    width: 800,
    height: 600,
    dataFormat: 'json',
    dataSource: myDataSourcePie
};
我导入它,然后用

<ReactFC {...chartConfigs} />
从中我得到了要放在表中的数据,我只想得到这个对象列表的两个标签放在图表中(电子邮件和消息)。我如何将这个值放入我的“myDataSourcePie”中?用道具? 谢谢

试试这个:

getFriendsChart()
    {
        let dataChart = [];

        this.state.friends.forEach( function( friend ) {

            dataChart.push(
                {
                    label: friend.email,
                    value: friend.messages,
                }
            );
        });

        let tempConfig = {...chartConfigs};     
        tempConfig.dataSource.data = dataChart;

        return tempConfig;
    }
getFriendsChart()
    {
        let dataChart = [];

        this.state.friends.forEach( function( friend ) {

            dataChart.push(
                {
                    label: friend.email,
                    value: friend.messages,
                }
            );
        });

        let tempConfig = {...chartConfigs};     
        tempConfig.dataSource.data = dataChart;

        return tempConfig;
    }