This is an automated email from the ASF dual-hosted git repository.
voidmatcha pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git
The following commit(s) were added to refs/heads/master by this push:
new 479ba74592 [ZEPPELIN-6783] Scale Angular scatter markers by area
479ba74592 is described below
commit 479ba7459299ed84c3c3744590ad110a9cf2c0e0
Author: Minho Jang <[email protected]>
AuthorDate: Mon Nov 30 20:41:56 2026 +0900
[ZEPPELIN-6783] Scale Angular scatter markers by area
### What is this PR for?
The Angular scatter chart maps numeric Size values to marker radii, making
the same increase in Size look larger at the high end. This PR maps Size values
to marker area instead, matching the Classic UI’s scaling behavior while
keeping the existing minimum and maximum radii.
Clearing Size restores uniform default markers. X/Y positions, group
colors, tooltips, and legends are unchanged.
### What type of PR is it?
Improvement
### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-6783
### How should this be tested?
From zeppelin-web-angular, run:
```bash
npm run test:shell --
src/app/visualizations/scatter-chart/scatter-chart-visualization.component.spec.ts
```
In the Angular notebook UI, plot three rows with distinct X values, the
same Y value, and Size values 2, 11, and 20. Select the Size column and verify
that the two increases in marker area are approximately equal. Clear Size and
verify that all three markers return to the same default size. Check that point
positions, group colors, Y-value tooltips, and the group legend stay unchanged.
### Questions:
- Do the license files need to be updated? No.
- Are there breaking changes for older versions? No.
- Does this need documentation? No.
Closes #5627 from miinhho/ZEPPELIN-6783-scatter-marker-area.
Signed-off-by: YONGJAE LEE <[email protected]>
---
.../scatter-chart-visualization.component.spec.ts | 12 ++++++-
.../scatter-chart-visualization.component.ts | 37 +++++++++++++++++++++-
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git
a/zeppelin-web-angular/src/app/visualizations/scatter-chart/scatter-chart-visualization.component.spec.ts
b/zeppelin-web-angular/src/app/visualizations/scatter-chart/scatter-chart-visualization.component.spec.ts
index f870c9d742..c0629c2508 100644
---
a/zeppelin-web-angular/src/app/visualizations/scatter-chart/scatter-chart-visualization.component.spec.ts
+++
b/zeppelin-web-angular/src/app/visualizations/scatter-chart/scatter-chart-visualization.component.spec.ts
@@ -53,7 +53,7 @@ const createChart = (): ScatterFixture => {
table.columns = ['x', 'y', 'size', 'other', 'group'];
table.rows = [
{ x: '1', y: '10', size: '2', other: '20', group: 'A' },
- { x: '2', y: '10', size: '8', other: '8', group: 'B' },
+ { x: '2', y: '10', size: '11', other: '11', group: 'B' },
{ x: '3', y: '10', size: '20', other: '2', group: 'A' }
];
@@ -144,10 +144,20 @@ describe('ScatterChartVisualizationComponent point
sizes', () => {
expect(positionsAndGroups()).toEqual(baseline);
});
+ it('renders equal increases in marker area for evenly spaced size values',
() => {
+ fixture = createChart();
+ fixture.selectSize('size');
+
+ const [small, medium, large] = fixture.radii().map(radius => Math.PI *
radius ** 2);
+ expect(medium - small).toBeGreaterThan(0);
+ expect(large - medium).toBeCloseTo(medium - small);
+ });
+
it('restores the default rendered radii when the size selection is cleared',
() => {
fixture = createChart();
fixture.selectSize();
const defaultRadii = fixture.radii();
+ expect(defaultRadii).toEqual(Array(3).fill(defaultRadii[0]));
fixture.selectSize('size');
expect(fixture.radii()).not.toEqual(defaultRadii);
diff --git
a/zeppelin-web-angular/src/app/visualizations/scatter-chart/scatter-chart-visualization.component.ts
b/zeppelin-web-angular/src/app/visualizations/scatter-chart/scatter-chart-visualization.component.ts
index b68c3e27b4..7b511840a3 100644
---
a/zeppelin-web-angular/src/app/visualizations/scatter-chart/scatter-chart-visualization.component.ts
+++
b/zeppelin-web-angular/src/app/visualizations/scatter-chart/scatter-chart-visualization.component.ts
@@ -83,12 +83,47 @@ export class ScatterChartVisualizationComponent extends
G2VisualizationComponent
.shape('circle');
if (size) {
- geom.size(size);
+ this.setPointSize(geom, size);
chart.legend(size, false);
geom.tooltip('__key__*__value__', (name: string, value: number) => ({
name, value: String(value) }));
}
}
+ private setPointSize(geom: G2.Geom, field: string): void {
+ const rows: ReadonlyArray<Record<string, unknown>> =
this.visualization.transformed.rows;
+ let min = Infinity;
+ let max = -Infinity;
+ for (const row of rows) {
+ let value = row[field];
+ // The categorical X axis keeps numeric values as strings.
+ if (typeof value === 'string') {
+ const text = value.trim();
+ value = text === '' ? NaN : Number(text);
+ }
+ if (typeof value !== 'number' || !Number.isFinite(value)) {
+ // Keep G2's existing mapping for nonnumeric fields.
+ geom.size(field);
+ return;
+ }
+ min = Math.min(min, value);
+ max = Math.max(max, value);
+ }
+
+ if (min >= max) {
+ geom.size(field);
+ return;
+ }
+
+ // G2 receives a radius. Interpolate its square so that the area changes
linearly
+ // while keeping the existing 1–10 px radius range.
+ const minRadiusSquared = 1;
+ const maxRadiusSquared = 100;
+ geom.size(field, (value: number | string) => {
+ const fraction = (Number(value) - min) / (max - min);
+ return Math.sqrt(minRadiusSquared + fraction * (maxRadiusSquared -
minRadiusSquared));
+ });
+ }
+
ngOnInit() {}
ngAfterViewInit() {