echarts 餅圖疊加態(tài)--統(tǒng)計成績及格分

1647596431(1).jpg
<div id="echarts"></div>
            let list = [];
            const max = 150;
            const value = 15;//每一級15分值
            let rows = [
                {name: '語文',score:parseInt(Math.random()*max)},{name: '數(shù)學',score:parseInt(Math.random()*max)},{name: '物理',score:parseInt(Math.random()*max)},{name: '化學',score:parseInt(Math.random()*max)},
                {name: '歷史',score:parseInt(Math.random()*max)},{name: '生物',score:parseInt(Math.random()*max)},{name: '政治',score:parseInt(Math.random()*max)},{name: '音樂',score:parseInt(Math.random()*max)}
            ];
            let color = [
                "rgb("+parseInt(Math.random()*255)+','+parseInt(Math.random()*255)+','+parseInt(Math.random()*255)+")",
                "rgb("+parseInt(Math.random()*255)+','+parseInt(Math.random()*255)+','+parseInt(Math.random()*255)+")",
                "rgb("+parseInt(Math.random()*255)+','+parseInt(Math.random()*255)+','+parseInt(Math.random()*255)+")",
                "rgb("+parseInt(Math.random()*255)+','+parseInt(Math.random()*255)+','+parseInt(Math.random()*255)+")",
                "rgb("+parseInt(Math.random()*255)+','+parseInt(Math.random()*255)+','+parseInt(Math.random()*255)+")",
                "rgb("+parseInt(Math.random()*255)+','+parseInt(Math.random()*255)+','+parseInt(Math.random()*255)+")",
                "rgb("+parseInt(Math.random()*255)+','+parseInt(Math.random()*255)+','+parseInt(Math.random()*255)+")",
                "rgb("+parseInt(Math.random()*255)+','+parseInt(Math.random()*255)+','+parseInt(Math.random()*255)+")"
            ]
            
            for(var i=0;i<=max/value;i++){
                let rowsCloen = JSON.parse(JSON.stringify(rows));
                rowsCloen = rowsCloen.map((e,index)=>{
                    e.value = value;
                    e.itemStyle = {
                        color:!(e.score<=(i+1)*value&&e.score<=i*value)?color[index]:"#ddd"
                    }
                    return e;
                })
                list.push({
                    name: '圖表'+i,
                    type: 'pie',
                    radius: [(i)*8+'%', (i+1)*8+'%'],
                    label: {
                        position: 'inner',
                        fontSize: 14
                    },
                    labelLine: {
                        show: false
                    },
                    emphasis: {
                        focus: 'series'
                    },
                    itemStyle:{
                        normal:{
                            label:{
                                show:false
                            }
                        }
                    },
                    data: rowsCloen
                })
            }
            let option = {
                tooltip: {
                    trigger: 'item',
                    formatter: function(item,index,a){
                        return item.name+'<br />級別分值范圍:'+(item.seriesIndex)*value+' ~ '+(item.seriesIndex+1)*value+"<br/>分值:"+item.data.score;
                    }
                },
                toolbox: {
                    show: true,
                    feature: {
                    mark: { show: true },
                    dataView: { show: true, readOnly: false },
                    restore: { show: true },
                    saveAsImage: { show: true }
                    }
                },
                series: list
            };
            const dome = echarts.init(document.getElementById("echarts"));
            dome.setOption(option);
最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末摸屠,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子播掷,更是在濱河造成了極大的恐慌咙边,老刑警劉巖猜煮,帶你破解...
    沈念sama閱讀 216,651評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件次员,死亡現(xiàn)場離奇詭異,居然都是意外死亡王带,警方通過查閱死者的電腦和手機淑蔚,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,468評論 3 392
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來愕撰,“玉大人刹衫,你說我怎么就攤上這事「阏酰” “怎么了带迟?”我有些...
    開封第一講書人閱讀 162,931評論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長囱桨。 經(jīng)常有香客問我仓犬,道長,這世上最難降的妖魔是什么舍肠? 我笑而不...
    開封第一講書人閱讀 58,218評論 1 292
  • 正文 為了忘掉前任搀继,我火速辦了婚禮,結果婚禮上翠语,老公的妹妹穿的比我還像新娘叽躯。我一直安慰自己,他們只是感情好啡专,可當我...
    茶點故事閱讀 67,234評論 6 388
  • 文/花漫 我一把揭開白布险毁。 她就那樣靜靜地躺著,像睡著了一般们童。 火紅的嫁衣襯著肌膚如雪畔况。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,198評論 1 299
  • 那天慧库,我揣著相機與錄音跷跪,去河邊找鬼。 笑死齐板,一個胖子當著我的面吹牛吵瞻,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播甘磨,決...
    沈念sama閱讀 40,084評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼橡羞,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了济舆?” 一聲冷哼從身側(cè)響起卿泽,我...
    開封第一講書人閱讀 38,926評論 0 274
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎滋觉,沒想到半個月后签夭,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體齐邦,經(jīng)...
    沈念sama閱讀 45,341評論 1 311
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,563評論 2 333
  • 正文 我和宋清朗相戀三年第租,在試婚紗的時候發(fā)現(xiàn)自己被綠了措拇。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 39,731評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡慎宾,死狀恐怖丐吓,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情璧诵,我是刑警寧澤汰蜘,帶...
    沈念sama閱讀 35,430評論 5 343
  • 正文 年R本政府宣布,位于F島的核電站之宿,受9級特大地震影響族操,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜比被,卻給世界環(huán)境...
    茶點故事閱讀 41,036評論 3 326
  • 文/蒙蒙 一色难、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧等缀,春花似錦枷莉、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,676評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至噪裕,卻和暖如春蹲盘,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背膳音。 一陣腳步聲響...
    開封第一講書人閱讀 32,829評論 1 269
  • 我被黑心中介騙來泰國打工召衔, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人祭陷。 一個月前我還...
    沈念sama閱讀 47,743評論 2 368
  • 正文 我出身青樓苍凛,卻偏偏與公主長得像,于是被迫代替她去往敵國和親兵志。 傳聞我的和親對象是個殘疾皇子羹呵,可洞房花燭夜當晚...
    茶點故事閱讀 44,629評論 2 354