MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / buildAxisLabel

Function buildAxisLabel

libs/echarts/echarts.simple.js:40953–41052  ·  view source on GitHub ↗
(axisBuilder, axisModel, opt)

Source from the content-addressed store, hash-verified

40951}
40952
40953function buildAxisLabel(axisBuilder, axisModel, opt) {
40954 var axis = axisModel.axis;
40955 var show = retrieve(opt.axisLabelShow, axisModel.get('axisLabel.show'));
40956
40957 if (!show || axis.scale.isBlank()) {
40958 return;
40959 }
40960
40961 var labelModel = axisModel.getModel('axisLabel');
40962 var labelMargin = labelModel.get('margin');
40963 var labels = axis.getViewLabels();
40964
40965 // Special label rotate.
40966 var labelRotation = (
40967 retrieve(opt.labelRotate, labelModel.get('rotate')) || 0
40968 ) * PI$2 / 180;
40969
40970 var labelLayout = innerTextLayout(opt.rotation, labelRotation, opt.labelDirection);
40971 var rawCategoryData = axisModel.getCategories && axisModel.getCategories(true);
40972
40973 var labelEls = [];
40974 var silent = isLabelSilent(axisModel);
40975 var triggerEvent = axisModel.get('triggerEvent');
40976
40977 each$1(labels, function (labelItem, index) {
40978 var tickValue = labelItem.tickValue;
40979 var formattedLabel = labelItem.formattedLabel;
40980 var rawLabel = labelItem.rawLabel;
40981
40982 var itemLabelModel = labelModel;
40983 if (rawCategoryData && rawCategoryData[tickValue] && rawCategoryData[tickValue].textStyle) {
40984 itemLabelModel = new Model(
40985 rawCategoryData[tickValue].textStyle, labelModel, axisModel.ecModel
40986 );
40987 }
40988
40989 var textColor = itemLabelModel.getTextColor()
40990 || axisModel.get('axisLine.lineStyle.color');
40991
40992 var tickCoord = axis.dataToCoord(tickValue);
40993 var pos = [
40994 tickCoord,
40995 opt.labelOffset + opt.labelDirection * labelMargin
40996 ];
40997
40998 var textEl = new Text({
40999 // Id for animation
41000 anid: 'label_' + tickValue,
41001 position: pos,
41002 rotation: labelLayout.rotation,
41003 silent: silent,
41004 z2: 10
41005 });
41006
41007 setTextStyle(textEl.style, itemLabelModel, {
41008 text: formattedLabel,
41009 textAlign: itemLabelModel.getShallow('align', true)
41010 || labelLayout.textAlign,

Callers 1

echarts.simple.jsFile · 0.70

Calls 9

pushMethod · 0.80
decomposeTransformMethod · 0.80
retrieveFunction · 0.70
each$1Function · 0.70
setTextStyleFunction · 0.70
getMethod · 0.45
getModelMethod · 0.45
addMethod · 0.45
updateTransformMethod · 0.45

Tested by

no test coverage detected