apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.45k stars 19.61k forks source link

Chart misbehavior while changing type #11489

Closed rkvignesh closed 2 years ago

rkvignesh commented 4 years ago
var myChart = echarts.init(document.getElementById(properties.ControlId), 'light');
                    if (properties.GraphSettings.series[0].type == 'column') {

                        var option = {

                            xAxis: {
                                type: 'category',
                                data: category,
                                name: properties.GraphSettings.axes[0].title,
                                nameLocation: 'middle',
                                nameGap: properties.GraphSettings.axes[0].titleBottomMargin == 0 ? 40 : properties.GraphSettings.axes[0].titleBottomMargin,
                                nameRotate: properties.GraphSettings.axes[0].titleAngle,
                                inverse: properties.GraphSettings.axes[0].isInverted == "false" ? false : true,
                                nameTextStyle: {
                                    fontWeight: 'bold',
                                    fontSize: 15
                                },
                                axisLabel: {
                                    interval: 0,
                                    rotate: properties.GraphSettings.axes[0].labelAngle,
                                    margin: properties.GraphSettings.axes[0].labelBottomMargin <= 10 ? 10 : properties.GraphSettings.axes[0].labelBottomMargin,
                                    color: properties.GraphSettings.axes[0].labelTextColor == "" ? "black" : properties.GraphSettings.axes[0].labelTextColor,
                                    formatter: function (value) {

                                        var text = value;

                                        if (text.length > 10) {
                                            text = text.substring(0, 10);
                                            text = text + '...'
                                        }
                                        return text;
                                    }
                                },
                                axisTick: {
                                    alignWithLabel: true
                                }
                            },
                            yAxis: {
                                type: 'value',
                                name: properties.GraphSettings.axes[1].title,
                                nameLocation: 'middle',
                                nameGap: properties.GraphSettings.axes[1].titleLeftMargin == 0 ? 40 : properties.GraphSettings.axes[1].titleLeftMargin,
                                nameRotate: properties.GraphSettings.axes[1].titleAngle,
                                inverse: properties.GraphSettings.axes[1].isInverted == "false" ? false : true,
                                nameTextStyle: {
                                    fontWeight: 'bold',
                                    fontSize: 15
                                },
                                axisLabel: {
                                    interval: 0,
                                    rotate: properties.GraphSettings.axes[1].labelAngle,
                                    margin: properties.GraphSettings.axes[1].labelLeftMargin <= 10 ? 10 : properties.GraphSettings.axes[1].labelLeftMargin,
                                    color: properties.GraphSettings.axes[1].labelTextColor == "" ? "black" : properties.GraphSettings.axes[0].labelTextColor,
                                },
                                axisTick: {
                                    alignWithLabel: true
                                }
                            },
                            grid: {
                                top: properties.GraphSettings.margin.topMargin == 0 ? 60 : properties.GraphSettings.margin.topMargin,
                                bottom: properties.GraphSettings.margin.bottomMargin == 0 ? 60 : properties.GraphSettings.margin.bottomMargin,
                                left: properties.GraphSettings.margin.leftMargin == 0 ? '10%' : properties.GraphSettings.margin.leftMargin,
                                right: properties.GraphSettings.margin.rightMargin == 0 ? '10%' : properties.GraphSettings.margin.rightMargin,
                                height: properties.GraphSettings.size.height == 0 ? "auto" : properties.GraphSettings.size.height
                            },
                            title: {
                                text: properties.GraphSettings.title.title,
                                textStyle: {
                                    color: properties.GraphSettings.title.titleTextColor,
                                    fontFamily: properties.GraphSettings.title.titleTextStyle == "" ? 'sans-serif' : properties.GraphSettings.title.titleTextStyle
                                },
                                subtext: properties.GraphSettings.title.subtitle,
                                subtextStyle: {
                                    color: properties.GraphSettings.title.subtitleTextColor
                                },
                                top: properties.GraphSettings.margin.titletopMargin == 0 ? 'auto' : properties.GraphSettings.margin.titletopMargin,
                                left: properties.GraphSettings.margin.titleLeftMargin == 0 ? 'auto' : properties.GraphSettings.margin.titleLeftMargin,
                                bottom: properties.GraphSettings.margin.titlebottomMargin == 0 ? 'auto' : properties.GraphSettings.margin.titlebottomMargin,
                                right: properties.GraphSettings.margin.titlerightMargin == 0 ? 'auto' : properties.GraphSettings.margin.titlerightMargin
                            },
                            tooltip: {
                                trigger: 'axis',
                                show: true,
                                axisPointer: {
                                    type: 'shadow'
                                }
                            },
                            color: properties.GraphSettings.brushes,
                            series: [{
                                name: properties.GraphSettings.series[0].title,
                                data: values,
                                type: 'bar'
                            }]

                        }

                    }

                    if (properties.GraphSettings.series[0].type == 'radialLine') {

                        var option = {

                            radiusAxis: {
                                type: 'category',
                                data: category,
                                z: 10,
                                name: properties.GraphSettings.axes[0].title,
                                nameLocation: 'middle',
                                nameGap: properties.GraphSettings.axes[0].titleBottomMargin == 0 ? 20 : properties.GraphSettings.axes[0].titleBottomMargin,
                                nameRotate: properties.GraphSettings.axes[0].titleAngle,
                                nameTextStyle: {
                                    fontWeight: 'bold',
                                    fontSize: 16
                                },
                                inverse: properties.GraphSettings.axes[0].isInverted == "false" ? false : true,
                                axisLabel: {
                                    interval: 0,
                                    rotate: properties.GraphSettings.axes[0].labelAngle,
                                    margin: properties.GraphSettings.axes[0].labelBottomMargin <= 10 ? 10 : properties.GraphSettings.axes[0].labelBottomMargin,
                                    color: properties.GraphSettings.axes[0].labelTextColor == "" ? "black" : properties.GraphSettings.axes[0].labelTextColor,
                                    formatter: function (value) {

                                        var text = value;

                                        if (text.length > 10) {
                                            text = text.substring(0, 10);
                                            text = text + '...'
                                        }
                                        return text;
                                    }
                                },
                                axisTick: {
                                    alignWithLabel: true
                                }
                            },
                            angleAxis: {
                            },
                            polar: {
                            },
                            title: {
                                text: properties.GraphSettings.title.title,
                                textStyle: {
                                    color: properties.GraphSettings.title.titleTextColor,
                                    fontFamily: properties.GraphSettings.title.titleTextStyle == "" ? 'sans-serif' : properties.GraphSettings.title.titleTextStyle
                                },
                                subtext: properties.GraphSettings.title.subtitle,
                                subtextStyle: {
                                    color: properties.GraphSettings.title.subtitleTextColor
                                },
                                top: properties.GraphSettings.margin.titletopMargin == 0 ? 'auto' : properties.GraphSettings.margin.titletopMargin,
                                left: properties.GraphSettings.margin.titleLeftMargin == 0 ? 'auto' : properties.GraphSettings.margin.titleLeftMargin,
                                bottom: properties.GraphSettings.margin.titlebottomMargin == 0 ? 'auto' : properties.GraphSettings.margin.titlebottomMargin,
                                right: properties.GraphSettings.margin.titlerightMargin == 0 ? 'auto' : properties.GraphSettings.margin.titlerightMargin
                            },
                            tooltip: {
                                trigger: 'axis',
                                show: true,
                                axisPointer: {
                                    type: 'shadow'
                                }
                            },
                            color: properties.GraphSettings.brushes,
                            series: [{
                                name: properties.GraphSettings.series[0].title,
                                data: values,
                                type: 'bar',
                                coordinateSystem: 'polar'
                            }]

                        }

                    }
