Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] add borderRadius option to heatmap #16493

Merged
merged 14 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from 11 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
4 changes: 2 additions & 2 deletions src/chart/bar/BarSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
SeriesSamplingOptionMixin,
SeriesLabelOption,
SeriesEncodeOptionMixin,
DefaultStatesMixinEmpasis,
DefaultStatesMixinEmphasis,
CallbackDataParams
} from '../../util/types';
import type Cartesian2D from '../../coord/cartesian/Cartesian2D';
Expand All @@ -49,7 +49,7 @@ export interface BarStateOption<TCbParams = never> {
}

interface BarStatesMixin {
emphasis?: DefaultStatesMixinEmpasis
emphasis?: DefaultStatesMixinEmphasis
}

export interface BarItemStyleOption<TCbParams = never> extends ItemStyleOption<TCbParams> {
Expand Down
4 changes: 2 additions & 2 deletions src/chart/funnel/FunnelSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
VerticalAlign,
SeriesLabelOption,
SeriesEncodeOptionMixin,
DefaultStatesMixinEmpasis,
DefaultStatesMixinEmphasis,
CallbackDataParams
} from '../../util/types';
import GlobalModel from '../../model/Global';
Expand All @@ -49,7 +49,7 @@ type FunnelLabelOption = Omit<SeriesLabelOption, 'position'> & {
};

interface FunnelStatesMixin {
emphasis?: DefaultStatesMixinEmpasis
emphasis?: DefaultStatesMixinEmphasis
}

export interface FunnelCallbackDataParams extends CallbackDataParams {
Expand Down
4 changes: 2 additions & 2 deletions src/chart/gauge/GaugeSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
OptionDataValueNumeric,
StatesOptionMixin,
SeriesEncodeOptionMixin,
DefaultStatesMixinEmpasis,
DefaultStatesMixinEmphasis,
CallbackDataParams
} from '../../util/types';
import GlobalModel from '../../model/Global';
Expand Down Expand Up @@ -105,7 +105,7 @@ interface DetailOption extends LabelOption {
}

interface GaugeStatesMixin {
emphasis?: DefaultStatesMixinEmpasis
emphasis?: DefaultStatesMixinEmphasis
}
export interface GaugeStateOption<TCbParams = never> {
itemStyle?: ItemStyleOption<TCbParams>
Expand Down
10 changes: 7 additions & 3 deletions src/chart/heatmap/HeatmapSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
StatesOptionMixin,
SeriesEncodeOptionMixin,
SeriesOnCalendarOptionMixin,
DefaultStatesMixinEmpasis,
DefaultStatesMixinEmphasis,
CallbackDataParams
} from '../../util/types';
import GlobalModel from '../../model/Global';
Expand All @@ -41,14 +41,18 @@ import type Calendar from '../../coord/calendar/Calendar';

type HeatmapDataValue = OptionDataValue[];

export type BorderRadius = number | number[];
plainheart marked this conversation as resolved.
Show resolved Hide resolved

export interface HeatmapStateOption<TCbParams = never> {
// Available on cartesian2d coordinate system
itemStyle?: ItemStyleOption<TCbParams>
itemStyle?: ItemStyleOption<TCbParams> & {
borderRadius?: BorderRadius
}
label?: SeriesLabelOption
}

interface FunnelStatesMixin {
emphasis?: DefaultStatesMixinEmpasis
emphasis?: DefaultStatesMixinEmphasis
}
export interface HeatmapDataItemOption extends HeatmapStateOption,
StatesOptionMixin<HeatmapStateOption, FunnelStatesMixin> {
Expand Down
17 changes: 13 additions & 4 deletions src/chart/heatmap/HeatmapView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { toggleHoverEmphasis } from '../../util/states';
import HeatmapLayer from './HeatmapLayer';
import * as zrUtil from 'zrender/src/core/util';
import ChartView from '../../view/Chart';
import HeatmapSeriesModel, { HeatmapDataItemOption } from './HeatmapSeries';
import HeatmapSeriesModel, { BorderRadius, HeatmapDataItemOption } from './HeatmapSeries';
plainheart marked this conversation as resolved.
Show resolved Hide resolved
import type GlobalModel from '../../model/Global';
import type ExtensionAPI from '../../core/ExtensionAPI';
import type VisualMapModel from '../../component/visualMap/VisualMapModel';
Expand All @@ -31,7 +31,7 @@ import type ContinuousModel from '../../component/visualMap/ContinuousModel';
import { CoordinateSystem, isCoordinateSystemType } from '../../coord/CoordinateSystem';
import { StageHandlerProgressParams, Dictionary, OptionDataValue } from '../../util/types';
import type Cartesian2D from '../../coord/cartesian/Cartesian2D';
import type Calendar from '../../coord/calendar/Calendar';
import Calendar from '../../coord/calendar/Calendar';
plainheart marked this conversation as resolved.
Show resolved Hide resolved
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle';
import Element from 'zrender/src/Element';

Expand Down Expand Up @@ -205,6 +205,7 @@ class HeatmapView extends ChartView {
let emphasisStyle = seriesModel.getModel(['emphasis', 'itemStyle']).getItemStyle();
let blurStyle = seriesModel.getModel(['blur', 'itemStyle']).getItemStyle();
let selectStyle = seriesModel.getModel(['select', 'itemStyle']).getItemStyle();
let borderRadius = seriesModel.get(['itemStyle', 'borderRadius']);
let labelStatesModels = getLabelStatesModels(seriesModel);
const emphasisModel = seriesModel.getModel('emphasis');
let focus = emphasisModel.get('focus');
Expand Down Expand Up @@ -268,22 +269,30 @@ class HeatmapView extends ChartView {
});
}

