Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/model/mixin/dataFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ import * as zrUtil from 'zrender/src/core/util';
import {retrieveRawValue} from '../../data/helper/dataProvider';
import {formatTpl} from '../../util/format';
import {
DataHost,
DisplayState,
CallbackDataParams,
ColorString,
ZRColor,
OptionDataValue,
SeriesDataType,
ComponentMainType,
ComponentSubType,
DataHost,
DimensionLoose,
InterpolatableValue
DisplayState,
InterpolatableValue,
OptionDataValue,
SeriesDataType,
ZRColor
} from '../../util/types';
import GlobalModel from '../Global';
import { TooltipMarkupBlockFragment } from '../../component/tooltip/tooltipMarkup';
import { error, makePrintable } from '../../util/log';
import {TooltipMarkupBlockFragment} from '../../component/tooltip/tooltipMarkup';
import {error, makePrintable} from '../../util/log';

const DIMENSION_LABEL_REG = /\{@(.+?)\}/g;

Expand Down Expand Up @@ -140,6 +140,12 @@ export class DataFormatMixin {
if (zrUtil.isFunction(formatter)) {
params.status = status;
params.dimensionIndex = labelDimIndex;
if (params.seriesType === 'pie') {
const sectorShape = data.getItemLayout(dataIndex);
const midAngle = (sectorShape.startAngle + sectorShape.endAngle) / 2;
const nx = Math.cos(midAngle);
params.labelSide = nx > 0 ? 'right' : 'left';
}
return formatter(params);
}
else if (zrUtil.isString(formatter)) {
Expand Down
2 changes: 2 additions & 0 deletions src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,8 @@ export interface CallbackDataParams {

// Param name list for mapping `a`, `b`, `c`, `d`, `e`
$vars: string[];
// Pie chart label orientation
labelSide?: string;
}
export type InterpolatableValue = ParsedValue | ParsedValue[];

Expand Down
54 changes: 54 additions & 0 deletions test/pie-label.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.