亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

使用echarts實現(xiàn)3d柱狀圖+折線圖

 更新時間:2024年12月18日 15:54:48   作者:吉吉安  
這篇文章主要為大家詳細介紹了如何使用echarts實現(xiàn)3d柱狀圖和折線圖,文中的示例代碼講解詳細,具有一定的借鑒價值,有需要的小伙伴可以了解一下

效果圖

HTML

需要注意threeDchart一定要設(shè)置寬度高度,不然圖不顯示,然后echarts版本不要太低,不然也不顯示

<div id="threeDchart" class="threeDchart"></div>

js

     set3DBarChart2(data) {
            var myChart = echarts.init(document.getElementById('middle-right-top-chart'));
            data = [2000, 1529, 2251, 1173];
            const CubeLeft = echarts.graphic.extendShape({
                shape: {
                    x: 0,
                    y: 0,
                },
                buildPath: function (ctx, shape) {
                    const xAxisPoint = shape.xAxisPoint;
                    const c0 = [shape.x, shape.y];
                    const c1 = [shape.x - 9, shape.y - 9];
                    const c2 = [xAxisPoint[0] - 9, xAxisPoint[1] - 9];
                    const c3 = [xAxisPoint[0], xAxisPoint[1]];
                    ctx.moveTo(c0[0], c0[1]).lineTo(c1[0], c1[1]).lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).closePath();
                },
            });
            const CubeRight = echarts.graphic.extendShape({
                shape: {
                    x: 0,
                    y: 0,
                },
                buildPath: function (ctx, shape) {
                    const xAxisPoint = shape.xAxisPoint;
                    const c1 = [shape.x, shape.y];
                    const c2 = [xAxisPoint[0], xAxisPoint[1]];
                    const c3 = [xAxisPoint[0] + 18, xAxisPoint[1] - 9];
                    const c4 = [shape.x + 18, shape.y - 9];
                    ctx.moveTo(c1[0], c1[1]).lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).lineTo(c4[0], c4[1]).closePath();
                },
            });
            const CubeTop = echarts.graphic.extendShape({
                shape: {
                    x: 0,
                    y: 0,
                },
                buildPath: function (ctx, shape) {
                    const c1 = [shape.x, shape.y];
                    const c2 = [shape.x + 18, shape.y - 9];
                    const c3 = [shape.x + 9, shape.y - 18];
                    const c4 = [shape.x - 9, shape.y - 9];
                    ctx.moveTo(c1[0], c1[1]).lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).lineTo(c4[0], c4[1]).closePath();
                },
            });
            echarts.graphic.registerShape('CubeLeft', CubeLeft);
            echarts.graphic.registerShape('CubeRight', CubeRight);
            echarts.graphic.registerShape('CubeTop', CubeTop);
        
          let  option = {
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true,
                },
                tooltip: {
                    trigger: 'item',
                    formatter: (params) => {
                        let markerArr = params.marker.split('color:');
                        let marker = markerArr[0] + 'color:#1472FF;"></span>';
                        dataStr =
                            `<div style="color:#000A3A">
                            <div style="color:#666666">${params.name}</div>
                            <div>` +
                            marker +
                            `<span>合同金額</span>` +
                            `<span style="margin-left:15px">${params.data}萬元</span></div>` +
                            `</div>`;
                        return dataStr;
                    },
                },
                xAxis: {
                    type: 'category',
                    data: ['隆德礦業(yè)', '榆橫煤電', '錦興能源', '不連溝'],
                    axisTick: {
                        show: false, // 不顯示坐標軸刻度線
                    },
                    axisPoint: {
                        type: 'shadow',
                    },
                    axisLabel: {
                        textStyle: {
                            color: '#666666',
                            fontSize: '14',
                        },
                    },
                },
                yAxis: [
                    {
                        type: 'value',
                        min: 0,
                        name: '萬元',
                        splitLine: {
                            show: true,
                            lineStyle: {
                                color: '#F0F0F0',
                            },
                        },
                        nameTextStyle: {
                            color: '#666666',
                            padding: [0, 30, 0, 0],
                        },
                        axisLabel: {
                            color: '#666666',
                        },
                    },
                    // 右側(cè)縱向坐標軸
                    {
                        type: 'value',
                        name: '折線圖值',
                        position: 'right', // 右側(cè)顯示
                        splitLine: {
                            show: false, // 不顯示右側(cè)坐標軸的分隔線
                        },
                        axisLabel: {
                            color: '#FF7F50',
                        },
                        nameTextStyle: {
                            color: '#FF7F50',
                        },
                    }
                ],
                series: [
                    // 3D柱狀圖
                    {
                        type: 'custom',
                        renderItem: function (params, api) {
                            const location = api.coord([api.value(0), api.value(1)]);
                            return {
                                type: 'group',
                                children: [
                                    {
                                        type: 'CubeLeft',
                                        shape: {
                                            api,
                                            xValue: api.value(0),
                                            yValue: api.value(1),
                                            x: location[0],
                                            y: location[1],
                                            xAxisPoint: api.coord([api.value(0), 0]),
                                        },
                                        style: {
                                            fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                                {
                                                    offset: 0,
                                                    color: '#1D6CE2',
                                                },
                                                {
                                                    offset: 1,
                                                    color: 'rgba(51, 135, 234, 0.10)',
                                                },
                                            ]),
                                        },
                                    },
                                    {
                                        type: 'CubeRight',
                                        shape: {
                                            api,
                                            xValue: api.value(0),
                                            yValue: api.value(1),
                                            x: location[0],
                                            y: location[1],
                                            xAxisPoint: api.coord([api.value(0), 0]),
                                        },
                                        style: {
                                            fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                                {
                                                    offset: 0,
                                                    color: 'rgba(51, 124, 234, 1)',
                                                },
                                                {
                                                    offset: 0.3,
                                                    color: 'rgba(51, 124, 234, 0.97)',
                                                },
                                                {
                                                    offset: 0.7,
                                                    color: 'rgba(51, 135, 234, 0.36)',
                                                },
                                                {
                                                    offset: 1,
                                                    color: 'rgba(51, 143, 234, 0.10)',
                                                },
                                            ]),
                                        },
                                    },
                                    {
                                        type: 'CubeTop',
                                        shape: {
                                            api,
                                            xValue: api.value(0),
                                            yValue: api.value(1),
                                            x: location[0],
                                            y: location[1],
                                            xAxisPoint: api.coord([api.value(0), 0]),
                                        },
                                        style: {
                                            fill: '#1472FF',
                                        },
                                    },
                                ],
                            };
                        },
                        data: data,
                    },
                    // 折線圖
                    {
                        type: 'line',
                        name: '折線圖',
                        smooth: true, // 平滑曲線
                        data: [2000, 1800, 2300, 1500], // 你可以根據(jù)實際數(shù)據(jù)修改這個數(shù)組
                        lineStyle: {
                            color: '#FF7F50',
                            width: 3,
                        },
                        symbol: 'circle', // 設(shè)置折線圖標記為圓形
                        symbolSize: 8, // 設(shè)置圓形標記的大小
                        yAxisIndex: 1, // 使用右側(cè)的 y 軸
                    },
                ],
            };
        
            myChart.setOption(option);
        
            window.addEventListener('resize', function () {
                myChart.resize();
            });
        },  

到此這篇關(guān)于使用echarts實現(xiàn)3d柱狀圖+折線圖的文章就介紹到這了,更多相關(guān)echarts 3d柱狀圖和折線圖內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論