¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * uCharts® |
| | | * 髿§è½è·¨å¹³å°å¾è¡¨åºï¼æ¯æH5ãAPPãå°ç¨åºï¼å¾®ä¿¡/æ¯ä»å®/ç¾åº¦/头æ¡/QQ/360ï¼ãVueãTaroçæ¯æcanvasçæ¡æ¶å¹³å° |
| | | * Copyright (c) 2021 QIUN®ç§äº https://www.ucharts.cn All rights reserved. |
| | | * Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) |
| | | * å¤å¶ä½¿ç¨è¯·ä¿çæ¬æ®µæ³¨éï¼æè°¢æ¯æå¼æºï¼ |
| | | * |
| | | * uChartsÂ®å®æ¹ç½ç« |
| | | * https://www.uCharts.cn |
| | | * |
| | | * 弿ºå°å: |
| | | * https://gitee.com/uCharts/uCharts |
| | | * |
| | | * uni-appæä»¶å¸åºå°åï¼ |
| | | * http://ext.dcloud.net.cn/plugin?id=271 |
| | | * |
| | | */ |
| | | |
| | | // 主é¢é¢è²é
ç½®ï¼å¦æ¯ä¸ªå¾è¡¨ç±»åéè¦ä¸å主é¢ï¼è¯·å¨å¯¹åºå¾è¡¨ç±»å䏿´æ¹color屿§ |
| | | const color = ['#1890FF', '#91CB74', '#FAC858', '#EE6666', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc']; |
| | | |
| | | //äºä»¶è½¬æ¢å½æ°ï¼ä¸»è¦ç¨ä½æ ¼å¼åx轴为æ¶é´è½´ï¼æ ¹æ®éæ±èªè¡ä¿®æ¹ |
| | | const formatDateTime = (timeStamp, returnType)=>{ |
| | | var date = new Date(); |
| | | date.setTime(timeStamp * 1000); |
| | | var y = date.getFullYear(); |
| | | var m = date.getMonth() + 1; |
| | | m = m < 10 ? ('0' + m) : m; |
| | | var d = date.getDate(); |
| | | d = d < 10 ? ('0' + d) : d; |
| | | var h = date.getHours(); |
| | | h = h < 10 ? ('0' + h) : h; |
| | | var minute = date.getMinutes(); |
| | | var second = date.getSeconds(); |
| | | minute = minute < 10 ? ('0' + minute) : minute; |
| | | second = second < 10 ? ('0' + second) : second; |
| | | if(returnType == 'full'){return y + '-' + m + '-' + d + ' '+ h +':' + minute + ':' + second;} |
| | | if(returnType == 'y-m-d'){return y + '-' + m + '-' + d;} |
| | | if(returnType == 'h:m'){return h +':' + minute;} |
| | | if(returnType == 'h:m:s'){return h +':' + minute +':' + second;} |
| | | return [y, m, d, h, minute, second]; |
| | | } |
| | | |
| | | const cfu = { |
| | | //demotype为èªå®ä¹å¾è¡¨ç±»åï¼ä¸è¬ä¸éè¦èªå®ä¹å¾è¡¨ç±»åï¼åªéè¦æ¹æ ¹èç¹ä¸å¯¹åºçç±»åå³å¯ |
| | | "type":["pie","ring","rose","word","funnel","map","arcbar","line","column","mount","bar","area","radar","gauge","candle","mix","tline","tarea","scatter","bubble","demotype"], |
| | | "range":["饼ç¶å¾","åç¯å¾","ç«ç°å¾","è¯äºå¾","æ¼æå¾","å°å¾","åå¼§è¿åº¦æ¡","æçº¿å¾","æ±ç¶å¾","山峰å¾","æ¡ç¶å¾","åºåå¾","é·è¾¾å¾","仪表ç","K线å¾","æ··åå¾","æ¶é´è½´æçº¿","æ¶é´è½´åºå","æ£ç¹å¾","æ°æ³¡å¾","èªå®ä¹ç±»å"], |
| | | //å¢å èªå®ä¹å¾è¡¨ç±»åï¼å¦æéè¦categoriesï¼è¯·å¨è¿éå å
¥æ¨çå¾è¡¨ç±»åï¼ä¾å¦æåç"demotype" |
| | | //èªå®ä¹ç±»åæ¶éè¦æ³¨æ"tline","tarea","scatter","bubble"çæ¶é´è½´ï¼ç¢éxè½´ï¼ç±»å¾è¡¨ï¼æ²¡æcategoriesï¼ä¸éè¦å å
¥categories |
| | | "categories":["line","column","mount","bar","area","radar","gauge","candle","mix","demotype"], |
| | | //instance为å®ä¾åéæ¿è½½å±æ§ï¼ä¸è¦å é¤ |
| | | "instance":{}, |
| | | //option为optsåeoptsæ¿è½½å±æ§ï¼ä¸è¦å é¤ |
| | | "option":{}, |
| | | //ä¸é¢æ¯èªå®ä¹formaté
ç½®ï¼å é¤H5端å¤çå
¶ä»ç«¯æ æ³éè¿propsä¼ é彿°ï¼åªè½éè¿æ¤å±æ§å¯¹åºä¸æ çæ¹å¼æ¥æ¿æ¢ |
| | | "formatter":{ |
| | | "yAxisDemo1":function(val, index, opts){return val+'å
'}, |
| | | "yAxisDemo2":function(val, index, opts){return val.toFixed(2)}, |
| | | "xAxisDemo1":function(val, index, opts){return val+'å¹´';}, |
| | | "xAxisDemo2":function(val, index, opts){return formatDateTime(val,'h:m')}, |
| | | "seriesDemo1":function(val, index, series, opts){return val+'å
'}, |
| | | "tooltipDemo1":function(item, category, index, opts){ |
| | | if(index==0){ |
| | | return 'é便ç¨'+item.data+'å¹´' |
| | | }else{ |
| | | return 'å
¶ä»ææ²¡æ¹'+item.data+'天' |
| | | } |
| | | }, |
| | | "pieDemo":function(val, index, series, opts){ |
| | | if(index !== undefined){ |
| | | return series[index].name+'ï¼'+series[index].data+'å
' |
| | | } |
| | | }, |
| | | }, |
| | | //è¿éæ¼ç¤ºäºèªå®ä¹æ¨çå¾è¡¨ç±»åçoptionï¼å¯ä»¥éæå½åï¼ä¹åå¨ç»ä»¶ä¸ type="demotype" åï¼ç»ä»¶ä¼è°ç¨è¿ä¸ªè±æ¬å·éçoptionï¼å¦æç»ä»¶ä¸è¿åå¨optsåæ°ï¼ä¼å°demotypeä¸optsä¸optionå并忏²æå¾è¡¨ã |
| | | "demotype":{ |
| | | //æè¿éææ²çº¿å¾å½åäºèªå®ä¹å¾è¡¨ç±»åï¼æ¨å¯ä»¥æ ¹æ®éè¦éææå®ç±»åæé
ç½® |
| | | "type": "line", |
| | | "color": color, |
| | | "padding": [15,10,0,15], |
| | | "xAxis": { |
| | | "disableGrid": true, |
| | | }, |
| | | "yAxis": { |
| | | "gridType": "dash", |
| | | "dashLength": 2, |
| | | }, |
| | | "legend": { |
| | | }, |
| | | "extra": { |
| | | "line": { |
| | | "type": "curve", |
| | | "width": 2 |
| | | }, |
| | | } |
| | | }, |
| | | //ä¸é¢æ¯èªå®ä¹é
ç½®ï¼è¯·æ·»å é¡¹ç®æéçéç¨é
ç½® |
| | | "pie":{ |
| | | "type": "pie", |
| | | "color": color, |
| | | "padding": [5,5,5,5], |
| | | "extra": { |
| | | "pie": { |
| | | "activeOpacity": 0.5, |
| | | "activeRadius": 10, |
| | | "offsetAngle": 0, |
| | | "labelWidth": 15, |
| | | "border": true, |
| | | "borderWidth": 3, |
| | | "borderColor": "#FFFFFF" |
| | | }, |
| | | } |
| | | }, |
| | | "ring":{ |
| | | "type": "ring", |
| | | "color": color, |
| | | "padding": [5,5,5,5], |
| | | "rotate": false, |
| | | "dataLabel": true, |
| | | "legend": { |
| | | "show": true, |
| | | "position": "right", |
| | | "lineHeight": 25, |
| | | }, |
| | | "title": { |
| | | "name": "æ¶çç", |
| | | "fontSize": 15, |
| | | "color": "#666666" |
| | | }, |
| | | "subtitle": { |
| | | "name": "70%", |
| | | "fontSize": 25, |
| | | "color": "#7cb5ec" |
| | | }, |
| | | "extra": { |
| | | "ring": { |
| | | "ringWidth":30, |
| | | "activeOpacity": 0.5, |
| | | "activeRadius": 10, |
| | | "offsetAngle": 0, |
| | | "labelWidth": 15, |
| | | "border": true, |
| | | "borderWidth": 3, |
| | | "borderColor": "#FFFFFF" |
| | | }, |
| | | }, |
| | | }, |
| | | "rose":{ |
| | | "type": "rose", |
| | | "color": color, |
| | | "padding": [5,5,5,5], |
| | | "legend": { |
| | | "show": true, |
| | | "position": "left", |
| | | "lineHeight": 25, |
| | | }, |
| | | "extra": { |
| | | "rose": { |
| | | "type": "area", |
| | | "minRadius": 50, |
| | | "activeOpacity": 0.5, |
| | | "activeRadius": 10, |
| | | "offsetAngle": 0, |
| | | "labelWidth": 15, |
| | | "border": false, |
| | | "borderWidth": 2, |
| | | "borderColor": "#FFFFFF" |
| | | }, |
| | | } |
| | | }, |
| | | "word":{ |
| | | "type": "word", |
| | | "color": color, |
| | | "extra": { |
| | | "word": { |
| | | "type": "normal", |
| | | "autoColors": false |
| | | } |
| | | } |
| | | }, |
| | | "funnel":{ |
| | | "type": "funnel", |
| | | "color": color, |
| | | "padding": [15,15,0,15], |
| | | "extra": { |
| | | "funnel": { |
| | | "activeOpacity": 0.3, |
| | | "activeWidth": 10, |
| | | "border": true, |
| | | "borderWidth": 2, |
| | | "borderColor": "#FFFFFF", |
| | | "fillOpacity": 1, |
| | | "labelAlign": "right" |
| | | }, |
| | | } |
| | | }, |
| | | "map":{ |
| | | "type": "map", |
| | | "color": color, |
| | | "padding": [0,0,0,0], |
| | | "dataLabel": true, |
| | | "extra": { |
| | | "map": { |
| | | "border": true, |
| | | "borderWidth": 1, |
| | | "borderColor": "#666666", |
| | | "fillOpacity": 0.6, |
| | | "activeBorderColor": "#F04864", |
| | | "activeFillColor": "#FACC14", |
| | | "activeFillOpacity": 1 |
| | | }, |
| | | } |
| | | }, |
| | | "arcbar":{ |
| | | "type": "arcbar", |
| | | "color": color, |
| | | "title": { |
| | | "name": "ç¾åæ¯", |
| | | "fontSize": 25, |
| | | "color": "#00FF00" |
| | | }, |
| | | "subtitle": { |
| | | "name": "é»è®¤æ é¢", |
| | | "fontSize": 15, |
| | | "color": "#666666" |
| | | }, |
| | | "extra": { |
| | | "arcbar": { |
| | | "type": "default", |
| | | "width": 12, |
| | | "backgroundColor": "#E9E9E9", |
| | | "startAngle": 0.75, |
| | | "endAngle": 0.25, |
| | | "gap": 2 |
| | | } |
| | | } |
| | | }, |
| | | "line":{ |
| | | "type": "line", |
| | | "color": color, |
| | | "padding": [15,10,0,15], |
| | | "xAxis": { |
| | | "disableGrid": true, |
| | | }, |
| | | "yAxis": { |
| | | "gridType": "dash", |
| | | "dashLength": 2, |
| | | }, |
| | | "legend": { |
| | | }, |
| | | "extra": { |
| | | "line": { |
| | | "type": "straight", |
| | | "width": 2, |
| | | "activeType": "hollow" |
| | | }, |
| | | } |
| | | }, |
| | | "tline":{ |
| | | "type": "line", |
| | | "color": color, |
| | | "padding": [15,10,0,15], |
| | | "xAxis": { |
| | | "disableGrid": false, |
| | | "boundaryGap":"justify", |
| | | }, |
| | | "yAxis": { |
| | | "gridType": "dash", |
| | | "dashLength": 2, |
| | | "data":[ |
| | | { |
| | | "min":0, |
| | | "max":80 |
| | | } |
| | | ] |
| | | }, |
| | | "legend": { |
| | | }, |
| | | "extra": { |
| | | "line": { |
| | | "type": "curve", |
| | | "width": 2, |
| | | "activeType": "hollow" |
| | | }, |
| | | } |
| | | }, |
| | | "tarea":{ |
| | | "type": "area", |
| | | "color": color, |
| | | "padding": [15,10,0,15], |
| | | "xAxis": { |
| | | "disableGrid": true, |
| | | "boundaryGap":"justify", |
| | | }, |
| | | "yAxis": { |
| | | "gridType": "dash", |
| | | "dashLength": 2, |
| | | "data":[ |
| | | { |
| | | "min":0, |
| | | "max":80 |
| | | } |
| | | ] |
| | | }, |
| | | "legend": { |
| | | }, |
| | | "extra": { |
| | | "area": { |
| | | "type": "curve", |
| | | "opacity": 0.2, |
| | | "addLine": true, |
| | | "width": 2, |
| | | "gradient": true, |
| | | "activeType": "hollow" |
| | | }, |
| | | } |
| | | }, |
| | | "column":{ |
| | | "type": "column", |
| | | "color": color, |
| | | "padding": [15,15,0,5], |
| | | "xAxis": { |
| | | "disableGrid": true, |
| | | }, |
| | | "yAxis": { |
| | | "data":[{"min":0}] |
| | | }, |
| | | "legend": { |
| | | }, |
| | | "extra": { |
| | | "column": { |
| | | "type": "group", |
| | | "width": 30, |
| | | "activeBgColor": "#000000", |
| | | "activeBgOpacity": 0.08 |
| | | }, |
| | | } |
| | | }, |
| | | "mount":{ |
| | | "type": "mount", |
| | | "color": color, |
| | | "padding": [15,15,0,5], |
| | | "xAxis": { |
| | | "disableGrid": true, |
| | | }, |
| | | "yAxis": { |
| | | "data":[{"min":0}] |
| | | }, |
| | | "legend": { |
| | | }, |
| | | "extra": { |
| | | "mount": { |
| | | "type": "mount", |
| | | "widthRatio": 1.5, |
| | | }, |
| | | } |
| | | }, |
| | | "bar":{ |
| | | "type": "bar", |
| | | "color": color, |
| | | "padding": [15,30,0,5], |
| | | "xAxis": { |
| | | "boundaryGap":"justify", |
| | | "disableGrid":false, |
| | | "min":0, |
| | | "axisLine":false |
| | | }, |
| | | "yAxis": { |
| | | }, |
| | | "legend": { |
| | | }, |
| | | "extra": { |
| | | "bar": { |
| | | "type": "group", |
| | | "width": 30, |
| | | "meterBorde": 1, |
| | | "meterFillColor": "#FFFFFF", |
| | | "activeBgColor": "#000000", |
| | | "activeBgOpacity": 0.08 |
| | | }, |
| | | } |
| | | }, |
| | | "area":{ |
| | | "type": "area", |
| | | "color": color, |
| | | "padding": [15,15,0,15], |
| | | "xAxis": { |
| | | "disableGrid": true, |
| | | }, |
| | | "yAxis": { |
| | | "gridType": "dash", |
| | | "dashLength": 2, |
| | | }, |
| | | "legend": { |
| | | }, |
| | | "extra": { |
| | | "area": { |
| | | "type": "straight", |
| | | "opacity": 0.2, |
| | | "addLine": true, |
| | | "width": 2, |
| | | "gradient": false, |
| | | "activeType": "hollow" |
| | | }, |
| | | } |
| | | }, |
| | | "radar":{ |
| | | "type": "radar", |
| | | "color": color, |
| | | "padding": [5,5,5,5], |
| | | "dataLabel": false, |
| | | "legend": { |
| | | "show": true, |
| | | "position": "right", |
| | | "lineHeight": 25, |
| | | }, |
| | | "extra": { |
| | | "radar": { |
| | | "gridType": "radar", |
| | | "gridColor": "#CCCCCC", |
| | | "gridCount": 3, |
| | | "opacity": 0.2, |
| | | "max": 200, |
| | | "labelShow": true |
| | | }, |
| | | } |
| | | }, |
| | | "gauge":{ |
| | | "type": "gauge", |
| | | "color": color, |
| | | "title": { |
| | | "name": "66Km/H", |
| | | "fontSize": 25, |
| | | "color": "#2fc25b", |
| | | "offsetY": 50 |
| | | }, |
| | | "subtitle": { |
| | | "name": "宿¶é度", |
| | | "fontSize": 15, |
| | | "color": "#1890ff", |
| | | "offsetY": -50 |
| | | }, |
| | | "extra": { |
| | | "gauge": { |
| | | "type": "default", |
| | | "width": 30, |
| | | "labelColor": "#666666", |
| | | "startAngle": 0.75, |
| | | "endAngle": 0.25, |
| | | "startNumber": 0, |
| | | "endNumber": 100, |
| | | "labelFormat": "", |
| | | "splitLine": { |
| | | "fixRadius": 0, |
| | | "splitNumber": 10, |
| | | "width": 30, |
| | | "color": "#FFFFFF", |
| | | "childNumber": 5, |
| | | "childWidth": 12 |
| | | }, |
| | | "pointer": { |
| | | "width": 24, |
| | | "color": "auto" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "candle":{ |
| | | "type": "candle", |
| | | "color": color, |
| | | "padding": [15,15,0,15], |
| | | "enableScroll": true, |
| | | "enableMarkLine": true, |
| | | "dataLabel": false, |
| | | "xAxis": { |
| | | "labelCount": 4, |
| | | "itemCount": 40, |
| | | "disableGrid": true, |
| | | "gridColor": "#CCCCCC", |
| | | "gridType": "solid", |
| | | "dashLength": 4, |
| | | "scrollShow": true, |
| | | "scrollAlign": "left", |
| | | "scrollColor": "#A6A6A6", |
| | | "scrollBackgroundColor": "#EFEBEF" |
| | | }, |
| | | "yAxis": { |
| | | }, |
| | | "legend": { |
| | | }, |
| | | "extra": { |
| | | "candle": { |
| | | "color": { |
| | | "upLine": "#f04864", |
| | | "upFill": "#f04864", |
| | | "downLine": "#2fc25b", |
| | | "downFill": "#2fc25b" |
| | | }, |
| | | "average": { |
| | | "show": true, |
| | | "name": ["MA5","MA10","MA30"], |
| | | "day": [5,10,20], |
| | | "color": ["#1890ff","#2fc25b","#facc14"] |
| | | } |
| | | }, |
| | | "markLine": { |
| | | "type": "dash", |
| | | "dashLength": 5, |
| | | "data": [ |
| | | { |
| | | "value": 2150, |
| | | "lineColor": "#f04864", |
| | | "showLabel": true |
| | | }, |
| | | { |
| | | "value": 2350, |
| | | "lineColor": "#f04864", |
| | | "showLabel": true |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | | "mix":{ |
| | | "type": "mix", |
| | | "color": color, |
| | | "padding": [15,15,0,15], |
| | | "xAxis": { |
| | | "disableGrid": true, |
| | | }, |
| | | "yAxis": { |
| | | "disabled": false, |
| | | "disableGrid": false, |
| | | "splitNumber": 5, |
| | | "gridType": "dash", |
| | | "dashLength": 4, |
| | | "gridColor": "#CCCCCC", |
| | | "padding": 10, |
| | | "showTitle": true, |
| | | "data": [] |
| | | }, |
| | | "legend": { |
| | | }, |
| | | "extra": { |
| | | "mix": { |
| | | "column": { |
| | | "width": 20 |
| | | } |
| | | }, |
| | | } |
| | | }, |
| | | "scatter":{ |
| | | "type": "scatter", |
| | | "color":color, |
| | | "padding":[15,15,0,15], |
| | | "dataLabel":false, |
| | | "xAxis": { |
| | | "disableGrid": false, |
| | | "gridType":"dash", |
| | | "splitNumber":5, |
| | | "boundaryGap":"justify", |
| | | "min":0 |
| | | }, |
| | | "yAxis": { |
| | | "disableGrid": false, |
| | | "gridType":"dash", |
| | | }, |
| | | "legend": { |
| | | }, |
| | | "extra": { |
| | | "scatter": { |
| | | }, |
| | | } |
| | | }, |
| | | "bubble":{ |
| | | "type": "bubble", |
| | | "color":color, |
| | | "padding":[15,15,0,15], |
| | | "xAxis": { |
| | | "disableGrid": false, |
| | | "gridType":"dash", |
| | | "splitNumber":5, |
| | | "boundaryGap":"justify", |
| | | "min":0, |
| | | "max":250 |
| | | }, |
| | | "yAxis": { |
| | | "disableGrid": false, |
| | | "gridType":"dash", |
| | | "data":[{ |
| | | "min":0, |
| | | "max":150 |
| | | }] |
| | | }, |
| | | "legend": { |
| | | }, |
| | | "extra": { |
| | | "bubble": { |
| | | "border":2, |
| | | "opacity": 0.5, |
| | | }, |
| | | } |
| | | } |
| | | } |
| | | |
| | | export default cfu; |