| 68 | name: space_name, |
| 69 | type: 'custom', |
| 70 | renderItem(params, api) { |
| 71 | const addressBegin = api.value(1); |
| 72 | const addressEnd = api.value(2); |
| 73 | const allocated = api.value(3); |
| 74 | const start = api.coord([addressBegin, 0]); |
| 75 | const end = api.coord([addressEnd, 0]); |
| 76 | |
| 77 | const allocatedRate = allocated / (addressEnd - addressBegin); |
| 78 | const unAllocatedRate = 1 - allocatedRate; |
| 79 | |
| 80 | const standardH = api.size([0, 1])[1]; |
| 81 | const standardY = start[1] - standardH / 2; |
| 82 | |
| 83 | const allocatedY = standardY + standardH * unAllocatedRate; |
| 84 | const allocatedH = standardH * allocatedRate; |
| 85 | |
| 86 | const unAllocatedY = standardY; |
| 87 | const unAllocatedH = standardH - allocatedH; |
| 88 | |
| 89 | const allocatedShape = echarts.graphic.clipRectByRect( |
| 90 | { |
| 91 | x: start[0], |
| 92 | y: allocatedY, |
| 93 | width: end[0] - start[0], |
| 94 | height: allocatedH, |
| 95 | }, |
| 96 | { |
| 97 | x: params.coordSys.x, |
| 98 | y: params.coordSys.y, |
| 99 | width: params.coordSys.width, |
| 100 | height: params.coordSys.height, |
| 101 | }); |
| 102 | |
| 103 | const unAllocatedShape = echarts.graphic.clipRectByRect( |
| 104 | { |
| 105 | x: start[0], |
| 106 | y: unAllocatedY, |
| 107 | width: end[0] - start[0], |
| 108 | height: unAllocatedH, |
| 109 | }, |
| 110 | { |
| 111 | x: params.coordSys.x, |
| 112 | y: params.coordSys.y, |
| 113 | width: params.coordSys.width, |
| 114 | height: params.coordSys.height, |
| 115 | }); |
| 116 | |
| 117 | const ret = { |
| 118 | type: 'group', |
| 119 | children: [ |
| 120 | { |
| 121 | type: 'rect', |
| 122 | shape: allocatedShape, |
| 123 | style: api.style(), |
| 124 | }, |
| 125 | { |
| 126 | type: 'rect', |
| 127 | shape: unAllocatedShape, |