myChart.setOption(option)

Chart Misbehaviour

Initially the chart loads correctly. But when i change the type from column to radial line the chart becomes like this

pissang commented 4 years ago

You need to remove angleAxis and radiusAxis.

This requires you set the second parameter of setOption to true. Which means not merge with the previous option.

rkvignesh commented 4 years ago

Still having the issue` if (properties.GraphSettings.series[0].type == 'column') {

                    var option = {

                        xAxis: {
                            type: 'category',
                            data: category,
                            name: properties.GraphSettings.axes[0].title,
                            nameLocation: 'middle',
                            nameGap: properties.GraphSettings.axes[0].titleBottomMargin == 0 ? 40 : properties.GraphSettings.axes[0].titleBottomMargin,
                            nameRotate: properties.GraphSettings.axes[0].titleAngle,
                            inverse: properties.GraphSettings.axes[0].isInverted == "false" ? false : true,
                            nameTextStyle: {
                                fontWeight: 'bold',
                                fontSize: 15
                            },
                            axisLabel: {
                                interval: 0,
                                rotate: properties.GraphSettings.axes[0].labelAngle,
                                margin: properties.GraphSettings.axes[0].labelBottomMargin <= 10 ? 10 : properties.GraphSettings.axes[0].labelBottomMargin,
                                color: properties.GraphSettings.axes[0].labelTextColor == "" ? "black" : properties.GraphSettings.axes[0].labelTextColor,
                                formatter: function (value) {

                                    var text = value;

                                    if (text.length > 10) {
                                        text = text.substring(0, 10);
                                        text = text + '...'
                                    }
                                    return text;
                                }
                            },
                            axisTick: {
                                alignWithLabel: true
                            }
                        },
                        yAxis: {
                            type: 'value',
                            name: properties.GraphSettings.axes[1].title,
                            nameLocation: 'middle',
                            nameGap: properties.GraphSettings.axes[1].titleLeftMargin == 0 ? 40 : properties.GraphSettings.axes[1].titleLeftMargin,
                            nameRotate: properties.GraphSettings.axes[1].titleAngle,
                            inverse: properties.GraphSettings.axes[1].isInverted == "false" ? false : true,
                            nameTextStyle: {
                                fontWeight: 'bold',
                                fontSize: 15
                            },
                            axisLabel: {
                                interval: 0,
                                rotate: properties.GraphSettings.axes[1].labelAngle,
                                margin: properties.GraphSettings.axes[1].labelLeftMargin <= 10 ? 10 : properties.GraphSettings.axes[1].labelLeftMargin,
                                color: properties.GraphSettings.axes[1].labelTextColor == "" ? "black" : properties.GraphSettings.axes[0].labelTextColor,
                            },
                            axisTick: {
                                alignWithLabel: true
                            }
                        },
                        grid: {
                            top: properties.GraphSettings.margin.topMargin == 0 ? 60 : properties.GraphSettings.margin.topMargin,
                            bottom: properties.GraphSettings.margin.bottomMargin == 0 ? 60 : properties.GraphSettings.margin.bottomMargin,
                            left: properties.GraphSettings.margin.leftMargin == 0 ? '10%' : properties.GraphSettings.margin.leftMargin,
                            right: properties.GraphSettings.margin.rightMargin == 0 ? '10%' : properties.GraphSettings.margin.rightMargin,
                            height: properties.GraphSettings.size.height == 0 ? "auto" : properties.GraphSettings.size.height
                        },
                        title: {
                            text: properties.GraphSettings.title.title,
                            textStyle: {
                                color: properties.GraphSettings.title.titleTextColor,
                                fontFamily: properties.GraphSettings.title.titleTextStyle == "" ? 'sans-serif' : properties.GraphSettings.title.titleTextStyle
                            },
                            subtext: properties.GraphSettings.title.subtitle,
                            subtextStyle: {
                                color: properties.GraphSettings.title.subtitleTextColor
                            },
                            top: properties.GraphSettings.margin.titletopMargin == 0 ? 'auto' : properties.GraphSettings.margin.titletopMargin,
                            left: properties.GraphSettings.margin.titleLeftMargin == 0 ? 'auto' : properties.GraphSettings.margin.titleLeftMargin,
                            bottom: properties.GraphSettings.margin.titlebottomMargin == 0 ? 'auto' : properties.GraphSettings.margin.titlebottomMargin,
                            right: properties.GraphSettings.margin.titlerightMargin == 0 ? 'auto' : properties.GraphSettings.margin.titlerightMargin
                        },
                        tooltip: {
                            trigger: 'axis',
                            show: true,
                            axisPointer: {
                                type: 'shadow'
                            }
                        },
                        color: properties.GraphSettings.brushes,
                        series: [{
                            name: properties.GraphSettings.series[0].title,
                            data: values,
                            type: 'bar'
                        }]

                    }

                }

                if (properties.GraphSettings.series[0].type == 'radialLine') {

                    var option = {

                        radiusAxis: {
                            type: 'category',
                            data: category,
                            z: 10,
                            name: properties.GraphSettings.axes[0].title,
                            nameLocation: 'middle',
                            nameGap: properties.GraphSettings.axes[0].titleBottomMargin == 0 ? 20 : properties.GraphSettings.axes[0].titleBottomMargin,
                            nameRotate: properties.GraphSettings.axes[0].titleAngle,
                            nameTextStyle: {
                                fontWeight: 'bold',
                                fontSize: 16
                            },
                            inverse: properties.GraphSettings.axes[0].isInverted == "false" ? false : true,
                            axisLabel: {
                                interval: 0,
                                rotate: properties.GraphSettings.axes[0].labelAngle,
                                margin: properties.GraphSettings.axes[0].labelBottomMargin <= 10 ? 10 : properties.GraphSettings.axes[0].labelBottomMargin,
                                color: properties.GraphSettings.axes[0].labelTextColor == "" ? "black" : properties.GraphSettings.axes[0].labelTextColor,
                                formatter: function (value) {

                                    var text = value;

                                    if (text.length > 10) {
                                        text = text.substring(0, 10);
                                        text = text + '...'
                                    }
                                    return text;
                                }
                            },
                            axisTick: {
                                alignWithLabel: true
                            }
                        },
                        angleAxis: {
                        },
                        polar: {
                        },
                        title: {
                            text: properties.GraphSettings.title.title,
                            textStyle: {
                                color: properties.GraphSettings.title.titleTextColor,
                                fontFamily: properties.GraphSettings.title.titleTextStyle == "" ? 'sans-serif' : properties.GraphSettings.title.titleTextStyle
                            },
                            subtext: properties.GraphSettings.title.subtitle,
                            subtextStyle: {
                                color: properties.GraphSettings.title.subtitleTextColor
                            },
                            top: properties.GraphSettings.margin.titletopMargin == 0 ? 'auto' : properties.GraphSettings.margin.titletopMargin,
                            left: properties.GraphSettings.margin.titleLeftMargin == 0 ? 'auto' : properties.GraphSettings.margin.titleLeftMargin,
                            bottom: properties.GraphSettings.margin.titlebottomMargin == 0 ? 'auto' : properties.GraphSettings.margin.titlebottomMargin,
                            right: properties.GraphSettings.margin.titlerightMargin == 0 ? 'auto' : properties.GraphSettings.margin.titlerightMargin
                        },
                        tooltip: {
                            trigger: 'axis',
                            show: true,
                            axisPointer: {
                                type: 'shadow'
                            }
                        },
                        color: properties.GraphSettings.brushes,
                        series: [{
                            name: properties.GraphSettings.series[0].title,
                            data: values,
                            type: 'bar',
                            coordinateSystem: 'polar'
                        }]

                    }

                }

                if (properties.GraphSettings.series[0].type == 'polarLine') {

                    var option = {

                        angleAxis: {
                            type: 'category',
                            data: category,
                            name: properties.GraphSettings.axes[0].title,
                            nameLocation: 'middle',
                            nameGap: properties.GraphSettings.axes[0].titleBottomMargin == 0 ? 20 : properties.GraphSettings.axes[0].titleBottomMargin,
                            nameRotate: properties.GraphSettings.axes[0].titleAngle,
                            nameTextStyle: {
                                fontWeight: 'bold',
                                fontSize: 16
                            },
                            inverse: properties.GraphSettings.axes[0].isInverted == "false" ? false : true,
                            axisLabel: {
                                interval: 0,
                                rotate: properties.GraphSettings.axes[0].labelAngle,
                                margin: properties.GraphSettings.axes[0].labelBottomMargin <= 10 ? 10 : properties.GraphSettings.axes[0].labelBottomMargin,
                                color: properties.GraphSettings.axes[0].labelTextColor == "" ? "black" : properties.GraphSettings.axes[0].labelTextColor,
                                formatter: function (value) {

                                    var text = value;

                                    if (text.length > 10) {
                                        text = text.substring(0, 10);
                                        text = text + '...'
                                    }
                                    return text;
                                }
                            },
                            axisTick: {
                                alignWithLabel: true
                            }
                        },
                        radiusAxis: {
                            z: 10
                        },
                        polar: {
                        },
                        title: {
                            text: properties.GraphSettings.title.title,
                            textStyle: {
                                color: properties.GraphSettings.title.titleTextColor,
                                fontFamily: properties.GraphSettings.title.titleTextStyle == "" ? 'sans-serif' : properties.GraphSettings.title.titleTextStyle
                            },
                            subtext: properties.GraphSettings.title.subtitle,
                            subtextStyle: {
                                color: properties.GraphSettings.title.subtitleTextColor
                            },
                            top: properties.GraphSettings.margin.titletopMargin == 0 ? 'auto' : properties.GraphSettings.margin.titletopMargin,
                            left: properties.GraphSettings.margin.titleLeftMargin == 0 ? 'auto' : properties.GraphSettings.margin.titleLeftMargin,
                            bottom: properties.GraphSettings.margin.titlebottomMargin == 0 ? 'auto' : properties.GraphSettings.margin.titlebottomMargin,
                            right: properties.GraphSettings.margin.titlerightMargin == 0 ? 'auto' : properties.GraphSettings.margin.titlerightMargin
                        },
                        tooltip: {
                            trigger: 'axis',
                            show: true,
                            axisPointer: {
                                type: 'shadow'
                            }
                        },
                        color: properties.GraphSettings.brushes,
                        series: [{
                            name: properties.GraphSettings.series[0].title,
                            data: values,
                            type: 'bar',
                            coordinateSystem: 'polar'
                        }]

                    }

                }

                myChart.setOption(option, {notMerge: true});

Chart Misbehaviour `

SeregPie commented 4 years ago

Same here. notMerge has no effect.

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.

github-actions[bot] commented 2 years ago

This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!