Toggle navigation
带zoom轴的散点图
By
h***鸦
2021-02-02 08:51:38
脚本
16
21
作品使用的第三方脚本
数据管理
上传数据
支持小于 5M 任意格式(csv, xlsx, json, xml, ...)的数据文件
上传后可以通过生成的文件链接异步获取托管的数据。
历史数据
0 条
无历史数据
代码修改记录
信息提示
保存作品
对当前截图不满意?你还可以
上传本地截图
重新截图
作品名称
作品描述
标签
geo
grid
legend
markLine
markPoint
bar
effectScatter
line
lines
map
timeline
title
toolbox
tooltip
visualMap
作品默认版本
最新
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
20:11:45
图表已生成
整理代码
刷新
代码
let sourceData = [{ prop_name: "IP联名", prop_value: "无", num: "2760270", itemCount: "288913", prop: "IP联名 / 无", }, { prop_name: "长度", prop_value: "常规", num: "2193954", itemCount: "225673", prop: "长度 / 常规", }, { prop_name: "风格", prop_value: "其它或未提及", num: "2096845", itemCount: "206479", prop: "风格 / 其它或未提及", }, { prop_name: "松紧度", prop_value: "常规", num: "1835864", itemCount: "179823", prop: "松紧度 / 常规", }, { prop_name: "图案", prop_value: "纯色", num: "1381297", itemCount: "148048", prop: "图案 / 纯色", }, { prop_name: "袖型", prop_value: "常规", num: "1313665", itemCount: "145270", prop: "袖型 / 常规", }, { prop_name: "袖长", prop_value: "长袖", num: "1228169", itemCount: "149488", prop: "袖长 / 长袖", }, { prop_name: "主要颜色", prop_value: "白", num: "959038", itemCount: "80275", prop: "主要颜色 / 白", }, { prop_name: "领型", prop_value: "其它", num: "905912", itemCount: "71932", prop: "领型 / 其它", }, ]; let seriesData = sourceData.map(function(item, index, array) { return { name: item["prop"], //实际点的参数 value: [item["num"], item["itemCount"]], }; }); let computeServicesAvgLine = function() { let sum = 0; sourceData.forEach(function(item) { sum += parseInt(item["itemCount"]); }); return sum / sourceData.length; }; let computeSalesAvgLine = function() { let sum = 0; sourceData.forEach(function(item) { sum += parseInt(item["num"]); }); return sum / sourceData.length; }; let avg = { servicesAvgLine: computeServicesAvgLine(), salesAvgLine: computeSalesAvgLine(), }; let seriesLabel = { normal: { show: true, position: "inside", offset: [0, -50], padding: [0, 7], fontSize: 12, color: "#000", textAlign: "left", textBorderColor: "#333", textBorderWidth: 0, backgroundColor: "#fff", borderColor: "#fff", borderWidth: 1, borderRadius: 4, formatter: function(obj) { if (obj.componentType == "series") { return [ obj.name, "销量 " + obj.data.value[0], "销量上新" + obj.data.value[1], ].join("\n"); } }, }, }; option = { title: { text: "女装属性销量驱动表现", x: "center", y: "top", }, tooltip: { trigger: "item", axisPointer: { show: true, type: "cross", lineStyle: { type: "dashed", width: 1, }, }, formatter: function(obj) { if (obj.componentType == "series") { return `
${obj.name}
销量
:${obj.data.value[0]}
销量上新
:${obj.data.value[1]}`; } }, }, label: { fontSize: 8, show: true, formatter: function(params) { return params.name; }, emphasis: { show: true, position: "bottom", }, }, xAxis: { name: "销量", type: "value", scale: true, axisLabel: { formatter: "{value}", fontSize: 8, }, splitLine: { show: false, }, axisLine: { lineStyle: { color: "#3259B8", }, }, }, yAxis: { name: "上新数量", type: "value", scale: true, axisLabel: { formatter: "{value}", fontSize: 8, }, splitLine: { show: false, }, axisLine: { lineStyle: { color: "#3259B8", }, }, }, dataZoom: [{ type: 'slider', show: true, xAxisIndex: [0], start: 0, end: 100 }, { type: 'slider', show: true, yAxisIndex: [0], left: '94%', start: 0, end: 100 }, { type: 'inside', xAxisIndex: [0], start: 1, end: 100 }, { type: 'inside', yAxisIndex: [0], start: 0, end: 100 } ], series: [{ type: "scatter", data: seriesData, label: seriesLabel, symbolSize: function(data, index) { return Math.sqrt(data[0]) / 4e1; }, itemStyle: { normal: { opacity: 0.8, }, color: function(params) { let colorarrays = [ "#2F9323", "#D9B63A", "#2E2AA4", "#9F2E61", "#4D670C", "#BF675F", "#1F814A", "#357F88", "#673509", "#310937", "#1B9637", "#F7393C", ]; return colorarrays[params.dataIndex]; }, }, markLine: { label: { normal: { formatter: function(params) { if (params.dataIndex == 0) { return params.value; } else if (params.dataIndex == 1) { return params.value; } return params.value; }, }, }, lineStyle: { normal: { color: "#626c91", type: "bashed", width: 1, }, emphasis: { color: "#d9def7", }, }, data: [{ xAxis: avg.salesAvgLine, name: "营业额平均线", itemStyle: { normal: { color: "#b84a58", }, }, }, { yAxis: avg.servicesAvgLine, name: "服务能力平均线", itemStyle: { normal: { color: "#b84a58", }, }, }, ], }, markArea: { silent: true, data: [ [{ name: "弱势区", itemStyle: { color: "white", }, label: { show: true, position: "insideBottomRight", fontStyle: "normal", color: "#797979", fontSize: 10, // fontWeight: "blod", }, coord: [avg.salesAvgLine, avg.servicesAvgLine], }, { coord: [Number.MAX_VALUE, 0], }, ], [{ name: "乏力区", itemStyle: { color: "white", }, label: { show: true, position: "insideBottomLeft", fontStyle: "normal", color: "#797979", fontSize: 10, // fontWeight: "blod", }, coord: [0, 0], }, { coord: [avg.salesAvgLine, avg.servicesAvgLine], }, ], [{ name: "强势区", itemStyle: { color: "white", }, label: { show: true, position: "insideTopRight", fontStyle: "normal", color: "#797979", fontSize: 10, // fontWeight: "blod", }, coord: [avg.salesAvgLine, avg.servicesAvgLine], }, { coord: [Number.MAX_VALUE, Number.MAX_VALUE], }, ], [{ name: "潜力区", itemStyle: { color: "white", }, label: { show: true, position: "insideTopLeft", fontStyle: "normal", color: "#797979", fontSize: 10, // fontWeight: "blod", }, coord: [0, Number.MAX_VALUE], }, { coord: [avg.salesAvgLine, avg.servicesAvgLine], }, ], ], }, }, ], };