Skip to content

Commit

Permalink
fix(dataZoom): use handleLabel.show
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovilia committed Nov 6, 2024
1 parent b04f36e commit c3ce6e0
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 131 deletions.
13 changes: 9 additions & 4 deletions src/component/dataZoom/SliderZoomModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import {
} from '../../util/types';
import { inheritDefaultOption } from '../../util/component';

interface SliderHandleLabelOption {
show?: boolean
}

export interface SliderDataZoomOption extends DataZoomOption, BoxLayoutOptionMixin {

show?: boolean
Expand Down Expand Up @@ -79,7 +83,7 @@ export interface SliderDataZoomOption extends DataZoomOption, BoxLayoutOptionMix

handleIcon?: string

handleLabelShow?: boolean
handleLabel?: SliderHandleLabelOption

/**
* number: height of icon. width will be calculated according to the aspect of icon.
Expand Down Expand Up @@ -119,7 +123,7 @@ export interface SliderDataZoomOption extends DataZoomOption, BoxLayoutOptionMix
brushStyle?: ItemStyleOption

emphasis?: {
handleLabelShow?: boolean
handleLabel: SliderHandleLabelOption
handleStyle?: ItemStyleOption
moveHandleStyle?: ItemStyleOption
}
Expand Down Expand Up @@ -174,7 +178,6 @@ class SliderZoomModel extends DataZoomModel<SliderDataZoomOption> {
// Color of selected window.
fillerColor: 'rgba(135,175,274,0.2)',
handleIcon: 'path://M-9.35,34.56V42m0-40V9.5m-2,0h4a2,2,0,0,1,2,2v21a2,2,0,0,1-2,2h-4a2,2,0,0,1-2-2v-21A2,2,0,0,1-11.35,9.5Z',
handleLabelShow: false,
// Percent of the slider height
handleSize: '100%',

Expand Down Expand Up @@ -205,7 +208,9 @@ class SliderZoomModel extends DataZoomModel<SliderDataZoomOption> {
},

emphasis: {
handleLabelShow: true,
handleLabel: {
show: true
},
handleStyle: {
borderColor: '#8FB0F7'
},
Expand Down
10 changes: 6 additions & 4 deletions src/component/dataZoom/SliderZoomView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ class SliderZoomView extends DataZoomView {
sliderGroup.add(handles[handleIndex] = path);

const textStyleModel = dataZoomModel.getModel('textStyle');
const handleLabelShow = dataZoomModel.get('handleLabelShow');
const handleLabel = dataZoomModel.get('handleLabel') || {};
const handleLabelShow = handleLabel.show || false;

thisGroup.add(
handleLabels[handleIndex] = new graphic.Text({
Expand Down Expand Up @@ -889,9 +890,10 @@ class SliderZoomView extends DataZoomView {
* @param isEmphasis true: show, false: hide
*/
private _showDataInfo(isEmphasis?: boolean) {
const normalShow = this.dataZoomModel.get('handleLabelShow');
const emphasisShow = this.dataZoomModel.getModel('emphasis')
.get('handleLabelShow');
const handleLabel = this.dataZoomModel.get('handleLabel') || {};
const normalShow = handleLabel.show || false;
const emphasisHandleLabel = this.dataZoomModel.getModel(['emphasis', 'handleLabel']);
const emphasisShow = emphasisHandleLabel.get('show') || false;
// Dragging is considered as emphasis, unless emphasisShow is false
const toShow = (isEmphasis || this._dragging)
? emphasisShow
Expand Down
270 changes: 147 additions & 123 deletions test/dataZoom-handleLabelShow.html

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

0 comments on commit c3ce6e0

Please sign in to comment.