* Register the visual encoding if this modules required.
(ecModel: GlobalModel, api: ExtensionAPI, payload: Payload)
| 71 | * Register the visual encoding if this modules required. |
| 72 | */ |
| 73 | function brushVisual(ecModel: GlobalModel, api: ExtensionAPI, payload: Payload) { |
| 74 | |
| 75 | const brushSelected: BrushSelectedItem[] = []; |
| 76 | let throttleType; |
| 77 | let throttleDelay; |
| 78 | |
| 79 | ecModel.eachComponent({mainType: 'brush'}, function (brushModel: BrushModel) { |
| 80 | payload && payload.type === 'takeGlobalCursor' && brushModel.setBrushOption( |
| 81 | payload.key === 'brush' ? payload.brushOption : {brushType: false} |
| 82 | ); |
| 83 | }); |
| 84 | |
| 85 | layoutCovers(ecModel); |
| 86 | |
| 87 | |
| 88 | ecModel.eachComponent({mainType: 'brush'}, function (brushModel: BrushModel, brushIndex) { |
| 89 | |
| 90 | const thisBrushSelected: BrushSelectedItem = { |
| 91 | brushId: brushModel.id, |
| 92 | brushIndex: brushIndex, |
| 93 | brushName: brushModel.name, |
| 94 | areas: zrUtil.clone(brushModel.areas), |
| 95 | selected: [] |
| 96 | }; |
| 97 | // Every brush component exists in event params, convenient |
| 98 | // for user to find by index. |
| 99 | brushSelected.push(thisBrushSelected); |
| 100 | |
| 101 | const brushOption = brushModel.option; |
| 102 | const brushLink = brushOption.brushLink; |
| 103 | const linkedSeriesMap: {[seriesIndex: number]: 0 | 1} = []; |
| 104 | const selectedDataIndexForLink: {[dataIndex: number]: 0 | 1} = []; |
| 105 | const rangeInfoBySeries: {[seriesIndex: number]: BrushSelectableArea[]} = []; |
| 106 | let hasBrushExists = false; |
| 107 | |
| 108 | if (!brushIndex) { // Only the first throttle setting works. |
| 109 | throttleType = brushOption.throttleType; |
| 110 | throttleDelay = brushOption.throttleDelay; |
| 111 | } |
| 112 | |
| 113 | // Add boundingRect and selectors to range. |
| 114 | const areas: BrushSelectableArea[] = zrUtil.map(brushModel.areas, function (area) { |
| 115 | const builder = boundingRectBuilders[area.brushType]; |
| 116 | const selectableArea = zrUtil.defaults( |
| 117 | {boundingRect: builder ? builder(area) : void 0}, |
| 118 | area |
| 119 | ) as BrushSelectableArea; |
| 120 | selectableArea.selectors = makeBrushCommonSelectorForSeries(selectableArea); |
| 121 | return selectableArea; |
| 122 | }); |
| 123 | |
| 124 | const visualMappings = visualSolution.createVisualMappings( |
| 125 | brushModel.option, STATE_LIST, function (mappingOption) { |
| 126 | mappingOption.mappingMethod = 'fixed'; |
| 127 | } |
| 128 | ); |
| 129 | |
| 130 | zrUtil.isArray(brushLink) && zrUtil.each(brushLink, function (seriesIndex) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…