You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2025/08/08 09:56:58 UTC
(echarts) 01/01: feat(matrix): Support matrix.x/y.length for conveniently create a headless matrix without composing an array.
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a commit to branch feat/matrix-tweak
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 5e54f9db1739446bb205aac403fdde76b275c7d5
Author: 100pah <su...@gmail.com>
AuthorDate: Fri Aug 8 17:50:33 2025 +0800
feat(matrix): Support matrix.x/y.length for conveniently create a headless matrix without composing an array.
---
src/coord/matrix/MatrixDim.ts | 8 ++++++++
src/coord/matrix/MatrixModel.ts | 3 +++
test/matrix.html | 44 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+)
diff --git a/src/coord/matrix/MatrixDim.ts b/src/coord/matrix/MatrixDim.ts
index 764d762c5..ed407bf0c 100644
--- a/src/coord/matrix/MatrixDim.ts
+++ b/src/coord/matrix/MatrixDim.ts
@@ -149,6 +149,7 @@ export class MatrixDim {
this._uniqueValueGen = createUniqueValueGenerator(dim);
let dimModelData = dimModel.get('data', true);
+ const length = dimModel.get('length', true);
if (dimModelData != null && !isArray(dimModelData)) {
if (__DEV__) {
error(`Illegal echarts option - matrix.${this.dim}.data must be an array if specified.`);
@@ -158,6 +159,13 @@ export class MatrixDim {
if (dimModelData) {
this._initByDimModelData(dimModelData);
}
+ else if (length != null) {
+ dimModelData = Array(length);
+ for (let i = 0; i < length; i++) {
+ dimModelData[i] = null;
+ }
+ this._initByDimModelData(dimModelData);
+ }
else {
this._initBySeriesData();
}
diff --git a/src/coord/matrix/MatrixModel.ts b/src/coord/matrix/MatrixModel.ts
index bcaae24bb..93737a7c7 100644
--- a/src/coord/matrix/MatrixModel.ts
+++ b/src/coord/matrix/MatrixModel.ts
@@ -158,6 +158,9 @@ interface MatrixDimensionOption extends MatrixCellStyleOption, MatrixDimensionLe
type?: 'category'; // For internal usage; force be 'category'.
show?: boolean;
data?: MatrixDimensionCellLooseOption[];
+ // A simple way to provide column/row count if no need to compose a `data`.
+ // Note: `length` is ignored if `data` is specified.
+ length?: number;
// `levels[0]`: the topmost (for x dimension) or leftmost (for y dimension) level.
// If not specified, use null/undefined, such as `levels: [null, null, {levelSize: 10}]`
levels?: (MatrixDimensionLevelOption | NullUndefined)[];
diff --git a/test/matrix.html b/test/matrix.html
index 66bd85322..7fffee5e0 100644
--- a/test/matrix.html
+++ b/test/matrix.html
@@ -46,6 +46,7 @@ under the License.
<div id="main4"></div>
<div id="main_collect"></div>
<div id="main_series_data_use_ordinal_number"></div>
+ <div id="main_x_y_length"></div>
@@ -664,6 +665,49 @@ under the License.
+
+ <script>
+ require([
+ 'echarts',
+ ], function (echarts) {
+
+ var option = {
+ matrix: {
+ x: {length: 4},
+ y: {length: 3},
+ },
+ series: {
+ type: 'scatter',
+ coordinateSystem: 'matrix',
+ label: {show: true},
+ encode: {label: 2},
+ symbolSize: 20,
+ data: [
+ [0, 0, 1223],
+ [1, 0, 323],
+ [2, 0, 142],
+ [0, 1, 63],
+ [1, 1, 91],
+ [2, 1, 45],
+ [0, 2, 55],
+ [1, 2, 15],
+ [2, 2, 53],
+ ]
+ }
+ };
+
+ var chart = testHelper.create(echarts, 'main_x_y_length', {
+ title: [
+ 'matrx.x/y.length'
+ ],
+ option: option
+ });
+ });
+ </script>
+
+
+
+
</body>
</html>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org