|
1 | 1 | import { uniq } from '@antv/util';
|
2 |
| -import { interaction, theme } from '../../adaptor/common'; |
| 2 | +import { theme } from '../../adaptor/common'; |
3 | 3 | import { Params } from '../../core/adaptor';
|
4 | 4 | import { deepAssign, flow } from '../../utils';
|
5 | 5 | import { polygon, edge } from '../../adaptor/geometries';
|
@@ -146,6 +146,39 @@ export function nodeDraggable(params: Params<SankeyOptions>): Params<SankeyOptio
|
146 | 146 | return params;
|
147 | 147 | }
|
148 | 148 |
|
| 149 | +/** |
| 150 | + * Interaction 配置 |
| 151 | + * @param params |
| 152 | + */ |
| 153 | +function interaction(params: Params<SankeyOptions>): Params<SankeyOptions> { |
| 154 | + const { chart, options } = params; |
| 155 | + const { interactions = [] } = options; |
| 156 | + |
| 157 | + const nodeInteractions = [].concat(interactions, options.nodeInteractions || []); |
| 158 | + const edgeInteractions = [].concat(interactions, options.edgeInteractions || []); |
| 159 | + |
| 160 | + const nodeView = chart.views[0]; |
| 161 | + const edgeView = chart.views[1]; |
| 162 | + |
| 163 | + nodeInteractions.forEach((i) => { |
| 164 | + if (i?.enable === false) { |
| 165 | + nodeView.removeInteraction(i.type); |
| 166 | + } else { |
| 167 | + nodeView.interaction(i.type, i.cfg || {}); |
| 168 | + } |
| 169 | + }); |
| 170 | + |
| 171 | + edgeInteractions.forEach((i) => { |
| 172 | + if (i?.enable === false) { |
| 173 | + edgeView.removeInteraction(i.type); |
| 174 | + } else { |
| 175 | + edgeView.interaction(i.type, i.cfg || {}); |
| 176 | + } |
| 177 | + }); |
| 178 | + |
| 179 | + return params; |
| 180 | +} |
| 181 | + |
149 | 182 | /**
|
150 | 183 | * 图适配器
|
151 | 184 | * @param chart
|
|
0 commit comments