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

Function updateStyle

src/chart/bar/BarView.ts:984–1075  ·  view source on GitHub ↗
(
    el: BarPossiblePath,
    data: SeriesData,
    dataIndex: number,
    itemModel: Model<BarDataItemOption>,
    layout: RectLayout | SectorLayout,
    seriesModel: BarSeriesModel,
    isHorizontalOrRadial: boolean,
    isPolar: boolean
)

Source from the content-addressed store, hash-verified

982}
983
984function updateStyle(
985 el: BarPossiblePath,
986 data: SeriesData,
987 dataIndex: number,
988 itemModel: Model<BarDataItemOption>,
989 layout: RectLayout | SectorLayout,
990 seriesModel: BarSeriesModel,
991 isHorizontalOrRadial: boolean,
992 isPolar: boolean
993) {
994 const style = data.getItemVisual(dataIndex, 'style');
995
996 if (!isPolar) {
997 const borderRadius = itemModel
998 .get(['itemStyle', 'borderRadius']) as number | number[] || 0;
999 (el as Rect).setShape('r', borderRadius);
1000 }
1001 else if (!seriesModel.get('roundCap')) {
1002 const sectorShape = (el as Sector).shape;
1003 const cornerRadius = getSectorCornerRadius(
1004 itemModel.getModel('itemStyle'),
1005 sectorShape,
1006 true
1007 );
1008 extend(sectorShape, cornerRadius);
1009 (el as Sector).setShape(sectorShape);
1010 }
1011
1012 el.useStyle(style);
1013
1014 const cursorStyle = itemModel.getShallow('cursor');
1015 cursorStyle && (el as Path).attr('cursor', cursorStyle);
1016
1017 const labelPositionOutside = isPolar
1018 ? (isHorizontalOrRadial
1019 ? ((layout as SectorLayout).r >= (layout as SectorLayout).r0 ? 'endArc' : 'startArc')
1020 : ((layout as SectorLayout).endAngle >= (layout as SectorLayout).startAngle
1021 ? 'endAngle'
1022 : 'startAngle'
1023 )
1024 )
1025 : (isHorizontalOrRadial
1026 ? getLabelPositionForHorizontal(layout as RectLayout, seriesModel.coordinateSystem)
1027 : getLabelPositionForVertical(layout as RectLayout, seriesModel.coordinateSystem));
1028
1029 const labelStatesModels = getLabelStatesModels(itemModel);
1030
1031 setLabelStyle(
1032 el, labelStatesModels,
1033 {
1034 labelFetcher: seriesModel,
1035 labelDataIndex: dataIndex,
1036 defaultText: getDefaultLabel(seriesModel.getData(), dataIndex),
1037 inheritColor: style.fill as ColorString,
1038 defaultOpacity: style.opacity,
1039 defaultOutsidePosition: labelPositionOutside as BuiltinTextPosition
1040 }
1041 );

Callers 1

_renderNormalMethod · 0.85

Calls 15

getSectorCornerRadiusFunction · 0.90
getLabelStatesModelsFunction · 0.90
setLabelStyleFunction · 0.90
getDefaultLabelFunction · 0.90
setSectorTextRotationFunction · 0.90
setLabelValueAnimationFunction · 0.90
toggleHoverEmphasisFunction · 0.90
setStatesStylesFromModelFunction · 0.90
extendFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…