height: number;
items: BubbleItem<T>[];
onBubbleClick?: (ref?: T) => void;
- padding?: [number, number, number, number];
+ padding: [number, number, number, number];
sizeDomain?: [number, number];
sizeRange?: [number, number];
xDomain?: [number, number];
displayXTicks: true,
displayYGrid: true,
displayYTicks: true,
+ padding: [0, 0, 0, 0],
sizeRange: [5, 45]
};
};
zoomed = () => {
- this.setState({ transform: event.transform });
+ const { padding } = this.props;
+ const { x, y, k } = event.transform as { x: number; y: number; k: number };
+ this.setState({
+ transform: {
+ x: x + padding[3] * (k - 1),
+ y: y + padding[0] * (k - 1),
+ k
+ }
+ });
};
resetZoom = (event: React.MouseEvent<Link>) => {
*/
import * as React from 'react';
import { mount } from 'enzyme';
+import { AutoSizerProps } from 'react-virtualized';
import BubbleChart, { Bubble } from '../BubbleChart';
+jest.mock('react-virtualized/dist/commonjs/AutoSizer', () => ({
+ AutoSizer: ({ children }: AutoSizerProps) => children({ width: 100, height: NaN })
+}));
+
it('should display bubbles', () => {
const items = [{ x: 1, y: 10, size: 7 }, { x: 2, y: 30, size: 5 }];
const chart = mount(<BubbleChart height={100} items={items} />);
key="0"
r={45}
scale={1}
- x={-10}
- y={52.3015873015873}
+ x={33.21428571428572}
+ y={70.07936507936508}
>
<Tooltip>
<g>
"stroke": undefined,
}
}
- transform="translate(-10, 52.3015873015873) scale(1)"
+ transform="translate(33.21428571428572, 70.07936507936508) scale(1)"
/>
</g>
</Tooltip>
key="1"
r={33.57142857142857}
scale={1}
- x={-75}
+ x={66.42857142857144}
y={33.57142857142857}
>
<Tooltip>
"stroke": undefined,
}
}
- transform="translate(-75, 33.57142857142857) scale(1)"
+ transform="translate(66.42857142857144, 33.57142857142857) scale(1)"
/>
</g>
</Tooltip>
link="foo"
r={45}
scale={1}
- x={-10}
- y={52.3015873015873}
+ x={33.21428571428572}
+ y={70.07936507936508}
>
<Tooltip>
<g>
"stroke": undefined,
}
}
- transform="translate(-10, 52.3015873015873) scale(1)"
+ transform="translate(33.21428571428572, 70.07936507936508) scale(1)"
/>
</a>
</Link>
link="bar"
r={33.57142857142857}
scale={1}
- x={-75}
+ x={66.42857142857144}
y={33.57142857142857}
>
<Tooltip>
"stroke": undefined,
}
}
- transform="translate(-75, 33.57142857142857) scale(1)"
+ transform="translate(66.42857142857144, 33.57142857142857) scale(1)"
/>
</a>
</Link>
onClick={[MockFunction]}
r={45}
scale={1}
- x={-10}
- y={52.3015873015873}
+ x={33.21428571428572}
+ y={70.07936507936508}
>
<Tooltip>
<g>
"stroke": undefined,
}
}
- transform="translate(-10, 52.3015873015873) scale(1)"
+ transform="translate(33.21428571428572, 70.07936507936508) scale(1)"
/>
</g>
</Tooltip>
onClick={[MockFunction]}
r={33.57142857142857}
scale={1}
- x={-75}
+ x={66.42857142857144}
y={33.57142857142857}
>
<Tooltip>
"stroke": undefined,
}
}
- transform="translate(-75, 33.57142857142857) scale(1)"
+ transform="translate(66.42857142857144, 33.57142857142857) scale(1)"
/>
</g>
</Tooltip>