Skip to content

Commit

Permalink
Merge branch 'master' into fix/pie-label-line
Browse files Browse the repository at this point in the history
  • Loading branch information
linghaoSu committed Oct 23, 2023
2 parents a913d20 + 6ce4dbc commit 301b13d
Show file tree
Hide file tree
Showing 8 changed files with 678 additions and 437 deletions.
780 changes: 382 additions & 398 deletions package-lock.json

Large diffs are not rendered by default.

37 changes: 28 additions & 9 deletions src/chart/sunburst/SunburstPiece.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import * as zrUtil from 'zrender/src/core/util';
import * as graphic from '../../util/graphic';
import { toggleHoverEmphasis, SPECIAL_STATES, DISPLAY_STATES } from '../../util/states';
import {createTextStyle} from '../../label/labelStyle';
import { createTextStyle } from '../../label/labelStyle';
import { TreeNode } from '../../data/Tree';
import SunburstSeriesModel, { SunburstSeriesNodeItemOption, SunburstSeriesOption } from './SunburstSeries';
import GlobalModel from '../../model/Global';
Expand All @@ -29,7 +29,7 @@ import { ColorString } from '../../util/types';
import Model from '../../model/Model';
import { getECData } from '../../util/innerStore';
import { getSectorCornerRadius } from '../helper/sectorHelper';
import {createOrUpdatePatternFromDecal} from '../../util/decal';
import { createOrUpdatePatternFromDecal } from '../../util/decal';
import ExtensionAPI from '../../core/ExtensionAPI';
import { saveOldStyle } from '../../animation/basicTransition';
import { normalizeRadian } from 'zrender/src/contain/util';
Expand Down Expand Up @@ -153,8 +153,8 @@ class SunburstPiece extends graphic.Sector {

const focusOrIndices =
focus === 'ancestor' ? node.getAncestorsIndices()
: focus === 'descendant' ? node.getDescendantIndices()
: focus;
: focus === 'descendant' ? node.getDescendantIndices()
: focus;

toggleHoverEmphasis(this, focusOrIndices, emphasisModel.get('blurScope'), emphasisModel.get('disabled'));
}
Expand Down Expand Up @@ -217,7 +217,12 @@ class SunburstPiece extends graphic.Sector {
let textAlign = getLabelAttr(labelStateModel, 'align');
if (labelPosition === 'outside') {
r = layout.r + labelPadding;
textAlign = midAngle > Math.PI / 2 ? 'right' : 'left';
if (layout.clockwise) {
textAlign = midAngle > Math.PI / 2 ? 'right' : 'left';
}
else {
textAlign = midAngle > -Math.PI * 3 / 2 ? 'right' : 'left';
}
}
else {
if (!textAlign || textAlign === 'center') {
Expand All @@ -232,14 +237,28 @@ class SunburstPiece extends graphic.Sector {
}
else if (textAlign === 'left') {
r = layout.r0 + labelPadding;
if (midAngle > Math.PI / 2 && !isRadianAroundZero(midAngle - Math.PI / 2)) {
textAlign = 'right';
if (layout.clockwise) {
if (midAngle > Math.PI / 2 && !isRadianAroundZero(midAngle - Math.PI / 2)) {
textAlign = 'right';
}
}
else {
if (midAngle > -Math.PI * 3 / 2 && !isRadianAroundZero(midAngle - Math.PI / 2)) {
textAlign = 'right';
}
}
}
else if (textAlign === 'right') {
r = layout.r - labelPadding;
if (midAngle > Math.PI / 2 && !isRadianAroundZero(midAngle - Math.PI / 2)) {
textAlign = 'left';
if (layout.clockwise) {
if (midAngle > Math.PI / 2 && !isRadianAroundZero(midAngle - Math.PI / 2)) {
textAlign = 'left';
}
}
else {
if (midAngle > -Math.PI * 3 / 2 && !isRadianAroundZero(midAngle - Math.PI / 2)) {
textAlign = 'left';
}
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/component/toolbox/ToolboxView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
import { getUID } from '../../util/component';
import Displayable from 'zrender/src/graphic/Displayable';
import ZRText from 'zrender/src/graphic/Text';
import { getFont } from '../../label/labelStyle';

type IconPath = ToolboxFeatureModel['iconPaths'][string];

Expand Down Expand Up @@ -217,13 +218,20 @@ class ToolboxView extends ComponentView {
pathEmphasisState.style = iconStyleEmphasisModel.getItemStyle();

// Text position calculation
// TODO: extract `textStyle` from `iconStyle` and use `createTextStyle`
const textContent = new ZRText({
style: {
text: titlesMap[iconName],
align: iconStyleEmphasisModel.get('textAlign'),
borderRadius: iconStyleEmphasisModel.get('textBorderRadius'),
padding: iconStyleEmphasisModel.get('textPadding'),
fill: null
fill: null,
font: getFont({
fontStyle: iconStyleEmphasisModel.get('textFontStyle'),
fontFamily: iconStyleEmphasisModel.get('textFontFamily'),
fontSize: iconStyleEmphasisModel.get('textFontSize'),
fontWeight: iconStyleEmphasisModel.get('textFontWeight')
}, ecModel)
},
ignore: true
});
Expand Down
4 changes: 4 additions & 0 deletions src/component/toolbox/featureManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ type IconStyle = ItemStyleOption & {
textAlign?: LabelOption['align']
textBorderRadius?: LabelOption['borderRadius']
textPadding?: LabelOption['padding']
textFontFamily?: LabelOption['fontFamily']
textFontSize?: LabelOption['fontSize']
textFontWeight?: LabelOption['fontWeight']
textFontStyle?: LabelOption['fontStyle']
};
export interface ToolboxFeatureOption {

Expand Down
13 changes: 6 additions & 7 deletions src/core/echarts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,20 +412,19 @@ class ECharts extends Eventful<ECEventDefinition> {
let defaultRenderer = 'canvas';
let defaultCoarsePointer: 'auto' | boolean = 'auto';
let defaultUseDirtyRect = false;

if (__DEV__) {
const root = (
/* eslint-disable-next-line */
env.hasGlobalWindow ? window : global
) as any;

defaultRenderer = root.__ECHARTS__DEFAULT__RENDERER__ || defaultRenderer;

defaultCoarsePointer = retrieve2(root.__ECHARTS__DEFAULT__COARSE_POINTER, defaultCoarsePointer);
if (root) {
defaultRenderer = retrieve2(root.__ECHARTS__DEFAULT__RENDERER__, defaultRenderer);
defaultCoarsePointer = retrieve2(root.__ECHARTS__DEFAULT__COARSE_POINTER, defaultCoarsePointer);
defaultUseDirtyRect = retrieve2(root.__ECHARTS__DEFAULT__USE_DIRTY_RECT__, defaultUseDirtyRect);
}

const devUseDirtyRect = root.__ECHARTS__DEFAULT__USE_DIRTY_RECT__;
defaultUseDirtyRect = devUseDirtyRect == null
? defaultUseDirtyRect
: devUseDirtyRect;
}

const zr = this._zr = zrender.init(dom, {
Expand Down
145 changes: 145 additions & 0 deletions src/i18n/langAR.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/**
* Language: Arabic.
*/

export default {

time: {
month: [
'يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو',
'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'
],
monthAbbr: [
'يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو',
'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'
],
dayOfWeek: [
'الأحد', 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'
],
dayOfWeekAbbr: [
'الأحد', 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'
]
},
legend: {
selector: {
all: 'تحديد الكل',
inverse: 'عكس التحديد'
}
},
toolbox: {
brush: {
title: {
rect: 'تحديد صندوقي',
polygon: 'تحديد حلقي',
lineX: 'تحديد أفقي',
lineY: 'تحديد عمودي',
keep: 'الاحتفاظ بالمحدد',
clear: 'إلغاء التحديد'
}
},
dataView: {
title: 'عرض البيانات',
lang: ['عرض البيانات', 'إغلاق', 'تحديث']
},
dataZoom: {
title: {
zoom: 'تكبير',
back: 'استعادة التكبير'
}
},
magicType: {
title: {
line: 'خطوط',
bar: 'أشرطة',
stack: 'تكديس',
tiled: 'مربعات'
}
},
restore: {
title: 'استعادة'
},
saveAsImage: {
title: 'حفظ كملف صورة',
lang: ['للحفظ كصورة انقر بالزر الأيمن']
}
},
series: {
typeNames: {
pie: 'رسم بياني دائري',
bar: 'رسم بياني شريطي',
line: 'رسم بياني خطي',
scatter: 'نقاط مبعثرة',
effectScatter: 'نقاط مبعثرة متموجة',
radar: 'رسم بياني راداري',
tree: 'شجرة',
treemap: 'مخطط شجري',
boxplot: 'مخطط صندوقي',
candlestick: 'مخطط شمعدان',
k: 'رسم بياني خطي من النوع K',
heatmap: 'خريطة حرارية',
map: 'خريطة',
parallel: 'خريطة الإحداثيات المتناظرة',
lines: 'خطوط',
graph: 'مخطط علائقي',
sankey: 'مخطط ثعباني',
funnel: 'مخطط هرمي',
gauge: 'مقياس',
pictorialBar: 'مخطط مصوّر',
themeRiver: 'نمط خريطة النهر',
sunburst: 'مخطط شمسي'
}
},
aria: {
general: {
withTitle: 'هذا رسم بياني حول "{title}".',
withoutTitle: 'هذا رسم بياني.'
},
series: {
single: {
prefix: '',
withName: ' من النوع {seriesType} اسمه {seriesName}.',
withoutName: ' من النوع {seriesType}.'
},
multiple: {
prefix: '. يتكون من {seriesCount} سلسلة.',
withName: ' الـ {seriesId} هي سلسلة من النوع {seriesType} تستعرض {seriesName}.',
withoutName: ' الـ {seriesId} هي سلسلة من النوع {seriesType}.',
separator: {
middle: '، ',
end: '. '
}
}
},
data: {
allData: 'البيانات هي كالتالي: ',
partialData: 'أول {displayCnt} عناصر هي: ',
withName: 'قيمة العنصر {name} هي {value}',
withoutName: '{value}',
separator: {
middle: '، ',
end: '. '
}
}
}


};
4 changes: 3 additions & 1 deletion src/label/labelGuideHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,6 @@ function setLabelLineState(
if (smooth > 0) {
(stateObj.shape as Polyline['shape']).smooth = smooth as number;
}

const styleObj = stateModel.getModel('lineStyle').getLineStyle();
isNormal ? labelLine.useStyle(styleObj) : stateObj.style = styleObj;
}
Expand Down Expand Up @@ -622,6 +621,9 @@ export function setLabelLineStyle(
if (stateObj) {
stateObj.ignore = true;
}
if (!!labelLine) {
setLabelLineState(labelLine, true, stateName, stateModel);
}
continue;
}
// Create labelLine if not exists
Expand Down
Loading

0 comments on commit 301b13d

Please sign in to comment.