Skip to content

Commit

Permalink
chore: fix ci problems
Browse files Browse the repository at this point in the history
  • Loading branch information
wang1212 committed Sep 27, 2024
1 parent 96b93a4 commit 6d2a617
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 72 deletions.
2 changes: 1 addition & 1 deletion __tests__/demos/2d/marker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Path, Circle, Line, Rect, Image } from '@antv/g';
import { Path, Circle, Line } from '@antv/g';

export async function marker(context) {
const { canvas } = context;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/demos/2d/path.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Path, Rect, Group } from '@antv/g';
import { Path } from '@antv/g';

export async function path(context) {
const { canvas } = context;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/demos/2d/text.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Text, Group } from '@antv/g';
import { Text } from '@antv/g';

export async function text(context) {
const { canvas } = context;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/demos/2d/transform-group.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CanvasEvent, Circle, Rect, Path, Group } from '@antv/g';
import { CanvasEvent, Circle, Rect, Group } from '@antv/g';

export async function transformGroup(context) {
const { canvas } = context;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/demos/2d/transform.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CanvasEvent, Circle, Rect, Path, Group } from '@antv/g';
import { Circle, Rect, Group } from '@antv/g';

export async function transform(context) {
const { canvas } = context;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/demos/bugfix/1624.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Canvas, Path } from '@antv/g';
import { Path } from '@antv/g';

