Pie Chart on re-click legends value not appear

Hello guys,

I'm working with PieChart, and I give dataSource by props. props data come from API call.

It works, but when I click the legends and I re-click legends the data not appear.

Where I wronge?
The same codice without props works without problem.

here the code:

thank you :)

<script>
/* eslint-disable */
script>
<template>
<div>
<ejs-accumulationchart
id="container-pie-chart-maggiore-incasso"
:title="title"
:legendSettings="legendSettings"
>
<e-accumulation-series-collection>
<e-accumulation-series :dataSource="dataMaggioreIncasso" xName="x" yName="y" :dataLabel="datalabel" :pointColorMapping="pointColorMapping" />
e-accumulation-series-collection>
ejs-accumulationchart>
div>
template>
<script>
import Vue from "vue";
import { AccumulationChartPlugin, PieSeries, AccumulationLegend } from "@syncfusion/ej2-vue-charts"


Vue.use(AccumulationChartPlugin)


export default {
props: {
dataMaggioreIncasso: {
type: Array,
required: true,
},
},
data() {
return {
legendSettings: {
visible: true,
},
datalabel: { visible: true, name: 'text' },
tooltip:{enable: true, format: '${point.x} : ${point.y}%'},
pointColorMapping: 'fill',
title: 'Quantità più vendute(%)',
seriesData: [
{ x: 'Jan', y: 3, fill: '#498fff', text:'January' }, { x: 'Feb', y: 3.5, fill: '#ffa060', text: 'February' },
{ x: 'Mar', y: 7, fill: '#ff68b6', text: 'March' }, { x: 'Apr', y: 13.5, fill: '#81e2a1', text: 'April' },
]
};
},
provide: {
accumulationchart: [PieSeries, AccumulationLegend ]
}
};
script>
<style>
#container-pie-chart-maggiore-incasso {
height: 350px;
}
style>

3 Replies

SB Swetha Babu Syncfusion Team June 6, 2022 10:10 AM UTC

Hi Alberto,


Greetings from Syncfusion.


We are unable to reproduce the reported scenario. We have created a simple Vue application using the provided code snippet to test the reported scenario and the same can be downloaded from the below link.


Sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Chart2097340747


Screenshot:


After First legend Click:



Again clicking the legend:



If the reported scenario still persists, please modify the above sample to replicate the reported scenario. It will be helpful for us to analyze further and assist you better.


Regards,

Swetha



AL Alberto June 6, 2022 11:47 AM UTC

Hello,

thank you for the answer.

I know, if I give dataSource from static json(template data, see variables seriesData) it works without problem. But if I give dataSource from props(rest api call from server) the charts has this problem.





DG Durga Gopalakrishnan Syncfusion Team June 9, 2022 02:58 PM UTC

Hi Alberto,


We have prepared sample based on your requirement. In the sample, we have accessed data from API response using axios and assigned it to chart series datasource. Chart legend click is working fine our end. We have attached tested sample and video for your reference.


mounted () {

    axios

      .get('https://api.coindesk.com/v1/bpi/currentprice.json')

      .then(response => {

                               let data = response.data.bpi;

                               this.seriesData.push(

                                             {x: data.EUR.code, y: data.EUR.rate_float},

                                             {x: data.GBP.code, y: data.GBP.rate_float},

                                             {x: data.USD.code, y: data.USD.rate_float}

                               );

                })         

  }


Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/APIcall-211865828.zip


Video : https://www.syncfusion.com/downloads/support/directtrac/general/ze/axios841909138.zip


If you are still facing problem, please try to replicate an issue in above sample or share us issue reproduced sample to validate this case further.


Regards,

Durga Gopalakrishnan.


Loader.
Up arrow icon