MCPcopy Index your code
hub / github.com/apache/echarts / giveSymbol

Function giveSymbol

src/component/timeline/SliderTimelineView.ts:772–833  ·  view source on GitHub ↗

* Create symbol or update symbol * opt: basic position and event handlers

(
    hostModel: Model<TimelineDataItemOption | TimelineCheckpointStyle>,
    itemStyleModel: Model<TimelineDataItemOption['itemStyle'] | TimelineCheckpointStyle>,
    group: graphic.Group,
    opt: PathProps,
    symbol?: TimelineSymbol,
    callback?: {
        onCreate?: (symbol: TimelineSymbol) => void
        onUpdate?: (symbol: TimelineSymbol) => void
    }
)

Source from the content-addressed store, hash-verified

770 * opt: basic position and event handlers
771 */
772function giveSymbol(
773 hostModel: Model<TimelineDataItemOption | TimelineCheckpointStyle>,
774 itemStyleModel: Model<TimelineDataItemOption['itemStyle'] | TimelineCheckpointStyle>,
775 group: graphic.Group,
776 opt: PathProps,
777 symbol?: TimelineSymbol,
778 callback?: {
779 onCreate?: (symbol: TimelineSymbol) => void
780 onUpdate?: (symbol: TimelineSymbol) => void
781 }
782) {
783 const color = itemStyleModel.get('color');
784
785 if (!symbol) {
786 const symbolType = hostModel.get('symbol');
787 symbol = createSymbol(symbolType, -1, -1, 2, 2, color);
788 symbol.setStyle('strokeNoScale', true);
789 group.add(symbol);
790 callback && callback.onCreate(symbol);
791 }
792 else {
793 symbol.setColor(color);
794 group.add(symbol); // Group may be new, also need to add.
795 callback && callback.onUpdate(symbol);
796 }
797
798 // Style
799 const itemStyle = itemStyleModel.getItemStyle(['color']);
800 symbol.setStyle(itemStyle);
801
802 // Transform and events.
803 opt = merge({
804 rectHover: true,
805 z2: 100
806 }, opt, true);
807
808 const symbolSize = normalizeSymbolSize(hostModel.get('symbolSize'));
809
810 opt.scaleX = symbolSize[0] / 2;
811 opt.scaleY = symbolSize[1] / 2;
812
813 const symbolOffset = normalizeSymbolOffset(hostModel.get('symbolOffset'), symbolSize);
814 if (symbolOffset) {
815 opt.x = (opt.x || 0) + symbolOffset[0];
816 opt.y = (opt.y || 0) + symbolOffset[1];
817 }
818
819 const symbolRotate = hostModel.get('symbolRotate');
820 opt.rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
821
822 symbol.attr(opt);
823
824 // FIXME
825 // (1) When symbol.style.strokeNoScale is true and updateTransform is not performed,
826 // getBoundingRect will return wrong result.
827 // (This is supposed to be resolved in zrender, but it is a little difficult to
828 // leverage performance and auto updateTransform)
829 // (2) All of ancesters of symbol do not scale, so we can just updateTransform symbol.

Callers 2

_renderAxisTickMethod · 0.85
_renderCurrentPointerMethod · 0.85

Calls 11

createSymbolFunction · 0.90
mergeFunction · 0.90
normalizeSymbolSizeFunction · 0.90
normalizeSymbolOffsetFunction · 0.90
setStyleMethod · 0.80
onCreateMethod · 0.80
onUpdateMethod · 0.80
getItemStyleMethod · 0.80
updateTransformMethod · 0.65
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…