3D固定柱状图.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. /*
  2. * @description: 配置,参考https://g2plot.antv.antgroup.com/examples
  3. * @Date: 2023-03-27 14:38:23
  4. * @Author: xing.heng
  5. */
  6. import * as echarts from 'echarts'
  7. // 配置版本号
  8. const version = '2023071001'
  9. // 分类
  10. const category = 'Column'
  11. // 标题
  12. const title = '3D固定柱状图'
  13. // 类别, new Line()
  14. const chartType = 'Column'
  15. // 用于标识,唯一,和文件夹名称一致
  16. const name = 'FenZuZhuZhuangTu'
  17. // 右侧配置项
  18. const setting = [
  19. {
  20. label: '维度',
  21. type: 'select', // 设置组件类型
  22. field: 'xField', // 字段
  23. optionField: 'xField', // 对应options中的字段
  24. // 是否多选
  25. multiple: false,
  26. value: '',
  27. tabName: 'data'
  28. },
  29. {
  30. label: '指标',
  31. type: 'select', // 设置组件类型
  32. field: 'yField', // 字段
  33. optionField: 'yField', // 对应options中的字段
  34. // 是否多选
  35. multiple: false,
  36. value: '',
  37. tabName: 'data'
  38. },
  39. {
  40. label: '分组字段',
  41. type: 'select', // 设置组件类型
  42. field: 'seriesField', // 字段
  43. optionField: 'seriesField', // 对应options中的字段
  44. // 是否多选
  45. multiple: false,
  46. value: '',
  47. tabName: 'data'
  48. },
  49. {
  50. label: '柱子顶部颜色',
  51. type: 'colorPicker', // 设置组件类型
  52. field: 'seriesCustom_barTopColor', // 字段
  53. optionField: 'seriesCustom.barTopColor', // 对应options中的字段
  54. value: '#2DB1EF',
  55. tabName: 'custom',
  56. groupName: 'graph'
  57. },
  58. {
  59. label: '柱子颜色1',
  60. type: 'colorPicker', // 设置组件类型
  61. field: 'seriesCustom_barColor1', // 字段
  62. optionField: 'seriesCustom.barColor1', // 对应options中的字段
  63. value: '#115ba6',
  64. tabName: 'custom',
  65. groupName: 'graph'
  66. },
  67. {
  68. label: '柱子颜色2',
  69. type: 'colorPicker', // 设置组件类型
  70. field: 'seriesCustom_barColor2', // 字段
  71. optionField: 'seriesCustom.barColor2', // 对应options中的字段
  72. value: '#1db0dd',
  73. tabName: 'custom',
  74. groupName: 'graph'
  75. },
  76. {
  77. label: '柱子底部颜色',
  78. type: 'colorPicker', // 设置组件类型
  79. field: 'seriesCustom_barBottomColor', // 字段
  80. optionField: 'seriesCustom.barBottomColor', // 对应options中的字段
  81. value: '#187dcb',
  82. tabName: 'custom',
  83. groupName: 'graph'
  84. },
  85. {
  86. label: '柱子背景顶部颜色',
  87. type: 'colorPicker', // 设置组件类型
  88. field: 'seriesCustom_shadowColor', // 字段
  89. optionField: 'seriesCustom.shadowColor', // 对应options中的字段
  90. value: '#041133',
  91. tabName: 'custom',
  92. groupName: 'graph'
  93. },
  94. {
  95. label: '柱子背景颜色',
  96. type: 'colorPicker', // 设置组件类型
  97. field: 'seriesCustom_shadowTopColor', // 字段
  98. optionField: 'seriesCustom.shadowTopColor', // 对应options中的字段
  99. value: '#142f5a',
  100. tabName: 'custom',
  101. groupName: 'graph'
  102. }
  103. ]
  104. // 配置处理脚本
  105. const optionHandler = ''
  106. // 数据处理脚本
  107. const dataHandler = ''
  108. // 图表配置 new Line('domName', option)
  109. const xData = ['本年话务总量', '本年人工话务量', '每万客户呼入量', '本年话务总量', '本年人工话务量', '每万客户呼入量']
  110. const yData = [300, 1230, 425, 300, 1230, 425]
  111. const maxData = [1500, 1500, 1500, 1500, 1500, 1500]
  112. const option = {
  113. animation: false,
  114. tooltip: {
  115. show: true
  116. },
  117. grid: {
  118. left: '15%',
  119. right: '5%',
  120. bottom: '15%',
  121. z: 100,
  122. containLabel: false,
  123. show: false
  124. },
  125. graphic: {
  126. type: 'group',
  127. bottom: '8%',
  128. left: '10%',
  129. z: 100,
  130. children: [
  131. {
  132. type: 'rect',
  133. left: 0,
  134. bottom: 0,
  135. shape: {
  136. width: 400,
  137. height: 10
  138. },
  139. style: {
  140. fill: '#3f4867'
  141. }
  142. },
  143. {
  144. type: 'polygon',
  145. left: 0,
  146. bottom: 10,
  147. shape: {
  148. // 左上、右上、右下、左下
  149. points: [[40, -50], [360, -50], [400, 0], [0, 0]]
  150. },
  151. style: {
  152. fill: '#303256'
  153. }
  154. }
  155. ]
  156. },
  157. xAxis: [
  158. {
  159. type: 'category',
  160. data: xData,
  161. // 坐标轴刻度设置:x轴数据展示
  162. axisTick: {
  163. show: true,
  164. alignWithLabel: true
  165. },
  166. // 横坐标颜色
  167. nameTextStyle: {
  168. color: '#82b0ec'
  169. },
  170. // 是否显示坐标轴的轴线
  171. axisLine: {
  172. show: false
  173. },
  174. // 坐标轴刻度标签
  175. axisLabel: {
  176. textStyle: {
  177. fontSize: 10,
  178. color: 'rgb(40, 129, 170)'
  179. },
  180. margin: 30
  181. }
  182. },
  183. {
  184. type: 'category',
  185. axisLine: {
  186. show: false
  187. },
  188. axisTick: {
  189. show: false
  190. },
  191. axisLabel: {
  192. show: false
  193. },
  194. splitArea: {
  195. show: false
  196. },
  197. splitLine: {
  198. show: false
  199. },
  200. data: xData
  201. }
  202. ],
  203. yAxis: [
  204. {
  205. show: true, // y轴文本标签显示
  206. type: 'value',
  207. axisLabel: {
  208. textStyle: {
  209. color: 'rgb(40, 129, 170)'
  210. }
  211. },
  212. // 分隔线
  213. splitLine: {
  214. show: false // yAxis.show配置为true时,该配置才有效
  215. },
  216. // y轴轴线是否显示
  217. axisLine: {
  218. show: true
  219. }
  220. }
  221. ],
  222. seriesCustom: {
  223. barTopColor: '#2DB1EF',
  224. barBottomColor: '#187dcb',
  225. barColor1: '#115ba6',
  226. barColor2: '#1db0dd',
  227. shadowColor: '#041133',
  228. shadowTopColor: '#142f5a'
  229. },
  230. series: [
  231. // 顶部
  232. {
  233. type: 'pictorialBar', // 象形柱图
  234. symbol: 'diamond',
  235. symbolOffset: [0, '-50%'], // 上部菱形
  236. symbolSize: [30, 15],
  237. // symbolOffset: [0, -6], // 上部椭圆
  238. symbolPosition: 'end',
  239. z: 12,
  240. label: {
  241. normal: {
  242. show: true,
  243. position: 'top',
  244. fontSize: 15,
  245. fontWeight: 'bold',
  246. color: '#27a7ce'
  247. }
  248. },
  249. color: '#2DB1EF',
  250. data: yData
  251. },
  252. // 底部
  253. {
  254. type: 'pictorialBar',
  255. symbol: 'diamond',
  256. symbolSize: [30, 15],
  257. symbolOffset: ['0%', '50%'], // 下部菱形
  258. // symbolOffset: [0, 7], // 下部椭圆
  259. z: 12,
  260. color: '#187dcb',
  261. data: yData
  262. },
  263. // 柱子
  264. {
  265. type: 'bar',
  266. barWidth: 30,
  267. z: 10,
  268. itemStyle: {
  269. normal: {
  270. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  271. {
  272. offset: 0,
  273. color: '#115ba6'
  274. },
  275. {
  276. offset: 1,
  277. color: '#1db0dd'
  278. }
  279. ]),
  280. opacity: 0.8,
  281. shadowColor: 'rgba(0, 0, 0, 0.5)', // 阴影颜色
  282. shadowBlur: 0 // 阴影模糊值
  283. }
  284. },
  285. data: yData
  286. },
  287. // 阴影柱子
  288. {
  289. type: 'bar',
  290. barWidth: 30,
  291. barGap: '-100%',
  292. itemStyle: {
  293. normal: {
  294. opacity: 0.8,
  295. shadowColor: 'rgba(0, 0, 0, 0.5)', // 阴影颜色
  296. shadowBlur: 0 // 阴影模糊值
  297. }
  298. },
  299. label: {
  300. show: false
  301. },
  302. color: '#041133',
  303. data: maxData
  304. },
  305. // 阴影顶部
  306. {
  307. type: 'pictorialBar', // 象形柱图
  308. symbol: 'diamond',
  309. symbolOffset: [0, '-50%'], // 上部菱形
  310. symbolSize: [30, 15],
  311. // symbolOffset: [0, -6], // 上部椭圆
  312. symbolPosition: 'end',
  313. z: 12,
  314. label: {
  315. normal: {
  316. show: false,
  317. position: 'top',
  318. fontSize: 15,
  319. fontWeight: 'bold',
  320. color: '#27a7ce'
  321. }
  322. },
  323. color: '#142f5a',
  324. data: maxData
  325. }
  326. ]
  327. }
  328. export default {
  329. category,
  330. version,
  331. title,
  332. chartType,
  333. name,
  334. option,
  335. setting,
  336. optionHandler,
  337. dataHandler
  338. }