@antv/component 2.1.6 → 2.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component.min.js +1 -1
- package/esm/animation/fadeIn.d.ts +1 -1
- package/esm/animation/fadeOut.d.ts +1 -1
- package/esm/animation/utils.d.ts +3 -3
- package/esm/ui/axis/axis.d.ts +1 -1
- package/esm/ui/axis/axis.js +18 -2
- package/esm/ui/axis/axis.js.map +1 -1
- package/esm/ui/axis/classname-map.d.ts +18 -0
- package/esm/ui/axis/classname-map.js +20 -0
- package/esm/ui/axis/classname-map.js.map +1 -0
- package/esm/ui/axis/constant.js +16 -15
- package/esm/ui/axis/constant.js.map +1 -1
- package/esm/ui/axis/guides/grid.d.ts +1 -1
- package/esm/ui/axis/guides/grid.js +8 -1
- package/esm/ui/axis/guides/grid.js.map +1 -1
- package/esm/ui/axis/guides/labels.d.ts +1 -2
- package/esm/ui/axis/guides/labels.js +29 -7
- package/esm/ui/axis/guides/labels.js.map +1 -1
- package/esm/ui/axis/guides/line.js +31 -8
- package/esm/ui/axis/guides/line.js.map +1 -1
- package/esm/ui/axis/guides/ticks.d.ts +1 -1
- package/esm/ui/axis/guides/ticks.js +10 -3
- package/esm/ui/axis/guides/ticks.js.map +1 -1
- package/esm/ui/axis/guides/title.d.ts +1 -1
- package/esm/ui/axis/guides/title.js +6 -2
- package/esm/ui/axis/guides/title.js.map +1 -1
- package/esm/ui/axis/types.d.ts +6 -0
- package/esm/ui/axis/utils/classname.d.ts +46 -0
- package/esm/ui/axis/utils/classname.js +53 -0
- package/esm/ui/axis/utils/classname.js.map +1 -0
- package/esm/ui/axis/utils/index.d.ts +1 -0
- package/esm/ui/axis/utils/index.js +1 -0
- package/esm/ui/axis/utils/index.js.map +1 -1
- package/esm/ui/grid/index.d.ts +1 -1
- package/esm/ui/legend/category/item.d.ts +3 -1
- package/esm/ui/legend/category/item.js +42 -14
- package/esm/ui/legend/category/item.js.map +1 -1
- package/esm/ui/legend/category/items.d.ts +2 -0
- package/esm/ui/legend/category/items.js +12 -9
- package/esm/ui/legend/category/items.js.map +1 -1
- package/esm/ui/legend/category.js +11 -3
- package/esm/ui/legend/category.js.map +1 -1
- package/esm/ui/legend/classname-map.d.ts +37 -0
- package/esm/ui/legend/classname-map.js +38 -0
- package/esm/ui/legend/classname-map.js.map +1 -0
- package/esm/ui/legend/constant.d.ts +1 -0
- package/esm/ui/legend/constant.js +1 -0
- package/esm/ui/legend/constant.js.map +1 -1
- package/esm/ui/legend/continuous/handle.d.ts +1 -0
- package/esm/ui/legend/continuous/handle.js +23 -3
- package/esm/ui/legend/continuous/handle.js.map +1 -1
- package/esm/ui/legend/continuous/ribbon.d.ts +1 -0
- package/esm/ui/legend/continuous/ribbon.js +11 -1
- package/esm/ui/legend/continuous/ribbon.js.map +1 -1
- package/esm/ui/legend/continuous.d.ts +6 -0
- package/esm/ui/legend/continuous.js +77 -10
- package/esm/ui/legend/continuous.js.map +1 -1
- package/esm/ui/legend/title/index.js +5 -1
- package/esm/ui/legend/title/index.js.map +1 -1
- package/esm/ui/legend/title/types.d.ts +1 -0
- package/esm/ui/legend/types.d.ts +1 -0
- package/esm/ui/legend/utils/classname.d.ts +31 -0
- package/esm/ui/legend/utils/classname.js +35 -0
- package/esm/ui/legend/utils/classname.js.map +1 -0
- package/esm/ui/legend/utils/index.d.ts +1 -0
- package/esm/ui/legend/utils/index.js +2 -0
- package/esm/ui/legend/utils/index.js.map +1 -0
- package/esm/ui/navigator/index.js +19 -4
- package/esm/ui/navigator/index.js.map +1 -1
- package/esm/ui/navigator/types.d.ts +1 -0
- package/esm/ui/slider/handle.d.ts +2 -0
- package/esm/ui/slider/handle.js +21 -6
- package/esm/ui/slider/handle.js.map +1 -1
- package/esm/ui/slider/index.js +3 -7
- package/esm/ui/slider/index.js.map +1 -1
- package/esm/util/extend-display-object.d.ts +2 -0
- package/esm/util/extend-display-object.js +7 -1
- package/esm/util/extend-display-object.js.map +1 -1
- package/esm/util/index.d.ts +1 -0
- package/esm/util/index.js +1 -0
- package/esm/util/index.js.map +1 -1
- package/esm/util/keyframe-interpolate.d.ts +1 -1
- package/esm/util/parse-height-from-html.d.ts +1 -0
- package/esm/util/parse-height-from-html.js +95 -0
- package/esm/util/parse-height-from-html.js.map +1 -0
- package/lib/animation/fadeIn.d.ts +1 -1
- package/lib/animation/fadeOut.d.ts +1 -1
- package/lib/animation/utils.d.ts +3 -3
- package/lib/ui/axis/axis.d.ts +1 -1
- package/lib/ui/axis/axis.js +18 -2
- package/lib/ui/axis/axis.js.map +1 -1
- package/lib/ui/axis/classname-map.d.ts +18 -0
- package/lib/ui/axis/classname-map.js +23 -0
- package/lib/ui/axis/classname-map.js.map +1 -0
- package/lib/ui/axis/constant.js +16 -15
- package/lib/ui/axis/constant.js.map +1 -1
- package/lib/ui/axis/guides/grid.d.ts +1 -1
- package/lib/ui/axis/guides/grid.js +8 -1
- package/lib/ui/axis/guides/grid.js.map +1 -1
- package/lib/ui/axis/guides/labels.d.ts +1 -2
- package/lib/ui/axis/guides/labels.js +27 -5
- package/lib/ui/axis/guides/labels.js.map +1 -1
- package/lib/ui/axis/guides/line.js +31 -8
- package/lib/ui/axis/guides/line.js.map +1 -1
- package/lib/ui/axis/guides/ticks.d.ts +1 -1
- package/lib/ui/axis/guides/ticks.js +10 -3
- package/lib/ui/axis/guides/ticks.js.map +1 -1
- package/lib/ui/axis/guides/title.d.ts +1 -1
- package/lib/ui/axis/guides/title.js +6 -2
- package/lib/ui/axis/guides/title.js.map +1 -1
- package/lib/ui/axis/types.d.ts +6 -0
- package/lib/ui/axis/utils/classname.d.ts +46 -0
- package/lib/ui/axis/utils/classname.js +58 -0
- package/lib/ui/axis/utils/classname.js.map +1 -0
- package/lib/ui/axis/utils/index.d.ts +1 -0
- package/lib/ui/axis/utils/index.js +1 -0
- package/lib/ui/axis/utils/index.js.map +1 -1
- package/lib/ui/grid/index.d.ts +1 -1
- package/lib/ui/legend/category/item.d.ts +3 -1
- package/lib/ui/legend/category/item.js +42 -14
- package/lib/ui/legend/category/item.js.map +1 -1
- package/lib/ui/legend/category/items.d.ts +2 -0
- package/lib/ui/legend/category/items.js +11 -8
- package/lib/ui/legend/category/items.js.map +1 -1
- package/lib/ui/legend/category.js +11 -3
- package/lib/ui/legend/category.js.map +1 -1
- package/lib/ui/legend/classname-map.d.ts +37 -0
- package/lib/ui/legend/classname-map.js +41 -0
- package/lib/ui/legend/classname-map.js.map +1 -0
- package/lib/ui/legend/constant.d.ts +1 -0
- package/lib/ui/legend/constant.js +3 -1
- package/lib/ui/legend/constant.js.map +1 -1
- package/lib/ui/legend/continuous/handle.d.ts +1 -0
- package/lib/ui/legend/continuous/handle.js +23 -3
- package/lib/ui/legend/continuous/handle.js.map +1 -1
- package/lib/ui/legend/continuous/ribbon.d.ts +1 -0
- package/lib/ui/legend/continuous/ribbon.js +11 -1
- package/lib/ui/legend/continuous/ribbon.js.map +1 -1
- package/lib/ui/legend/continuous.d.ts +6 -0
- package/lib/ui/legend/continuous.js +76 -9
- package/lib/ui/legend/continuous.js.map +1 -1
- package/lib/ui/legend/title/index.js +5 -1
- package/lib/ui/legend/title/index.js.map +1 -1
- package/lib/ui/legend/title/types.d.ts +1 -0
- package/lib/ui/legend/types.d.ts +1 -0
- package/lib/ui/legend/utils/classname.d.ts +31 -0
- package/lib/ui/legend/utils/classname.js +39 -0
- package/lib/ui/legend/utils/classname.js.map +1 -0
- package/lib/ui/legend/utils/index.d.ts +1 -0
- package/lib/ui/legend/utils/index.js +5 -0
- package/lib/ui/legend/utils/index.js.map +1 -0
- package/lib/ui/navigator/index.js +19 -4
- package/lib/ui/navigator/index.js.map +1 -1
- package/lib/ui/navigator/types.d.ts +1 -0
- package/lib/ui/slider/handle.d.ts +2 -0
- package/lib/ui/slider/handle.js +21 -6
- package/lib/ui/slider/handle.js.map +1 -1
- package/lib/ui/slider/index.js +3 -7
- package/lib/ui/slider/index.js.map +1 -1
- package/lib/util/extend-display-object.d.ts +2 -0
- package/lib/util/extend-display-object.js +7 -0
- package/lib/util/extend-display-object.js.map +1 -1
- package/lib/util/index.d.ts +1 -0
- package/lib/util/index.js +1 -0
- package/lib/util/index.js.map +1 -1
- package/lib/util/keyframe-interpolate.d.ts +1 -1
- package/lib/util/parse-height-from-html.d.ts +1 -0
- package/lib/util/parse-height-from-html.js +99 -0
- package/lib/util/parse-height-from-html.js.map +1 -0
- package/package.json +2 -3
- package/src/ui/axis/axis.ts +19 -2
- package/src/ui/axis/classname-map.ts +22 -0
- package/src/ui/axis/constant.ts +17 -15
- package/src/ui/axis/guides/grid.ts +8 -1
- package/src/ui/axis/guides/labels.ts +35 -9
- package/src/ui/axis/guides/line.ts +50 -12
- package/src/ui/axis/guides/ticks.ts +15 -5
- package/src/ui/axis/guides/title.ts +10 -4
- package/src/ui/axis/types.ts +6 -0
- package/src/ui/axis/utils/classname.ts +62 -0
- package/src/ui/axis/utils/index.ts +1 -0
- package/src/ui/legend/category/item.ts +59 -12
- package/src/ui/legend/category/items.ts +17 -7
- package/src/ui/legend/category.ts +12 -3
- package/src/ui/legend/classname-map.ts +45 -0
- package/src/ui/legend/constant.ts +2 -0
- package/src/ui/legend/continuous/handle.ts +41 -4
- package/src/ui/legend/continuous/ribbon.ts +17 -1
- package/src/ui/legend/continuous.ts +96 -10
- package/src/ui/legend/title/index.ts +5 -1
- package/src/ui/legend/title/types.ts +1 -0
- package/src/ui/legend/types.ts +1 -0
- package/src/ui/legend/utils/classname.ts +39 -0
- package/src/ui/legend/utils/index.ts +1 -0
- package/src/ui/navigator/index.ts +32 -2
- package/src/ui/navigator/types.ts +1 -0
- package/src/ui/slider/handle.ts +44 -6
- package/src/ui/slider/index.ts +3 -4
- package/src/util/extend-display-object.ts +7 -1
- package/src/util/index.ts +1 -0
- package/src/util/parse-height-from-html.ts +94 -0
|
@@ -21,6 +21,8 @@ import { ifHorizontal } from '../utils';
|
|
|
21
21
|
import type { CategoryItemStyleProps } from './item';
|
|
22
22
|
import { CategoryItem } from './item';
|
|
23
23
|
import type { PoptipStyleProps } from '../../poptip/types';
|
|
24
|
+
import { getLegendClassName } from '../utils/classname';
|
|
25
|
+
import { CLASSNAME_SUFFIX_MAP } from '../constant';
|
|
24
26
|
|
|
25
27
|
interface CategoryItemsDatum {
|
|
26
28
|
[keys: string]: any;
|
|
@@ -32,7 +34,12 @@ type CallableItemStyle = CallableStyleProps<
|
|
|
32
34
|
>;
|
|
33
35
|
|
|
34
36
|
export type PoptipRender = {
|
|
35
|
-
render?: (params: {
|
|
37
|
+
render?: (params: {
|
|
38
|
+
label: string | number;
|
|
39
|
+
value: string | number;
|
|
40
|
+
color?: string;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}) => string;
|
|
36
43
|
};
|
|
37
44
|
|
|
38
45
|
export type CategoryItemsStyleProps = GroupStyleProps &
|
|
@@ -57,6 +64,7 @@ export type CategoryItemsStyleProps = GroupStyleProps &
|
|
|
57
64
|
poptip?: PoptipStyleProps & PoptipRender;
|
|
58
65
|
focus?: boolean;
|
|
59
66
|
focusMarkerSize?: number;
|
|
67
|
+
classNamePrefix?: string;
|
|
60
68
|
};
|
|
61
69
|
|
|
62
70
|
export type CategoryItemsOptions = ComponentOptions<CategoryItemsStyleProps>;
|
|
@@ -131,7 +139,7 @@ export class CategoryItems extends Component<CategoryItemsStyleProps> {
|
|
|
131
139
|
}
|
|
132
140
|
|
|
133
141
|
private get renderData() {
|
|
134
|
-
const { data, layout, poptip, focus, focusMarkerSize } = this.attributes;
|
|
142
|
+
const { data, layout, poptip, focus, focusMarkerSize, classNamePrefix } = this.attributes;
|
|
135
143
|
const style = subStyleProps<CategoryItemStyleProps>(this.attributes, 'item');
|
|
136
144
|
|
|
137
145
|
const d = data.map((datum, index) => {
|
|
@@ -146,6 +154,7 @@ export class CategoryItems extends Component<CategoryItemsStyleProps> {
|
|
|
146
154
|
poptip,
|
|
147
155
|
focus,
|
|
148
156
|
focusMarkerSize,
|
|
157
|
+
classNamePrefix,
|
|
149
158
|
...Object.fromEntries(
|
|
150
159
|
Object.entries(style).map(([key, val]) => [key, getCallbackValue(val, [datum, index, data])])
|
|
151
160
|
),
|
|
@@ -250,17 +259,18 @@ export class CategoryItems extends Component<CategoryItemsStyleProps> {
|
|
|
250
259
|
}
|
|
251
260
|
|
|
252
261
|
private renderItems(container: Group) {
|
|
253
|
-
const { click, mouseenter, mouseleave } = this.attributes;
|
|
262
|
+
const { click, mouseenter, mouseleave, classNamePrefix } = this.attributes;
|
|
254
263
|
this.flattenPage(container);
|
|
255
264
|
const dispatchCustomEvent = this.dispatchCustomEvent.bind(this);
|
|
265
|
+
const itemClassName = getLegendClassName(CLASS_NAMES.item.name, CLASSNAME_SUFFIX_MAP.item, classNamePrefix);
|
|
256
266
|
select(container)
|
|
257
267
|
.selectAll(CLASS_NAMES.item.class)
|
|
258
268
|
.data(this.renderData, (d) => d.id)
|
|
259
269
|
.join(
|
|
260
270
|
(enter) =>
|
|
261
271
|
enter
|
|
262
|
-
.append(({ style }) => new CategoryItem({ style }))
|
|
263
|
-
.attr('className',
|
|
272
|
+
.append(({ style, ...rest }) => new CategoryItem({ style }, rest))
|
|
273
|
+
.attr('className', itemClassName)
|
|
264
274
|
.on('click', function () {
|
|
265
275
|
click?.(this);
|
|
266
276
|
dispatchCustomEvent('itemClick', { item: this });
|
|
@@ -311,9 +321,9 @@ export class CategoryItems extends Component<CategoryItemsStyleProps> {
|
|
|
311
321
|
}
|
|
312
322
|
|
|
313
323
|
private renderNavigator(container: Selection) {
|
|
314
|
-
const { orientation } = this.attributes;
|
|
324
|
+
const { orientation, classNamePrefix } = this.attributes;
|
|
315
325
|
const navStyle = subStyleProps(this.attributes, 'nav');
|
|
316
|
-
const style = deepAssign({ orientation }, navStyle);
|
|
326
|
+
const style = deepAssign({ orientation, classNamePrefix }, navStyle);
|
|
317
327
|
const that = this;
|
|
318
328
|
container
|
|
319
329
|
.selectAll(CLASS_NAMES.navigator.class)
|
|
@@ -23,13 +23,13 @@ export class Category extends Component<CategoryStyleProps> {
|
|
|
23
23
|
private items!: Selection<CategoryItems>;
|
|
24
24
|
|
|
25
25
|
private renderTitle(container: Selection, width: number, height: number) {
|
|
26
|
-
const { showTitle, titleText } = this.attributes;
|
|
26
|
+
const { showTitle, titleText, classNamePrefix } = this.attributes;
|
|
27
27
|
const style = subStyleProps<TitleStyleProps>(this.attributes, 'title');
|
|
28
28
|
const [titleStyle, groupStyle] = splitStyle(style);
|
|
29
29
|
|
|
30
30
|
this.titleGroup = container.maybeAppendByClassName<Group>(CLASS_NAMES.titleGroup, 'g').styles(groupStyle);
|
|
31
31
|
|
|
32
|
-
const finalTitleStyle = { width, height, ...titleStyle, text: showTitle ? titleText : '' };
|
|
32
|
+
const finalTitleStyle = { width, height, ...titleStyle, text: showTitle ? titleText : '', classNamePrefix };
|
|
33
33
|
this.title = this.titleGroup
|
|
34
34
|
.maybeAppendByClassName(CLASS_NAMES.title, () => new Title({ style: finalTitleStyle as TitleStyleProps }))
|
|
35
35
|
.update(finalTitleStyle) as Selection<Title>;
|
|
@@ -84,8 +84,17 @@ export class Category extends Component<CategoryStyleProps> {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
render(attributes: Required<CategoryStyleProps>, container: Group) {
|
|
87
|
-
const { width, height, x = 0, y = 0 } = this.attributes;
|
|
87
|
+
const { width, height, x = 0, y = 0, classNamePrefix } = this.attributes;
|
|
88
88
|
const ctn = select(container);
|
|
89
|
+
|
|
90
|
+
// Set root container className
|
|
91
|
+
const baseClassName = container.className || 'legend-category';
|
|
92
|
+
if (classNamePrefix) {
|
|
93
|
+
container.attr('className', `${baseClassName} ${classNamePrefix}legend`);
|
|
94
|
+
} else if (!container.className) {
|
|
95
|
+
container.attr('className', 'legend-category');
|
|
96
|
+
}
|
|
97
|
+
|
|
89
98
|
container.style.transform = `translate(${x}, ${y})`;
|
|
90
99
|
|
|
91
100
|
this.renderTitle(ctn, width!, height!);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* className suffix mapping for legend elements
|
|
3
|
+
* Used to generate prefixed classNames, e.g., classNamePrefix='g2-' generates 'g2-legend-{suffix}'
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* import { CLASSNAME_SUFFIX_MAP, getLegendClassName } from './utils';
|
|
7
|
+
*
|
|
8
|
+
* const titleClassName = getLegendClassName(
|
|
9
|
+
* CLASS_NAMES.text.name,
|
|
10
|
+
* CLASSNAME_SUFFIX_MAP.title,
|
|
11
|
+
* 'g2-'
|
|
12
|
+
* );
|
|
13
|
+
* // Returns: 'title-text g2-legend-title'
|
|
14
|
+
*/
|
|
15
|
+
export const CLASSNAME_SUFFIX_MAP = {
|
|
16
|
+
// Common elements
|
|
17
|
+
title: 'title',
|
|
18
|
+
|
|
19
|
+
// Category legend elements
|
|
20
|
+
item: 'item',
|
|
21
|
+
marker: 'marker',
|
|
22
|
+
label: 'label',
|
|
23
|
+
value: 'value',
|
|
24
|
+
focusIcon: 'focus-icon',
|
|
25
|
+
background: 'background',
|
|
26
|
+
|
|
27
|
+
// Continuous legend elements
|
|
28
|
+
ribbon: 'ribbon',
|
|
29
|
+
track: 'track',
|
|
30
|
+
selection: 'selection',
|
|
31
|
+
handle: 'handle',
|
|
32
|
+
handleMarker: 'handle-marker',
|
|
33
|
+
handleLabel: 'handle-label',
|
|
34
|
+
indicator: 'indicator',
|
|
35
|
+
|
|
36
|
+
// Navigator elements (reserved)
|
|
37
|
+
prevBtn: 'prev-btn',
|
|
38
|
+
nextBtn: 'next-btn',
|
|
39
|
+
pageInfo: 'page-info',
|
|
40
|
+
} as const;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* className suffix type
|
|
44
|
+
*/
|
|
45
|
+
export type ClassNameSuffix = keyof typeof CLASSNAME_SUFFIX_MAP;
|
|
@@ -2,6 +2,8 @@ import { classNames, deepAssign, superStyleProps } from '../../util';
|
|
|
2
2
|
import { DEFAULT_HANDLE_CFG } from './continuous/handle';
|
|
3
3
|
import type { LegendBaseStyleProps } from './types';
|
|
4
4
|
|
|
5
|
+
export { CLASSNAME_SUFFIX_MAP, type ClassNameSuffix } from './classname-map';
|
|
6
|
+
|
|
5
7
|
export const LEGEND_BASE_DEFAULT_OPTIONS: Partial<LegendBaseStyleProps> = {
|
|
6
8
|
showTitle: true,
|
|
7
9
|
padding: 0,
|
|
@@ -7,6 +7,8 @@ import type { Selection } from '../../../util';
|
|
|
7
7
|
import { classNames, ifShow, select, subStyleProps } from '../../../util';
|
|
8
8
|
import { Marker, MarkerStyleProps } from '../../marker';
|
|
9
9
|
import { ifHorizontal } from '../utils';
|
|
10
|
+
import { getLegendClassName } from '../utils/classname';
|
|
11
|
+
import { CLASSNAME_SUFFIX_MAP } from '../classname-map';
|
|
10
12
|
|
|
11
13
|
export type HandleStyleProps<T = any> = GroupStyleProps &
|
|
12
14
|
PrefixObject<TextStyleProps, 'label'> &
|
|
@@ -17,6 +19,7 @@ export type HandleStyleProps<T = any> = GroupStyleProps &
|
|
|
17
19
|
/** spacing between marker and label */
|
|
18
20
|
spacing?: number;
|
|
19
21
|
shape?: 'basic' | 'slider';
|
|
22
|
+
classNamePrefix?: string;
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
export type HandleOptions = ComponentOptions<HandleStyleProps>;
|
|
@@ -64,20 +67,47 @@ export class Handle extends Component<HandleStyleProps> {
|
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
private renderMarker(container: Selection) {
|
|
67
|
-
const {
|
|
68
|
-
|
|
70
|
+
const {
|
|
71
|
+
orientation,
|
|
72
|
+
classNamePrefix,
|
|
73
|
+
markerSymbol = ifHorizontal(orientation, 'horizontalHandle', 'verticalHandle'),
|
|
74
|
+
} = this.attributes;
|
|
69
75
|
|
|
70
76
|
ifShow(!!markerSymbol, container, (group) => {
|
|
71
77
|
const handleStyle = subStyleProps(this.attributes, 'marker');
|
|
72
78
|
const markerStyle = { symbol: markerSymbol, ...handleStyle };
|
|
79
|
+
const markerClassName = getLegendClassName(
|
|
80
|
+
CLASS_NAMES.marker.name,
|
|
81
|
+
CLASSNAME_SUFFIX_MAP.handleMarker,
|
|
82
|
+
classNamePrefix
|
|
83
|
+
);
|
|
84
|
+
|
|
73
85
|
this.marker = group
|
|
74
|
-
.maybeAppendByClassName(
|
|
86
|
+
.maybeAppendByClassName(
|
|
87
|
+
CLASS_NAMES.marker,
|
|
88
|
+
() =>
|
|
89
|
+
new Marker({
|
|
90
|
+
style: markerStyle,
|
|
91
|
+
className: markerClassName,
|
|
92
|
+
})
|
|
93
|
+
)
|
|
75
94
|
.update(markerStyle);
|
|
95
|
+
|
|
96
|
+
// Update Marker's child element className (Marker component overrides className internally)
|
|
97
|
+
if (classNamePrefix) {
|
|
98
|
+
const markerElement = this.marker.node().querySelector('.marker');
|
|
99
|
+
if (markerElement) {
|
|
100
|
+
const currentClass = markerElement.getAttribute('class') || '';
|
|
101
|
+
const baseClass = currentClass.split(' ')[0]; // e.g., 'marker'
|
|
102
|
+
const legendClassName = getLegendClassName(baseClass, CLASSNAME_SUFFIX_MAP.handleMarker, classNamePrefix);
|
|
103
|
+
markerElement.setAttribute('class', legendClassName);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
76
106
|
});
|
|
77
107
|
}
|
|
78
108
|
|
|
79
109
|
private renderLabel(container: Selection) {
|
|
80
|
-
const { showLabel, orientation, spacing = 0, formatter } = this.attributes;
|
|
110
|
+
const { showLabel, orientation, spacing = 0, formatter, classNamePrefix } = this.attributes;
|
|
81
111
|
|
|
82
112
|
ifShow(showLabel, container, (group) => {
|
|
83
113
|
const { text, ...labelStyle } = subStyleProps(this.attributes, 'label');
|
|
@@ -90,8 +120,15 @@ export class Handle extends Component<HandleStyleProps> {
|
|
|
90
120
|
[width + spacing, 0, 'start', 'middle']
|
|
91
121
|
);
|
|
92
122
|
|
|
123
|
+
const labelClassName = getLegendClassName(
|
|
124
|
+
CLASS_NAMES.label.name,
|
|
125
|
+
CLASSNAME_SUFFIX_MAP.handleLabel,
|
|
126
|
+
classNamePrefix
|
|
127
|
+
);
|
|
128
|
+
|
|
93
129
|
group
|
|
94
130
|
.maybeAppendByClassName(CLASS_NAMES.label, 'text')
|
|
131
|
+
.attr('className', labelClassName)
|
|
95
132
|
.styles({ ...labelStyle, x, y, text: formatter(text).toString(), textAlign, textBaseline });
|
|
96
133
|
});
|
|
97
134
|
}
|
|
@@ -5,6 +5,8 @@ import { Component } from '../../../core';
|
|
|
5
5
|
import type { GroupStyleProps, PathStyleProps, RectStyleProps } from '../../../shapes';
|
|
6
6
|
import { Group } from '../../../shapes';
|
|
7
7
|
import { classNames, select, Selection, subStyleProps } from '../../../util';
|
|
8
|
+
import { CLASSNAME_SUFFIX_MAP } from '../constant';
|
|
9
|
+
import { getLegendClassName } from '../utils/classname';
|
|
8
10
|
import { ifHorizontal } from '../utils';
|
|
9
11
|
import { getBlockColor } from './utils';
|
|
10
12
|
|
|
@@ -23,6 +25,7 @@ export type RibbonStyleProps = GroupStyleProps &
|
|
|
23
25
|
range?: [number, number];
|
|
24
26
|
size: number;
|
|
25
27
|
type?: 'size' | 'color';
|
|
28
|
+
classNamePrefix?: string;
|
|
26
29
|
};
|
|
27
30
|
|
|
28
31
|
export type RibbonOptions = ComponentOptions<RibbonStyleProps>;
|
|
@@ -93,15 +96,28 @@ function getClipPath(attr: RequiredRibbonStyleProps): any[] {
|
|
|
93
96
|
|
|
94
97
|
function renderTrack(container: Selection, attr: RequiredRibbonStyleProps) {
|
|
95
98
|
const style = subStyleProps(attr, 'track');
|
|
96
|
-
|
|
99
|
+
const { classNamePrefix } = attr;
|
|
100
|
+
const trackClassName = getLegendClassName(CLASS_NAMES.track.name, CLASSNAME_SUFFIX_MAP.track, classNamePrefix);
|
|
101
|
+
|
|
102
|
+
container
|
|
103
|
+
.maybeAppendByClassName(CLASS_NAMES.track, 'path')
|
|
104
|
+
.attr('className', trackClassName)
|
|
105
|
+
.styles({ d: getTrackPath(attr), ...style });
|
|
97
106
|
}
|
|
98
107
|
|
|
99
108
|
function renderSelection(container: Selection, attr: RequiredRibbonStyleProps) {
|
|
100
109
|
const style = subStyleProps(attr, 'selection');
|
|
101
110
|
const fill = getColor(attr);
|
|
111
|
+
const { classNamePrefix } = attr;
|
|
112
|
+
const selectionClassName = getLegendClassName(
|
|
113
|
+
CLASS_NAMES.selection.name,
|
|
114
|
+
CLASSNAME_SUFFIX_MAP.selection,
|
|
115
|
+
classNamePrefix
|
|
116
|
+
);
|
|
102
117
|
|
|
103
118
|
const ribbon = container
|
|
104
119
|
.maybeAppendByClassName(CLASS_NAMES.selection, 'path')
|
|
120
|
+
.attr('className', selectionClassName)
|
|
105
121
|
.styles({ d: getSelectionPath(attr), fill, ...style });
|
|
106
122
|
const clipPath = ribbon
|
|
107
123
|
.maybeAppendByClassName(CLASS_NAMES.clipPath, 'path')
|
|
@@ -25,7 +25,8 @@ import type { IndicatorStyleProps } from '../indicator';
|
|
|
25
25
|
import { Indicator } from '../indicator';
|
|
26
26
|
import { Handle as SliderHandle } from '../slider/handle';
|
|
27
27
|
import { Title } from './title';
|
|
28
|
-
import { CLASS_NAMES, CONTINUOUS_DEFAULT_OPTIONS, STEP_RATIO } from './constant';
|
|
28
|
+
import { CLASS_NAMES, CLASSNAME_SUFFIX_MAP, CONTINUOUS_DEFAULT_OPTIONS, STEP_RATIO } from './constant';
|
|
29
|
+
import { getLegendClassName } from './utils/classname';
|
|
29
30
|
import type { HandleStyleProps, HandleType } from './continuous/handle';
|
|
30
31
|
import { Handle } from './continuous/handle';
|
|
31
32
|
import type { RibbonStyleProps } from './continuous/ribbon';
|
|
@@ -76,6 +77,15 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
public render(attributes: Required<ContinuousStyleProps>, container: Group) {
|
|
80
|
+
// Set root container className
|
|
81
|
+
const { classNamePrefix } = attributes;
|
|
82
|
+
const baseClassName = container.className || 'legend-continuous';
|
|
83
|
+
if (classNamePrefix) {
|
|
84
|
+
container.attr('className', `${baseClassName} ${classNamePrefix}legend`);
|
|
85
|
+
} else if (!container.className) {
|
|
86
|
+
container.attr('className', 'legend-continuous');
|
|
87
|
+
}
|
|
88
|
+
|
|
79
89
|
// 渲染顺序
|
|
80
90
|
// 1. 绘制 title, 获得可用空间
|
|
81
91
|
// 2. 绘制 label, handle
|
|
@@ -153,9 +163,9 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
153
163
|
}
|
|
154
164
|
|
|
155
165
|
private renderTitle(container: Selection) {
|
|
156
|
-
const { showTitle, titleText, width, height } = this.attributes;
|
|
166
|
+
const { showTitle, titleText, width, height, classNamePrefix } = this.attributes;
|
|
157
167
|
const style = subStyleProps<TextStyleProps>(this.attributes, 'title');
|
|
158
|
-
const finalTitleStyle = { ...style, width, height, text: titleText };
|
|
168
|
+
const finalTitleStyle = { ...style, width, height, text: titleText, classNamePrefix };
|
|
159
169
|
const that = this;
|
|
160
170
|
container
|
|
161
171
|
.selectAll(CLASS_NAMES.title.class)
|
|
@@ -263,7 +273,7 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
263
273
|
}
|
|
264
274
|
|
|
265
275
|
private renderRibbon(container: Selection) {
|
|
266
|
-
const { data, type, orientation, color, block } = this.attributes;
|
|
276
|
+
const { data, type, orientation, color, block, classNamePrefix } = this.attributes;
|
|
267
277
|
const ribbonStyle = subStyleProps(this.attributes, 'ribbon');
|
|
268
278
|
const { min, max } = this.range;
|
|
269
279
|
const { x, y } = this.ribbonBBox;
|
|
@@ -279,11 +289,22 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
279
289
|
block,
|
|
280
290
|
partition: data.map((d) => (d.value - min) / (max - min)),
|
|
281
291
|
range: this.ribbonRange,
|
|
292
|
+
classNamePrefix,
|
|
282
293
|
},
|
|
283
294
|
ribbonStyle
|
|
284
295
|
);
|
|
285
296
|
|
|
286
|
-
|
|
297
|
+
const ribbonClassName = getLegendClassName(CLASS_NAMES.ribbon.name, CLASSNAME_SUFFIX_MAP.ribbon, classNamePrefix);
|
|
298
|
+
this.ribbon = container
|
|
299
|
+
.maybeAppendByClassName(
|
|
300
|
+
CLASS_NAMES.ribbon,
|
|
301
|
+
() =>
|
|
302
|
+
new Ribbon({
|
|
303
|
+
style,
|
|
304
|
+
className: ribbonClassName,
|
|
305
|
+
})
|
|
306
|
+
)
|
|
307
|
+
.update(style);
|
|
287
308
|
}
|
|
288
309
|
|
|
289
310
|
private getHandleClassName(type: HandleType) {
|
|
@@ -292,14 +313,19 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
292
313
|
}
|
|
293
314
|
|
|
294
315
|
private renderHandles() {
|
|
295
|
-
const { showHandle, orientation } = this.attributes;
|
|
316
|
+
const { showHandle, orientation, classNamePrefix } = this.attributes;
|
|
296
317
|
const handleStyle = subStyleProps<HandleStyleProps>(this.attributes, 'handle');
|
|
297
318
|
const [min, max] = this.selection;
|
|
298
|
-
const style = { ...handleStyle, orientation };
|
|
319
|
+
const style = { ...handleStyle, orientation, classNamePrefix };
|
|
299
320
|
const { shape = 'slider' } = handleStyle;
|
|
300
321
|
const HandleCtor = shape === 'basic' ? Handle : SliderHandle;
|
|
301
322
|
|
|
302
323
|
const that = this;
|
|
324
|
+
const baseHandleClassName = getLegendClassName(
|
|
325
|
+
CLASS_NAMES.handle.name,
|
|
326
|
+
CLASSNAME_SUFFIX_MAP.handle,
|
|
327
|
+
classNamePrefix
|
|
328
|
+
);
|
|
303
329
|
this.handlesGroup
|
|
304
330
|
.selectAll(CLASS_NAMES.handle.class)
|
|
305
331
|
.data(
|
|
@@ -314,10 +340,10 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
314
340
|
.join(
|
|
315
341
|
(enter) =>
|
|
316
342
|
enter
|
|
317
|
-
.append(() => new HandleCtor({ style }))
|
|
343
|
+
.append(() => new HandleCtor({ style, className: baseHandleClassName }))
|
|
318
344
|
.attr(
|
|
319
345
|
'className',
|
|
320
|
-
({ type }: any) => `${
|
|
346
|
+
({ type }: any) => `${baseHandleClassName} ${that.getHandleClassName(type as HandleType)}`
|
|
321
347
|
)
|
|
322
348
|
.each(function ({ type, value: labelText }) {
|
|
323
349
|
this.update({ labelText });
|
|
@@ -343,6 +369,51 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
343
369
|
const [min, max] = this.selection;
|
|
344
370
|
this.setHandlePosition('start', min);
|
|
345
371
|
this.setHandlePosition('end', max);
|
|
372
|
+
|
|
373
|
+
// Update SliderHandle sub-elements className after rendering
|
|
374
|
+
const { classNamePrefix, showHandle } = this.attributes;
|
|
375
|
+
const { shape = 'slider' } = subStyleProps<HandleStyleProps>(this.attributes, 'handle');
|
|
376
|
+
if (showHandle && shape === 'slider' && classNamePrefix) {
|
|
377
|
+
if (this.startHandle) this.updateSliderHandleClassNames(this.startHandle, classNamePrefix);
|
|
378
|
+
if (this.endHandle) this.updateSliderHandleClassNames(this.endHandle, classNamePrefix);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Update SliderHandle sub-elements className to use legend prefix
|
|
384
|
+
* SliderHandle generates: handle-icon-rect, handle-icon-line, handle-label
|
|
385
|
+
* Should add legend className: g2-legend-handle-marker, g2-legend-handle-label
|
|
386
|
+
*/
|
|
387
|
+
private updateSliderHandleClassNames(handle: any, classNamePrefix: string) {
|
|
388
|
+
// Get the actual DOM node from the component
|
|
389
|
+
const container = handle.container || handle;
|
|
390
|
+
|
|
391
|
+
// Update icon elements (rect and lines) to use handleMarker suffix
|
|
392
|
+
const iconRect = container.querySelector('.handle-icon-rect');
|
|
393
|
+
if (iconRect) {
|
|
394
|
+
const markerClassName = getLegendClassName(
|
|
395
|
+
'handle-icon-rect',
|
|
396
|
+
CLASSNAME_SUFFIX_MAP.handleMarker,
|
|
397
|
+
classNamePrefix
|
|
398
|
+
);
|
|
399
|
+
iconRect.setAttribute('class', markerClassName);
|
|
400
|
+
|
|
401
|
+
// Line elements are children of rect element
|
|
402
|
+
const iconLines = iconRect.querySelectorAll('line');
|
|
403
|
+
iconLines.forEach((line: any) => {
|
|
404
|
+
const currentClass = line.getAttribute('class') || '';
|
|
405
|
+
const baseClass = currentClass.split(' ')[0]; // e.g., 'handle-icon-line-1'
|
|
406
|
+
const markerClassName = getLegendClassName(baseClass, CLASSNAME_SUFFIX_MAP.handleMarker, classNamePrefix);
|
|
407
|
+
line.setAttribute('class', markerClassName);
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// Update label element to use handleLabel suffix
|
|
412
|
+
const label = container.querySelector('.handle-label');
|
|
413
|
+
if (label) {
|
|
414
|
+
const labelClassName = getLegendClassName('handle-label', CLASSNAME_SUFFIX_MAP.handleLabel, classNamePrefix);
|
|
415
|
+
label.setAttribute('class', labelClassName);
|
|
416
|
+
}
|
|
346
417
|
}
|
|
347
418
|
|
|
348
419
|
private cacheHandleBBox: DOMRect | null = null;
|
|
@@ -380,8 +451,23 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
380
451
|
}
|
|
381
452
|
|
|
382
453
|
private renderIndicator(container: Selection) {
|
|
454
|
+
const { classNamePrefix } = this.attributes;
|
|
383
455
|
const style = subStyleProps<IndicatorStyleProps>(this.attributes, 'indicator');
|
|
384
|
-
|
|
456
|
+
const indicatorClassName = getLegendClassName(
|
|
457
|
+
CLASS_NAMES.indicator.name,
|
|
458
|
+
CLASSNAME_SUFFIX_MAP.indicator,
|
|
459
|
+
classNamePrefix
|
|
460
|
+
);
|
|
461
|
+
this.indicator = container
|
|
462
|
+
.maybeAppendByClassName(
|
|
463
|
+
CLASS_NAMES.indicator,
|
|
464
|
+
() =>
|
|
465
|
+
new Indicator({
|
|
466
|
+
style,
|
|
467
|
+
className: indicatorClassName,
|
|
468
|
+
})
|
|
469
|
+
)
|
|
470
|
+
.update(style);
|
|
385
471
|
// this.hideIndicator();
|
|
386
472
|
}
|
|
387
473
|
|
|
@@ -2,6 +2,8 @@ import { Component } from '../../../core';
|
|
|
2
2
|
import type { Group } from '../../../shapes';
|
|
3
3
|
import { DisplayObject, Text } from '../../../shapes';
|
|
4
4
|
import { BBox, Selection, classNames, ifShow, parsePosition, parseSeriesAttr, select, splitStyle } from '../../../util';
|
|
5
|
+
import { getLegendClassName } from '../utils/classname';
|
|
6
|
+
import { CLASSNAME_SUFFIX_MAP } from '../constant';
|
|
5
7
|
import type { TitleOptions, TitleStyleProps } from './types';
|
|
6
8
|
|
|
7
9
|
export type { TitleOptions, TitleStyleProps };
|
|
@@ -144,14 +146,16 @@ export class Title extends Component<TitleStyleProps> {
|
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
public render(attributes: Required<TitleStyleProps>, container: Group) {
|
|
147
|
-
const { width, height, position, spacing, ...restStyle } = attributes;
|
|
149
|
+
const { width, height, position, spacing, classNamePrefix, ...restStyle } = attributes;
|
|
148
150
|
|
|
149
151
|
const [titleStyle] = splitStyle(restStyle);
|
|
150
152
|
const { x, y, textAlign, textBaseline } = getTitleLayout(attributes);
|
|
151
153
|
|
|
152
154
|
ifShow(!!restStyle.text, select(container), (group) => {
|
|
155
|
+
const titleClassName = getLegendClassName(CLASS_NAMES.text.name, CLASSNAME_SUFFIX_MAP.title, classNamePrefix);
|
|
153
156
|
this.title = group
|
|
154
157
|
.maybeAppendByClassName(CLASS_NAMES.text, 'text')
|
|
158
|
+
.attr('className', titleClassName)
|
|
155
159
|
.styles(titleStyle)
|
|
156
160
|
.call(mayApplyStyle, { x, y, textAlign, textBaseline })
|
|
157
161
|
.node();
|
package/src/ui/legend/types.ts
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legend className utility functions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Generate legend className with optional prefix
|
|
7
|
+
* @param baseClassName - Base className, e.g., 'title-text'
|
|
8
|
+
* @param suffix - Suffix for prefixed className, e.g., 'title' -> '{prefix}legend-title'
|
|
9
|
+
* @param classNamePrefix - Optional className prefix, e.g., 'g2-'
|
|
10
|
+
* @returns Complete className, e.g., 'title-text g2-legend-title'
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* getLegendClassName('title-text', 'title', 'g2-')
|
|
14
|
+
* // Returns: 'title-text g2-legend-title'
|
|
15
|
+
*/
|
|
16
|
+
export function getLegendClassName(baseClassName: string, suffix: string, classNamePrefix?: string): string {
|
|
17
|
+
if (!classNamePrefix) return baseClassName;
|
|
18
|
+
return `${baseClassName} ${classNamePrefix}legend-${suffix}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Generate className from component attributes
|
|
23
|
+
* @param attributes - Component attributes with classNamePrefix
|
|
24
|
+
* @param baseClassName - CLASS_NAMES object, e.g., CLASS_NAMES.text
|
|
25
|
+
* @param suffix - Suffix key from CLASSNAME_SUFFIX_MAP
|
|
26
|
+
* @returns Complete className
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* getClassNameFromAttrs(this.attributes, CLASS_NAMES.text, 'title')
|
|
30
|
+
* // Returns: 'title-text g2-legend-title' (if classNamePrefix = 'g2-')
|
|
31
|
+
*/
|
|
32
|
+
export function getClassNameFromAttrs(
|
|
33
|
+
attributes: { classNamePrefix?: string },
|
|
34
|
+
baseClassName: { name: string },
|
|
35
|
+
suffix: string
|
|
36
|
+
): string {
|
|
37
|
+
const { classNamePrefix = '' } = attributes;
|
|
38
|
+
return getLegendClassName(baseClassName.name, suffix, classNamePrefix);
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './classname';
|
|
@@ -19,6 +19,8 @@ import {
|
|
|
19
19
|
} from '../../util';
|
|
20
20
|
import { button } from '../marker/symbol';
|
|
21
21
|
import type { NavigatorOptions, NavigatorStyleProps } from './types';
|
|
22
|
+
import { CLASSNAME_SUFFIX_MAP } from '../legend/classname-map';
|
|
23
|
+
import { getLegendClassName } from '../legend/utils/classname';
|
|
22
24
|
|
|
23
25
|
export type { NavigatorOptions, NavigatorStyleProps };
|
|
24
26
|
|
|
@@ -272,7 +274,7 @@ export class Navigator extends Component<NavigatorStyleProps> {
|
|
|
272
274
|
}
|
|
273
275
|
|
|
274
276
|
private renderController(container: Selection) {
|
|
275
|
-
const { controllerSpacing: spacing } = this.attributes;
|
|
277
|
+
const { controllerSpacing: spacing, classNamePrefix = '' } = this.attributes;
|
|
276
278
|
const { pageWidth, pageHeight } = this.pageShape;
|
|
277
279
|
const visible = this.pageViews.length >= 2;
|
|
278
280
|
|
|
@@ -291,10 +293,28 @@ export class Navigator extends Component<NavigatorStyleProps> {
|
|
|
291
293
|
this.prevBtnGroup = prevBtnGroup.node();
|
|
292
294
|
const prevBtn = prevBtnGroup.maybeAppendByClassName(CLASS_NAMES.prevBtn, 'path');
|
|
293
295
|
|
|
296
|
+
if (classNamePrefix) {
|
|
297
|
+
const prevBtnClassName = getLegendClassName(
|
|
298
|
+
CLASS_NAMES.prevBtn.name,
|
|
299
|
+
CLASSNAME_SUFFIX_MAP.prevBtn,
|
|
300
|
+
classNamePrefix
|
|
301
|
+
);
|
|
302
|
+
prevBtn.node().setAttribute('class', prevBtnClassName);
|
|
303
|
+
}
|
|
304
|
+
|
|
294
305
|
const nextBtnGroup = group.maybeAppendByClassName(CLASS_NAMES.nextBtnGroup, 'g').styles(groupStyle);
|
|
295
306
|
this.nextBtnGroup = nextBtnGroup.node();
|
|
296
307
|
const nextBtn = nextBtnGroup.maybeAppendByClassName(CLASS_NAMES.nextBtn, 'path');
|
|
297
308
|
|
|
309
|
+
if (classNamePrefix) {
|
|
310
|
+
const nextBtnClassName = getLegendClassName(
|
|
311
|
+
CLASS_NAMES.nextBtn.name,
|
|
312
|
+
CLASSNAME_SUFFIX_MAP.nextBtn,
|
|
313
|
+
classNamePrefix
|
|
314
|
+
);
|
|
315
|
+
nextBtn.node().setAttribute('class', nextBtnClassName);
|
|
316
|
+
}
|
|
317
|
+
|
|
298
318
|
[prevBtn, nextBtn].forEach((btn) => {
|
|
299
319
|
btn.styles({ ...pathStyle, transformOrigin: 'center' });
|
|
300
320
|
scaleToPixel(btn.node(), size, true);
|
|
@@ -303,7 +323,17 @@ export class Navigator extends Component<NavigatorStyleProps> {
|
|
|
303
323
|
const pageInfoGroup = group.maybeAppendByClassName(CLASS_NAMES.pageInfoGroup, 'g');
|
|
304
324
|
this.pageInfoGroup = pageInfoGroup.node();
|
|
305
325
|
|
|
306
|
-
pageInfoGroup.maybeAppendByClassName(CLASS_NAMES.pageInfo, 'text')
|
|
326
|
+
const pageInfoElement = pageInfoGroup.maybeAppendByClassName(CLASS_NAMES.pageInfo, 'text');
|
|
327
|
+
pageInfoElement.styles(textStyle);
|
|
328
|
+
|
|
329
|
+
if (classNamePrefix) {
|
|
330
|
+
const pageInfoClassName = getLegendClassName(
|
|
331
|
+
CLASS_NAMES.pageInfo.name,
|
|
332
|
+
CLASSNAME_SUFFIX_MAP.pageInfo,
|
|
333
|
+
classNamePrefix
|
|
334
|
+
);
|
|
335
|
+
pageInfoElement.node().setAttribute('class', pageInfoClassName);
|
|
336
|
+
}
|
|
307
337
|
|
|
308
338
|
this.updatePageInfo();
|
|
309
339
|
|
|
@@ -21,6 +21,7 @@ export type NavigatorStyleProps = Omit<RectStyleProps, 'width' | 'height'> &
|
|
|
21
21
|
pageWidth?: number;
|
|
22
22
|
/** infer to pageWidth */
|
|
23
23
|
pageHeight?: number;
|
|
24
|
+
classNamePrefix?: string;
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
export type NavigatorOptions = ComponentOptions<NavigatorStyleProps>;
|