NativeScript / nativescript-ui-charts

NativeScript wrapper around HiCharts library
Apache License 2.0
26 stars 6 forks source link

Pie chart breaks application on Android #13

Open cjohn001 opened 3 years ago

cjohn001 commented 3 years ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

Use the following chart and run it on Android -> App should crash on startup callstack is

JS: ERROR Error: JNI Exception occurred (SIGABRT). JS: ======= JS: Check the 'adb logcat' for additional information about the error. JS: ======= chromium: [INFO:library_loader_hooks.cc(36)] Chromium logging enabled: level = 0, default verbosity = 0 System.err: An uncaught Exception occurred on "main" thread. System.err: Calling js method onCreateView failed System.err: Error: JNI Exception occurred (SIGABRT). System.err: ======= System.err: Check the 'adb logcat' for additional information about the error. System.err: ======= System.err: System.err: System.err: StackTrace: System.err: optionsBuilder(file: node_modules/@nativescript/ui-charts/options-handlers/helpers/helpers.android.js:119:0) System.err: at dataLabelsHandler(file: node_modules/@nativescript/ui-charts/options-handlers/dataLabels/dataLabels-handler.js:62:49) System.err: at HIDataLabels(file: node_modules/@nativescript/ui-charts/options-handlers/helpers/_helpers.common.js:158:276) System.err: at optionsBuilder(file: node_modules/@nativescript/ui-charts/options-handlers/helpers/helpers.android.js:119:0) System.err: at seriesHandler(file: node_modules/@nativescript/ui-charts/options-handlers/series/series-handler.js:119:25) System.err: at pieHandler(file: node_modules/@nativescript/ui-charts/options-handlers/series/pie/pie-handler.js:30:28) System.err: at HIPie(file: node_modules/@nativescript/ui-charts/options-handlers/helpers/_helpers.common.js:129:36) System.err: at optionsBuilder(file: node_modules/@nativescript/ui-charts/options-handlers/helpers/helpers.android.js:119:0) System.err: at plotOptionsHandler(file: node_modules/@nativescript/ui-charts/options-handlers/plotOptions/plotOptions-handler.js:58:25) System.err: at HIPlotOptions(file: node_modules/@nativescript/ui-charts/options-handlers/helpers/_helpers.common.js:170:197) System.err: at optionsBuilder(file: node_modules/@nativescript/ui-charts/options-handlers/helpers/helpers.android.js:119:0) System.err: at optionsHandler(file: node_modules/@nativescript/ui-charts/options-handlers/options-handler.js:93:25) System.err: at onLoaded(file: node_modules/@nativescript/ui-charts/ui-charts.android.js:7:40) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at callFunctionWithSuper(file: node_modules/@nativescript/core/ui/core/view-base/index.js:291:0) System.err: at callLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at loadView(file: node_modules/@nativescript/core/ui/core/view-base/index.js:437:0) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:216:0) System.err: at eachChildView(file: node_modules/@nativescript/core/ui/layouts/layout-base-common.js:101:0) System.err: at eachChild(file: node_modules/@nativescript/core/ui/core/view/view-common.js:700:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:215:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/core/view/index.android.js:271:0) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at callFunctionWithSuper(file: node_modules/@nativescript/core/ui/core/view-base/index.js:291:0) System.err: at callLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at loadView(file: node_modules/@nativescript/core/ui/core/view-base/index.js:437:0) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:216:0) System.err: at eachChildView(file: node_modules/@nativescript/core/ui/layouts/layout-base-common.js:101:0) System.err: at eachChild(file: node_modules/@nativescript/core/ui/core/view/view-common.js:700:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:215:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/core/view/index.android.js:271:0) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at callFunctionWithSuper(file: node_modules/@nativescript/core/ui/core/view-base/index.js:291:0) System.err: at callLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at loadView(file: node_modules/@nativescript/core/ui/core/view-base/index.js:437:0) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:216:0) System.err: at eachChildView(file: node_modules/@nativescript/core/ui/layouts/layout-base-common.js:101:0) System.err: at eachChild(file: node_modules/@nativescript/core/ui/core/view/view-common.js:700:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:215:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/core/view/index.android.js:271:0) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at callFunctionWithSuper(file: node_modules/@nativescript/core/ui/core/view-base/index.js:291:0) System.err: at callLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at loadView(file: node_modules/@nativescript/core/ui/core/view-base/index.js:437:0) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:216:0) System.err: at eachChildView(file: node_modules/@nativescript/core/ui/layouts/layout-base-common.js:101:0) System.err: at eachChild(file: node_modules/@nativescript/core/ui/core/view/view-common.js:700:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:215:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/core/view/index.android.js:271:0) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at callFunctionWithSuper(file: node_modules/@nativescript/core/ui/core/view-base/index.js:291:0) System.err: at callLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at loadView(file: node_modules/@nativescript/core/ui/core/view-base/index.js:437:0) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:216:0) System.err: at eachChildView(file: node_modules/@nativescript/core/ui/layouts/layout-base-common.js:101:0) System.err: at eachChild(file: node_modules/@nativescript/core/ui/core/view/view-common.js:700:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:215:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/core/view/index.android.js:271:0) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at callFunctionWithSuper(file: node_modules/@nativescript/core/ui/core/view-base/index.js:291:0) System.err: at callLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at loadView(file: node_modules/@nativescript/core/ui/core/view-base/index.js:437:0) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:216:0) System.err: at eachChildView(file: node_modules/@nativescript/core/ui/layouts/layout-base-common.js:101:0) System.err: at eachChild(file: node_modules/@nativescript/core/ui/core/view/view-common.js:700:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:215:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/core/view/index.android.js:271:0) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at callFunctionWithSuper(file: node_modules/@nativescript/core/ui/core/view-base/index.js:291:0) System.err: at callLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at loadView(file: node_modules/@nativescript/core/ui/core/view-base/index.js:437:0) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:216:0) System.err: at eachChildView(file: node_modules/@nativescript/core/ui/layouts/layout-base-common.js:101:0) System.err: at eachChild(file: node_modules/@nativescript/core/ui/core/view/view-common.js:700:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:215:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/core/view/index.android.js:271:0) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at callFunctionWithSuper(file: node_modules/@nativescript/core/ui/core/view-base/index.js:291:0) System.err: at callLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at loadView(file: node_modules/@nativescript/core/ui/core/view-base/index.js:437:0) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:216:0) System.err: at eachChildView(file: node_modules/@nativescript/core/ui/content-view/index.js:65:0) System.err: at eachChildView(file: node_modules/@nativescript/core/ui/page/page-common.js:99:0) System.err: at eachChild(file: node_modules/@nativescript/core/ui/core/view/view-common.js:700:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:215:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/core/view/index.android.js:271:0) System.err: at onLoaded(file: node_modules/@nativescript/core/ui/page/index.android.js:37:0) System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at callFunctionWithSuper(file: node_modules/@nativescript/core/ui/core/view-base/index.js:291:0) System.err: at callLoaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:297:0) System.err: at loadView(file: node_modules/@nativescript/core/ui/core/view-base/index.js:437:0) System.err: at _addViewCore(file: node_modules/@nativescript/core/ui/core/view-base/index.js:432:0) System.err: at _addView(file: node_modules/@nativescript/core/ui/core/view-base/index.js:418:0) System.err: at onCreateView(file: node_modules/@nativescript/core/ui/frame/index.android.js:738:0) System.err: at onCreateView(file: node_modules/@nativescript/core/ui/frame/fragment.android.js:25:0) System.err: at com.tns.Runtime.callJSMethodNative(Native Method) System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1302) System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1188) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1175) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1153) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1149) System.err: at com.tns.FragmentClass.onCreateView(FragmentClass.java:55) System.err: at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2699) System.err: at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:320) System.err: at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1199) System.err: at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1368) System.err: at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1446) System.err: at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1509) System.err: at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:447) System.err: at androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2181) System.err: at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2004) System.err: at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1959) System.err: at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1861) System.err: at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:413) System.err: at android.os.Handler.handleCallback(Handler.java:873) System.err: at android.os.Handler.dispatchMessage(Handler.java:99) System.err: at android.os.Looper.loop(Looper.java:193) System.err: at android.app.ActivityThread.main(ActivityThread.java:6669) System.err: at java.lang.reflect.Method.invoke(Native Method) System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Is there any code involved?

