| 62 | |
| 63 | |
| 64 | class MagicType extends ToolboxFeature<ToolboxMagicTypeFeatureOption> { |
| 65 | |
| 66 | getIcons() { |
| 67 | const model = this.model; |
| 68 | const availableIcons = model.get('icon'); |
| 69 | const icons: ToolboxMagicTypeFeatureOption['icon'] = {}; |
| 70 | zrUtil.each(model.get('type'), function (type) { |
| 71 | if (availableIcons[type]) { |
| 72 | icons[type] = availableIcons[type]; |
| 73 | } |
| 74 | }); |
| 75 | return icons; |
| 76 | } |
| 77 | |
| 78 | static getDefaultOption(ecModel: GlobalModel) { |
| 79 | const defaultOption: ToolboxMagicTypeFeatureOption = { |
| 80 | show: true, |
| 81 | type: [], |
| 82 | // Icon group |
| 83 | icon: { |
| 84 | line: 'M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4', |
| 85 | bar: 'M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7', |
| 86 | // eslint-disable-next-line |
| 87 | stack: 'M8.2,38.4l-8.4,4.1l30.6,15.3L60,42.5l-8.1-4.1l-21.5,11L8.2,38.4z M51.9,30l-8.1,4.2l-13.4,6.9l-13.9-6.9L8.2,30l-8.4,4.2l8.4,4.2l22.2,11l21.5-11l8.1-4.2L51.9,30z M51.9,21.7l-8.1,4.2L35.7,30l-5.3,2.8L24.9,30l-8.4-4.1l-8.3-4.2l-8.4,4.2L8.2,30l8.3,4.2l13.9,6.9l13.4-6.9l8.1-4.2l8.1-4.1L51.9,21.7zM30.4,2.2L-0.2,17.5l8.4,4.1l8.3,4.2l8.4,4.2l5.5,2.7l5.3-2.7l8.1-4.2l8.1-4.2l8.1-4.1L30.4,2.2z' // jshint ignore:line |
| 88 | }, |
| 89 | // `line`, `bar`, `stack`, `tiled` |
| 90 | title: ecModel.getLocaleModel().get(['toolbox', 'magicType', 'title']), |
| 91 | option: {}, |
| 92 | seriesIndex: {} |
| 93 | }; |
| 94 | |
| 95 | return defaultOption; |
| 96 | } |
| 97 | |
| 98 | onclick(ecModel: GlobalModel, api: ExtensionAPI, type: IconType) { |
| 99 | const model = this.model; |
| 100 | const seriesIndex = model.get(['seriesIndex', type as 'line' | 'bar']); |
| 101 | // Not supported magicType |
| 102 | if (!seriesOptGenreator[type]) { |
| 103 | return; |
| 104 | } |
| 105 | const newOption: ECUnitOption = { |
| 106 | series: [] |
| 107 | }; |
| 108 | const generateNewSeriesTypes = function (seriesModel: SeriesModel<MegicTypeSeriesOption>) { |
| 109 | const seriesType = seriesModel.subType; |
| 110 | const seriesId = seriesModel.id; |
| 111 | const newSeriesOpt = seriesOptGenreator[type]( |
| 112 | seriesType, seriesId, seriesModel, model |
| 113 | ); |
| 114 | if (newSeriesOpt) { |
| 115 | // PENDING If merge original option? |
| 116 | zrUtil.defaults(newSeriesOpt, seriesModel.option); |
| 117 | (newOption.series as SeriesOption[]).push(newSeriesOpt); |
| 118 | } |
| 119 | // Modify boundaryGap |
| 120 | const coordSys = seriesModel.coordinateSystem; |
| 121 | if (coordSys && coordSys.type === 'cartesian2d' && (type === 'line' || type === 'bar')) { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…