MCPcopy
hub / github.com/apache/echarts / getItemAlign

Function getItemAlign

src/component/visualMap/helper.ts:40–72  ·  view source on GitHub ↗
(
    visualMapModel: VisualMapModel,
    api: ExtensionAPI,
    itemSize: number[]
)

Source from the content-addressed store, hash-verified

38 * @return {string} 'left' or 'right' or 'top' or 'bottom'
39 */
40export function getItemAlign(
41 visualMapModel: VisualMapModel,
42 api: ExtensionAPI,
43 itemSize: number[]
44): ItemAlign {
45 const modelOption = visualMapModel.option;
46 const itemAlign = modelOption.align;
47
48 if (itemAlign != null && itemAlign !== 'auto') {
49 return itemAlign as ItemAlign;
50 }
51
52 // Auto decision align.
53 const ecSize = {width: api.getWidth(), height: api.getHeight()};
54 const realIndex = modelOption.orient === 'horizontal' ? 1 : 0;
55
56 const reals = paramsSet[realIndex];
57 const fakeValue = [0, null, 10];
58
59 const layoutInput = {} as Record<ItemAlign, number | string>;
60 for (let i = 0; i < 3; i++) {
61 layoutInput[paramsSet[1 - realIndex][i]] = fakeValue[i];
62 layoutInput[reals[i]] = i === 2 ? itemSize[0] : modelOption[reals[i]];
63 }
64
65 const rParam = ([['x', 'width', 3], ['y', 'height', 0]] as const)[realIndex];
66 const rect = getLayoutRect(layoutInput, ecSize, modelOption.padding);
67
68 return reals[
69 (rect.margin[rParam[2]] || 0) + rect[rParam[0]] + rect[rParam[1]] * 0.5
70 < ecSize[rParam[1]] * 0.5 ? 0 : 1
71 ];
72}
73
74/**
75 * Prepare dataIndex for outside usage, where dataIndex means rawIndex, and

Callers

nothing calls this directly

Calls 3

getLayoutRectFunction · 0.90
getWidthMethod · 0.65
getHeightMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…