chartOptions: any = {
    chart: {
        type: 'pie',
        backgroundColor: 'rgba(0,0,0,0)',
        options3d: {
            enabled: true,
            alpha: 65,
            beta: 0
        },
        marginTop: 0,
        marginBottom: 15,
        marginLeft: 0,
        marginRight: 0
    },
    legend: {
        layout: 'horizontal',
        align: 'center',
        verticalAlign: 'bottom',
        floating: true,
        enabled: true,
        itemStyle: {
            color: '#6E6E6E',
            fontSize: '12px',
            fontWeight: 'normal'
        },
        y: 8
    },
    exporting: {
        enabled: false
    },
    credits: {
        enabled: false
    },
    title: {
        text: 'Carbohydrate Decomposition of last Week',
        style: {
            color: '#377576',
            fontSize: '12px',
            fontWeight: 'bold'
        }
    },
    plotOptions: {
        pie: {
            dataLabels: {
                distance: '10%',
                enabled: true,
                useHTML: true,
                formatter:
                    // tslint:disable-next-line: quotemark
                    "function () { return '<span style=\"font-size:12px; color:#6E6E6E;margin-bottom:20px; font-weight: normal;\">' + this.y + '%</span>';}"
            },
            allowPointSelect: false,
            depth: 15,
            showInLegend: true
        }
    },
    series: [
        {
            type: 'pie',
            enableMouseTracking: false,
            data: [
                { name: 'Dietary Fiber', y: 33.3, color: '#FECB02' },
                {
                    name: 'Sugar',
                    y: 33.3,
                    color: '#e63e11'
                },
                { name: 'Other', color: '#85bb2f', y: 33.3 }
            ]
        }
    ]
};
cjohn001 commented 3 years ago

Found the problem now. Seems like Android version does not support use of objects within series array. The following works on Android

series: [
            {
                type: 'pie',
                animation: true,
                enableMouseTracking: false,
                keys: ['name', 'y', 'color'],
                data: [['Dietary Fiber', 33.3, '#FECB02'], ['Sugar', 33.3, '#e63e11'], ['Other', 33.3, '#85bb2f']]
            }
        ]

and the following does not work:

series: [
            {
                type: 'pie',
                animation: true,
                enableMouseTracking: false,
                data: [
                    { name: 'Dietary Fiber', y: 33.3, color: '#FECB02' },
                    {
                        name: 'Sugar',
                        y: 33.3,
                        color: '#e63e11'
                    },
                    { name: 'Other', color: '#85bb2f', y: 33.3 }
                ]
            }
        ]
shiv19 commented 2 years ago

@cjohn001 is the array technique working for both iOS and Android?

cjohn001 commented 2 years ago

@shiv19 , yes it works on both platforms for me.