You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by ov...@apache.org on 2024/04/09 08:05:47 UTC
(echarts) 01/01: feat: init matrix coordinate
This is an automated email from the ASF dual-hosted git repository.
ovilia pushed a commit to branch feat-matrix
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit ecd2ff02cef2b79ee3bee6b530cb8fa32057784e
Author: Ovilia <zw...@gmail.com>
AuthorDate: Tue Apr 9 16:05:14 2024 +0800
feat: init matrix coordinate
---
src/component/matrix/MatrixView.ts | 35 ++++++++++++++++
src/component/matrix/install.ts | 29 +++++++++++++
src/coord/matrix/Matrix.ts | 84 ++++++++++++++++++++++++++++++++++++++
src/coord/matrix/MatrixModel.ts | 35 ++++++++++++++++
src/export/components.ts | 2 +
src/export/option.ts | 2 +
src/util/types.ts | 5 +++
7 files changed, 192 insertions(+)
diff --git a/src/component/matrix/MatrixView.ts b/src/component/matrix/MatrixView.ts
new file mode 100644
index 000000000..c4401f083
--- /dev/null
+++ b/src/component/matrix/MatrixView.ts
@@ -0,0 +1,35 @@
+/*
+* 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.
+*/
+
+import MatrixModel from '../../coord/matrix/MatrixModel';
+import ExtensionAPI from '../../core/ExtensionAPI';
+import { ComponentView } from '../../echarts.all';
+import GlobalModel from '../../model/Global';
+
+class MatrixView extends ComponentView {
+
+ static type = 'matrix';
+ type = MatrixView.type;
+
+ render(matrixModel: MatrixModel, ecModel: GlobalModel, api: ExtensionAPI) {
+ // TODO
+ }
+}
+
+export default MatrixView;
diff --git a/src/component/matrix/install.ts b/src/component/matrix/install.ts
new file mode 100644
index 000000000..86a0ccc85
--- /dev/null
+++ b/src/component/matrix/install.ts
@@ -0,0 +1,29 @@
+/*
+* 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.
+*/
+
+import { EChartsExtensionInstallRegisters } from '../../extension';
+import MatrixModel from '../../coord/matrix/MatrixModel';
+import MatrixView from './MatrixView';
+import Matrix from '../../coord/matrix/Matrix';
+
+export function install(registers: EChartsExtensionInstallRegisters) {
+ registers.registerComponentModel(MatrixModel);
+ registers.registerComponentView(MatrixView);
+ registers.registerCoordinateSystem('matrix', Matrix);
+}
diff --git a/src/coord/matrix/Matrix.ts b/src/coord/matrix/Matrix.ts
new file mode 100644
index 000000000..349e251d5
--- /dev/null
+++ b/src/coord/matrix/Matrix.ts
@@ -0,0 +1,84 @@
+/*
+* 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.
+*/
+
+import BoundingRect from 'zrender/src/core/BoundingRect';
+import { MatrixArray } from 'zrender/src/core/matrix';
+import { PrepareCustomInfo } from '../../chart/custom/CustomSeries';
+import { ComponentModel, SeriesModel } from '../../echarts.all';
+import { ComponentOption, ScaleDataValue, SeriesOnMatrixOptionMixin, SeriesOption } from '../../util/types';
+import Axis from '../Axis';
+import { CoordinateSystem, CoordinateSystemClipArea, CoordinateSystemMaster } from '../CoordinateSystem';
+import GlobalModel from '../../model/Global';
+import ExtensionAPI from '../../core/ExtensionAPI';
+import MatrixModel from './MatrixModel';
+
+class Matrix implements CoordinateSystem, CoordinateSystemMaster {
+
+ static readonly dimensions = [''];
+
+ static create(ecModel: GlobalModel, api: ExtensionAPI) {
+ const matrixList: Matrix[] = [];
+
+ ecModel.eachComponent('matrix', function (matrixModel: MatrixModel) {
+ const matrix = new Matrix(matrixModel, ecModel, api);
+ matrixList.push(matrix);
+ matrixModel.coordinateSystem = matrix;
+ });
+
+ ecModel.eachSeries(function (matrixSeries: SeriesModel<SeriesOption & SeriesOnMatrixOptionMixin>) {
+ if (matrixSeries.get('coordinateSystem') === 'matrix') {
+ // Inject coordinate system
+ matrixSeries.coordinateSystem = matrixList[matrixSeries.get('matrixIndex') || 0];
+ }
+ });
+ return matrixList;
+ }
+
+ constructor(matrixModel: MatrixModel, ecModel: GlobalModel, api: ExtensionAPI) {
+ this._model = matrixModel;
+ }
+
+ private _model: MatrixModel;
+
+ type: string;
+ master?: CoordinateSystemMaster;
+ dimensions: string[];
+ model?: ComponentModel<ComponentOption>;
+ dataToPoint(data: ScaleDataValue | ScaleDataValue[], reserved?: any, out?: number[]): number[] {
+ throw new Error('Method not implemented.');
+ }
+ pointToData?(point: number[], clamp?: boolean): number | number[] {
+ throw new Error('Method not implemented.');
+ }
+ containPoint(point: number[]): boolean {
+ throw new Error('Method not implemented.');
+ }
+ getAxes?: () => Axis[];
+ getAxis?: (dim?: string) => Axis;
+ getBaseAxis?: () => Axis;
+ getOtherAxis?: (baseAxis: Axis) => Axis;
+ clampData?: (data: ScaleDataValue[], out?: number[]) => number[];
+ getRoamTransform?: () => MatrixArray;
+ getArea?: (tolerance?: number) => CoordinateSystemClipArea;
+ getBoundingRect?: () => BoundingRect;
+ getAxesByScale?: (scaleType: string) => Axis[];
+ prepareCustoms?: PrepareCustomInfo;
+}
+
+export default Matrix;
diff --git a/src/coord/matrix/MatrixModel.ts b/src/coord/matrix/MatrixModel.ts
new file mode 100644
index 000000000..de0cba6cc
--- /dev/null
+++ b/src/coord/matrix/MatrixModel.ts
@@ -0,0 +1,35 @@
+/*
+* 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.
+*/
+
+import ComponentModel from '../../model/Component';
+import { BoxLayoutOptionMixin, ComponentOption } from '../../util/types';
+import Matrix from './Matrix';
+
+export interface MatrixOption extends ComponentOption, BoxLayoutOptionMixin {
+
+}
+
+class MatrixModel extends ComponentModel<MatrixOption> {
+ static type = 'matrix';
+ type = MatrixModel.type;
+
+ coordinateSystem: Matrix;
+}
+
+export default MatrixModel;
diff --git a/src/export/components.ts b/src/export/components.ts
index 8e4e14e26..934b99027 100644
--- a/src/export/components.ts
+++ b/src/export/components.ts
@@ -28,6 +28,7 @@ export {install as GeoComponent} from '../component/geo/install';
export {install as SingleAxisComponent} from '../component/singleAxis/install';
export {install as ParallelComponent} from '../component/parallel/install';
export {install as CalendarComponent} from '../component/calendar/install';
+export {install as MatrixComponent} from '../component/matrix/install';
export {install as GraphicComponent} from '../component/graphic/install';
@@ -77,6 +78,7 @@ export {
SingleAxisComponentOption,
ParallelComponentOption,
CalendarComponentOption,
+ MatrixComponentOption,
GraphicComponentOption,
diff --git a/src/export/option.ts b/src/export/option.ts
index d25e8197a..b03e79b7d 100644
--- a/src/export/option.ts
+++ b/src/export/option.ts
@@ -33,6 +33,7 @@ import type {SingleAxisOption as SingleAxisComponentOption} from '../coord/singl
import type {ParallelAxisOption as ParallelAxisComponentOption} from '../coord/parallel/AxisModel';
import type {ParallelCoordinateSystemOption as ParallelComponentOption} from '../coord/parallel/ParallelModel';
import type {CalendarOption as CalendarComponentOption} from '../coord/calendar/CalendarModel';
+import type {MatrixOption as MatrixComponentOption} from '../coord/matrix/MatrixModel';
import type {ToolboxOption} from '../component/toolbox/ToolboxModel';
import type {
TooltipOption as TooltipComponentOption,
@@ -155,6 +156,7 @@ export {
AngleAxisComponentOption,
ParallelComponentOption,
CalendarComponentOption,
+ MatrixComponentOption,
TooltipComponentOption,
AxisPointerComponentOption,
BrushComponentOption,
diff --git a/src/util/types.ts b/src/util/types.ts
index 01e932188..9045eadc4 100644
--- a/src/util/types.ts
+++ b/src/util/types.ts
@@ -1665,6 +1665,11 @@ export interface SeriesOnCalendarOptionMixin {
calendarId?: string
}
+export interface SeriesOnMatrixOptionMixin {
+ matrixIndex?: number
+ matrixId?: string
+}
+
export interface SeriesLargeOptionMixin {
large?: boolean
largeThreshold?: number
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org