Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fusion Chart events in iOS does not emit. Only the first will emit. #48

Open
YeshanJay opened this issue Jun 4, 2019 · 5 comments

Comments

@YeshanJay
Copy link

commented Jun 4, 2019

Chart events seems to be not working properly. Only the first key in the event object (key-value paired) will fire/emit.

In the example below, console.log("bI"); will be logged, but not any other event. Not even onInitialized since it depends on the renderComplete event.

But if we comment out beforeInitialize event, the next event would work and so on.
onInitialized event will only work if we don't send the events prop or pass an empty object.

Update

Only occurs in iOS, and works fine in Android.

Update 2

Check point 2 in this blog, under "3. onMessage/postMessage".

The problem is that doing consecutive window.postMessage calls in iOS will result in losing your first calls as the url is overridden each time before the message is delivered so the last call wins


Scenario 1

// myChart.js
...
import ReactNativeFusionCharts from "react-native-fusioncharts";


const _libraryPath = Platform.select({
    android: { uri: "file:///android_asset/fusioncharts.html" },
    ios: require("./../../../assets/fusioncharts.html")
});

export default class MyChart extends PureComponent {
    refChart = null;
    _chartApi = null;

    render() {
        return (
            <ReactNativeFusionCharts
                ref={(ref) => {
                    this.refChart = ref;
                }}
                .... // <-- Add necessary props
                libraryPath={_libraryPath}

                onInitialized={(chartApi) => {
                    console.log("onInitialized - API");    // <-- Not emitting
                    this._chartApi = chartApi;
                }}
                events={{
                    beforeInitialize: () => {
                        console.log("bI");     // <-- Will emit
                    },
                    initialized: () => {
                        console.log("i");    // <-- Not emitting
                    },
                    chartClick: () => {
                         console.log("cclk");    // <-- Not emitting
                    }
                }}
            />
        );
    }

}

Scenario 2

// myChart.js
...
render() {
    return (
        <ReactNativeFusionCharts
            ref={(ref) => {
                this.refChart = ref;
            }}
            .... // <-- Add necessary props
            libraryPath={_libraryPath}

            onInitialized={(chartApi) => {
                console.log("onInitialized - API");    // <-- Not emitting
                this._chartApi = chartApi;
            }}
            events={{
                // beforeInitialize: () => {
                //     console.log("bI");
                // },
                // initialized: () => {
                //     console.log("i");
                // },
                chartClick: () => {
                     console.log("cclk");    // <-- Will emit
                }
            }}
        />
    );
}
...

Version:
react-native: 0.59.4
react-native-webview: 5.8.1
fushionchart: 3.13.5
react-native-fusioncharts: 3.0.0

@YeshanJay YeshanJay changed the title Fusion Chart events does not emit. Only the first will emit. Fusion Chart events in iOS does not emit. Only the first will emit. Jun 5, 2019
@ndrishinski

This comment has been minimized.

Copy link

commented Jun 21, 2019

I am also having an issue only with IOS Events. I have a dragable 2d area chart:

this.state = {
...,

events: {
        dataplotDragEnd: (e, a) => {
            Alert.alert("called")
            console.log(e.data.endValue)
          },
      }
}

<FusionCharts
      type={this.state.type}
      width={this.state.width}
      height={this.state.height}
      dataFormat={this.state.dataFormat}
      dataSource={this.state.dataSource}
      events={this.state.events}
      libraryPath={this.libraryPath}
                        />

Versions:
"fusioncharts": "^3.13.5-sr.1",
"react": "16.8.3"
"react-native": "0.59.4",
"react-native-fusioncharts": "^3.0.0"
It worked as expected on Android. Any solutions for this?

@rohanoid5

This comment has been minimized.

Copy link
Member

commented Jun 25, 2019

@YeshanJay will investigate this issue and give you an update.

@YeshanJay

This comment has been minimized.

Copy link
Author

commented Aug 23, 2019

@rohanoid5 Thank you. Were you able to find the root cause for this issue?

@YeshanJay

This comment has been minimized.

Copy link
Author

commented Aug 24, 2019

Check point 2 in this blog, under "3. onMessage/postMessage".

The problem is that doing consecutive window.postMessage calls in iOS will result in losing your first calls as the url is overridden each time before the message is delivered so the last call wins


Added an update on this issue.
@rohanoid5

This comment has been minimized.

Copy link
Member

commented Sep 20, 2019

Fixed in version 4.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.