const itemModel = data.getItemModel<HeatmapDataItemOption>(idx);

// Optimization for large datset
if (data.hasItemOption) {
const itemModel = data.getItemModel<HeatmapDataItemOption>(idx);
pissang marked this conversation as resolved.
Show resolved Hide resolved
const emphasisModel = itemModel.getModel('emphasis');
emphasisStyle = emphasisModel.getModel('itemStyle').getItemStyle();
blurStyle = itemModel.getModel(['blur', 'itemStyle']).getItemStyle();
selectStyle = itemModel.getModel(['select', 'itemStyle']).getItemStyle();

// Each item value struct in the data would be firstly
// {
// itemStyle: { borderRadius: [30, 30] },
// value: [2022, 02, 22]
// }
borderRadius = itemModel.get(['itemStyle', 'borderRadius']);

focus = emphasisModel.get('focus');
blurScope = emphasisModel.get('blurScope');
emphasisDisabled = emphasisModel.get('disabled');

labelStatesModels = getLabelStatesModels(itemModel);
}

rect.shape.r = borderRadius;

const rawValue = seriesModel.getRawValue(idx) as OptionDataValue[];
let defaultText = '-';
if (rawValue && rawValue[2] != null) {
Expand Down
4 changes: 2 additions & 2 deletions src/chart/lines/LinesSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
StatesOptionMixin,
SeriesLineLabelOption,
DimensionDefinitionLoose,
DefaultStatesMixinEmpasis,
DefaultStatesMixinEmphasis,
ZRColor,
CallbackDataParams
} from '../../util/types';
Expand Down Expand Up @@ -86,7 +86,7 @@ interface LegacyDataItemOption {
}

interface LinesStatesMixin {
emphasis?: DefaultStatesMixinEmpasis
emphasis?: DefaultStatesMixinEmphasis
}
export interface LinesStateOption<TCbParams = never> {
lineStyle?: LinesLineStyleOption<(TCbParams extends never ? never : (params: TCbParams) => ZRColor) | ZRColor>
Expand Down
6 changes: 3 additions & 3 deletions src/chart/parallel/ParallelSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import {
OptionEncodeValue,
Dictionary,
OptionEncode,
DefaultStatesMixinEmpasis,
DefaultStatesMixinEmphasis,
ZRColor,
CallbackDataParams
} from '../../util/types';
} from '../../util/types';
import GlobalModel from '../../model/Global';
import SeriesData from '../../data/SeriesData';
import { ParallelActiveState, ParallelAxisOption } from '../../coord/parallel/AxisModel';
Expand All @@ -46,7 +46,7 @@ import ParallelModel from '../../coord/parallel/ParallelModel';
type ParallelSeriesDataValue = OptionDataValue[];

interface ParallelStatesMixin {
emphasis?: DefaultStatesMixinEmpasis
emphasis?: DefaultStatesMixinEmphasis
}
export interface ParallelStateOption<TCbParams = never> {
lineStyle?: LineStyleOption<(TCbParams extends never ? never : (params: TCbParams) => ZRColor) | ZRColor>
Expand Down
4 changes: 2 additions & 2 deletions src/chart/radar/RadarSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
OptionDataItemObject,
SeriesEncodeOptionMixin,
CallbackDataParams,
DefaultStatesMixinEmpasis
DefaultStatesMixinEmphasis
} from '../../util/types';
import GlobalModel from '../../model/Global';
import SeriesData from '../../data/SeriesData';
Expand All @@ -45,7 +45,7 @@ import {
type RadarSeriesDataValue = OptionDataValue[];

interface RadarStatesMixin {
emphasis?: DefaultStatesMixinEmpasis
emphasis?: DefaultStatesMixinEmphasis
}
export interface RadarSeriesStateOption<TCbParams = never> {
lineStyle?: LineStyleOption
Expand Down
4 changes: 2 additions & 2 deletions src/chart/themeRiver/ThemeRiverSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
Dictionary,
SeriesLabelOption,
CallbackDataParams,
DefaultStatesMixinEmpasis
DefaultStatesMixinEmphasis
} from '../../util/types';
import SingleAxis from '../../coord/single/SingleAxis';
import GlobalModel from '../../model/Global';
Expand All @@ -51,7 +51,7 @@ interface ThemeRiverSeriesLabelOption extends SeriesLabelOption {
type ThemerRiverDataItem = [OptionDataValueDate, OptionDataValueNumeric, string];

interface ThemeRiverStatesMixin {
emphasis?: DefaultStatesMixinEmpasis
emphasis?: DefaultStatesMixinEmphasis
}
export interface ThemeRiverStateOption<TCbParams = never> {
label?: ThemeRiverSeriesLabelOption
Expand Down
2 changes: 1 addition & 1 deletion src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ export interface DefaultStatesMixin {

export type DefaultEmphasisFocus = 'none' | 'self' | 'series';

export interface DefaultStatesMixinEmpasis {
export interface DefaultStatesMixinEmphasis {
/**
* self: Focus self and blur all others.
* series: Focus series and blur all other series.
Expand Down
Loading