export async function transform_path(context) {
const { canvas, container } = context;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/demos/perf/circles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { runtime, Circle } from '@antv/g';
import { Circle } from '@antv/g';

export async function circles(context) {
const { canvas, container } = context;
Expand Down
54 changes: 11 additions & 43 deletions __tests__/demos/plugin/exporter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as d3 from 'd3';
import { HTML, Rectangle, runtime } from '@antv/g';
import { HTML, Rectangle } from '@antv/g';
import { ImageExporter } from '@antv/g-image-exporter';

export async function exporter(context) {
Expand All @@ -13,9 +13,7 @@ export async function exporter(context) {

const drawBars = async () => {
// 1. Access data
const dataset = await d3.json(
'https://gw.alipayobjects.com/os/bmw-prod/8e7cfeb6-28e5-4e78-8d16-c08468360f5f.json',
);
const dataset = await d3.json('https://gw.alipayobjects.com/os/bmw-prod/8e7cfeb6-28e5-4e78-8d16-c08468360f5f.json');
const metricAccessor = (d) => d.humidity;
const yAccessor = (d) => d.length;

Expand All @@ -33,10 +31,8 @@ export async function exporter(context) {
boundedWidth: 0,
boundedHeight: 0,
};
dimensions.boundedWidth =
dimensions.width - dimensions.margin.left - dimensions.margin.right;
dimensions.boundedHeight =
dimensions.height - dimensions.margin.top - dimensions.margin.bottom;
dimensions.boundedWidth = dimensions.width - dimensions.margin.left - dimensions.margin.right;
dimensions.boundedHeight = dimensions.height - dimensions.margin.top - dimensions.margin.bottom;

// 3. Draw canvas
const wrapper = d3.select(
Expand All @@ -45,10 +41,7 @@ export async function exporter(context) {

const bounds = wrapper
.append('g')
.style(
'transform',
`translate(${dimensions.margin.left}px, ${dimensions.margin.top}px)`,
);
.style('transform', `translate(${dimensions.margin.left}px, ${dimensions.margin.top}px)`);

// 4. Create scales

Expand All @@ -58,11 +51,7 @@ export async function exporter(context) {
.range([0, dimensions.boundedWidth])
.nice();

const binsGenerator = d3
.bin()
.domain(xScale.domain())
.value(metricAccessor)
.thresholds(12);
const binsGenerator = d3.bin().domain(xScale.domain()).value(metricAccessor).thresholds(12);

const bins = binsGenerator(dataset);

Expand All @@ -74,20 +63,14 @@ export async function exporter(context) {

// 5. Draw data
const binsGroup = bounds.append('g');
const binGroups = binsGroup
.selectAll('g')
.data(bins)
.join('g')
.attr('class', 'bin');
const binGroups = binsGroup.selectAll('g').data(bins).join('g').attr('class', 'bin');

const barPadding = 1;
const barRects = binGroups
.append('rect')
.attr('x', (d) => xScale(d.x0) + barPadding / 2)
.attr('y', (d) => yScale(yAccessor(d)))
.attr('width', (d) =>
d3.max([0, xScale(d.x1) - xScale(d.x0) - barPadding]),
)
.attr('width', (d) => d3.max([0, xScale(d.x1) - xScale(d.x0) - barPadding]))
.attr('height', (d) => dimensions.boundedHeight - yScale(yAccessor(d)))
.attr('fill', 'cornflowerblue')
.on('mouseenter', function (e) {
Expand Down Expand Up @@ -191,12 +174,7 @@ export async function exporter(context) {
ignoreElements: (element) => {
return [gui.domElement].indexOf(element) > -1;
},
clippingRegion: new Rectangle(
clippingRegionX,
clippingRegionY,
clippingRegionWidth,
clippingRegionHeight,
),
clippingRegion: new Rectangle(clippingRegionX, clippingRegionY, clippingRegionWidth, clippingRegionHeight),
beforeDrawImage: (context) => {
if (enableBackgroundColor) {
context.fillStyle = backgroundColor;
Expand Down Expand Up @@ -229,12 +207,7 @@ export async function exporter(context) {
ignoreElements: (element) => {
return [gui.domElement].indexOf(element) > -1;
},
clippingRegion: new Rectangle(
clippingRegionX,
clippingRegionY,
clippingRegionWidth,
clippingRegionHeight,
),
clippingRegion: new Rectangle(clippingRegionX, clippingRegionY, clippingRegionWidth, clippingRegionHeight),
beforeDrawImage: (context) => {
if (enableBackgroundColor) {
context.fillStyle = backgroundColor;
Expand Down Expand Up @@ -282,12 +255,7 @@ export async function exporter(context) {
exporterFolder.add(exporterConfig, 'enableBackgroundColor');
exporterFolder.addColor(exporterConfig, 'backgroundColor');
exporterFolder.add(exporterConfig, 'enableWatermark');
exporterFolder.add(exporterConfig, 'type', [
'image/png',
'image/jpeg',
'image/webp',
'image/bmp',
]);
exporterFolder.add(exporterConfig, 'type', ['image/png', 'image/jpeg', 'image/webp', 'image/bmp']);
exporterFolder.add(exporterConfig, 'encoderOptions', 0, 1);
exporterFolder.add(exporterConfig, 'toDataURL');
exporterFolder.add(exporterConfig, 'downloadImage');
Expand Down
28 changes: 6 additions & 22 deletions __tests__/demos/plugin/rough-barchart.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { runtime } from '@antv/g';
import { Plugin as PluginRoughCanvasRenderer } from '@antv/g-plugin-rough-canvas-renderer';
import { Plugin as PluginRoughSVGRenderer } from '@antv/g-plugin-rough-svg-renderer';
import { Plugin as PluginCSSSelect } from '@antv/g-plugin-css-select';
Expand Down Expand Up @@ -37,10 +36,8 @@ export async function roughBarchart(context) {
left: 50,
},
};
dimensions.boundedWidth =
dimensions.width - dimensions.margin.left - dimensions.margin.right;
dimensions.boundedHeight =
dimensions.height - dimensions.margin.top - dimensions.margin.bottom;
dimensions.boundedWidth = dimensions.width - dimensions.margin.left - dimensions.margin.right;
dimensions.boundedHeight = dimensions.height - dimensions.margin.top - dimensions.margin.bottom;

// 3. Draw canvas
const wrapper = d3.select(
Expand All @@ -49,10 +46,7 @@ export async function roughBarchart(context) {

const bounds = wrapper
.append('g')
.style(
'transform',
`translate(${dimensions.margin.left}px, ${dimensions.margin.top}px)`,
);
.style('transform', `translate(${dimensions.margin.left}px, ${dimensions.margin.top}px)`);

// 4. Create scales

Expand All @@ -62,11 +56,7 @@ export async function roughBarchart(context) {
.range([0, dimensions.boundedWidth])
.nice();

const binsGenerator = d3
.bin()
.domain(xScale.domain())
.value(metricAccessor)
.thresholds(12);
const binsGenerator = d3.bin().domain(xScale.domain()).value(metricAccessor).thresholds(12);

const bins = binsGenerator(dataset);

Expand All @@ -78,20 +68,14 @@ export async function roughBarchart(context) {

// 5. Draw data
const binsGroup = bounds.append('g');
const binGroups = binsGroup
.selectAll('g')
.data(bins)
.join('g')
.attr('class', 'bin');
const binGroups = binsGroup.selectAll('g').data(bins).join('g').attr('class', 'bin');

const barPadding = 1;
const barRects = binGroups
.append('rect')
.attr('x', (d) => xScale(d.x0) + barPadding / 2)
.attr('y', (d) => yScale(yAccessor(d)))
.attr('width', (d) =>
d3.max([0, xScale(d.x1) - xScale(d.x0) - barPadding]),
)
.attr('width', (d) => d3.max([0, xScale(d.x1) - xScale(d.x0) - barPadding]))
.attr('height', (d) => dimensions.boundedHeight - yScale(yAccessor(d)))
.attr('fill', 'cornflowerblue')
.on('mouseenter', function (e) {
Expand Down

0 comments on commit 6d2a617

Please sign in to comment.