MCPcopy Create free account
hub / github.com/apache/echarts / _layout

Method _layout

src/component/timeline/SliderTimelineView.ts:166–264  ·  view source on GitHub ↗
(timelineModel: SliderTimelineModel, api: ExtensionAPI)

Source from the content-addressed store, hash-verified

164 }
165
166 private _layout(timelineModel: SliderTimelineModel, api: ExtensionAPI): LayoutInfo {
167 const labelPosOpt = timelineModel.get(['label', 'position']);
168 const orient = timelineModel.get('orient');
169 const viewRect = getViewRect(timelineModel, api);
170 let parsedLabelPos: number | '+' | '-';
171 // Auto label offset.
172 if (labelPosOpt == null || labelPosOpt === 'auto') {
173 parsedLabelPos = orient === 'horizontal'
174 ? ((viewRect.y + viewRect.height / 2) < api.getHeight() / 2 ? '-' : '+')
175 : ((viewRect.x + viewRect.width / 2) < api.getWidth() / 2 ? '+' : '-');
176 }
177 else if (isString(labelPosOpt)) {
178 parsedLabelPos = ({
179 horizontal: {top: '-', bottom: '+'},
180 vertical: {left: '-', right: '+'}
181 } as const)[orient][labelPosOpt];
182 }
183 else {
184 // is number
185 parsedLabelPos = labelPosOpt;
186 }
187
188 const labelAlignMap = {
189 horizontal: 'center',
190 vertical: (parsedLabelPos >= 0 || parsedLabelPos === '+') ? 'left' : 'right'
191 };
192
193 const labelBaselineMap = {
194 horizontal: (parsedLabelPos >= 0 || parsedLabelPos === '+') ? 'top' : 'bottom',
195 vertical: 'middle'
196 };
197 const rotationMap = {
198 horizontal: 0,
199 vertical: PI / 2
200 };
201
202 // Position
203 const mainLength = orient === 'vertical' ? viewRect.height : viewRect.width;
204
205 const controlModel = timelineModel.getModel('controlStyle');
206 const showControl = controlModel.get('show', true);
207 const controlSize = showControl ? controlModel.get('itemSize') : 0;
208 const controlGap = showControl ? controlModel.get('itemGap') : 0;
209 const sizePlusGap = controlSize + controlGap;
210
211 // Special label rotate.
212 let labelRotation = timelineModel.get(['label', 'rotate']) || 0;
213 labelRotation = labelRotation * PI / 180; // To radian.
214
215 let playPosition: number[];
216 let prevBtnPosition: number[];
217 let nextBtnPosition: number[];
218 const controlPosition = controlModel.get('position', true);
219 const showPlayBtn = showControl && controlModel.get('showPlayBtn', true);
220 const showPrevBtn = showControl && controlModel.get('showPrevBtn', true);
221 const showNextBtn = showControl && controlModel.get('showNextBtn', true);
222 let xLeft = 0;
223 let xRight = mainLength;

Callers 1

renderMethod · 0.95

Calls 5

getViewRectFunction · 0.70
getHeightMethod · 0.65
getWidthMethod · 0.65
getMethod · 0.45
getModelMethod · 0.45

Tested by

no test coverage detected