Skip to content

Commit

Permalink
feat: new theme and set padding to auto
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini committed Jul 25, 2023
1 parent ceb5c35 commit 91c3dd7
Show file tree
Hide file tree
Showing 187 changed files with 762 additions and 422 deletions.
6 changes: 1 addition & 5 deletions __tests__/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,7 @@ function createSpecRender(object) {
window.__g_instances__ = [canvas];
const renderChart = mounted ? renderToMountedElement : render;
before?.();
const node = renderChart(
{ theme: 'classic', ...options },
{ canvas },
() => after?.(),
);
const node = renderChart(options, { canvas }, () => after?.());

// Append nodes.
if (node instanceof HTMLElement) container.append(node);
Expand Down
2 changes: 0 additions & 2 deletions __tests__/plots/animation/events-interval-encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export function eventsIntervalEncode(): G2Spec {
return {
type: 'interval',
width: 720,
paddingTop: 60,
paddingLeft: 100,
data: events,
coordinate: { transform: [{ type: 'transpose' }] },
scale: {
Expand Down
24 changes: 12 additions & 12 deletions __tests__/plots/animation/stocks-keyframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { G2Spec } from '../../../src';

const facetLine = (data) => ({
type: 'facetRect',
paddingLeft: 60,
data,
encode: {
y: 'symbol',
Expand All @@ -29,6 +30,7 @@ const facetLine = (data) => ({

const facetArea = (data) => ({
type: 'facetRect',
paddingLeft: 60,
data,
encode: {
y: 'symbol',
Expand Down Expand Up @@ -141,7 +143,7 @@ const groupBar = (data) => ({
key: (_, i) => i,
},
axis: {
x: { tickFilter: (d) => false },
x: { tickFilter: (_) => false },
},
});

Expand All @@ -157,7 +159,7 @@ const stackBar = (data) => ({
key: (_, i) => i,
},
axis: {
x: { tickFilter: (d) => false },
x: { tickFilter: (_) => false },
},
});

Expand Down Expand Up @@ -186,6 +188,9 @@ const pie = (data) => ({
color: 'symbol',
key: 'symbol',
},
legend: {
color: { layout: { justifyContent: 'center' } },
},
style: {
radius: 10,
},
Expand All @@ -204,9 +209,10 @@ const rose = (data) => ({
},
scale: { x: { padding: 0 } },
style: { radius: 10 },
axis: {
y: false,
legend: {
color: { layout: { justifyContent: 'center' } },
},
axis: { y: false },
});

const keyframes = [
Expand All @@ -228,18 +234,12 @@ const keyframes = [
*/
export async function stocksKeyframe(): Promise<G2Spec> {
const data = await csv('data/stocks2.csv', autoType);
const paddingLeft = 50;
const paddingRight = 60;

// @ts-ignore
return {
type: 'timingKeyframe',
width: 800,
// @ts-ignore
children: keyframes.map((plot) => ({
...plot(data),
paddingLeft,
paddingRight,
})),
children: keyframes.map((plot) => plot(data)),
};
}

Expand Down
1 change: 0 additions & 1 deletion __tests__/plots/api/chart-auto-fit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export function chartAutoFit(context) {
container.appendChild(wrapperDiv);

const chart = new Chart({
theme: 'classic',
container: wrapperDiv,
autoFit: true,
canvas,
Expand Down
2 changes: 1 addition & 1 deletion __tests__/plots/api/chart-axis-label-formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Chart } from '../../../src';
export function chartAxisLabelFormatter(context) {
const { container, canvas } = context;

const chart = new Chart({ theme: 'classic', container, canvas });
const chart = new Chart({ container, canvas });

chart.data([
{
Expand Down
2 changes: 0 additions & 2 deletions __tests__/plots/api/chart-change-data-empty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ export function chartChangeDataEmpty(context) {
const { container, canvas } = context;

const chart = new Chart({
theme: 'classic',
container,
canvas,
});

chart.options({
theme: 'classic',
type: 'line',
clip: true,
data: {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/plots/api/chart-change-data-facet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function chartChangeDataFacet(context) {
const div = document.createElement('div');
container.appendChild(div);

const chart = new Chart({ theme: 'classic', container: div, canvas });
const chart = new Chart({ container: div, canvas });

const view = chart
.facetRect()
Expand Down
2 changes: 0 additions & 2 deletions __tests__/plots/api/chart-change-data-legend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export function chartChangeDataLegend(context) {
const { container, canvas } = context;

const chart = new Chart({
theme: 'classic',
container,
canvas,
});
Expand All @@ -21,7 +20,6 @@ export function chartChangeDataLegend(context) {
];

chart.options({
theme: 'classic',
type: 'interval',
data,
encode: {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/plots/api/chart-change-size-polar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function chartChangeSizePolar(context) {
const div = document.createElement('div');
container.appendChild(div);

const chart = new Chart({ theme: 'classic', container: div, canvas });
const chart = new Chart({ container: div, canvas });

chart.options({
type: 'view',
Expand Down
2 changes: 0 additions & 2 deletions __tests__/plots/api/chart-change-size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ export function chartChangeSize(context) {
container.appendChild(div);

const chart = new Chart({
theme: 'classic',
container: div,
canvas,
padding: 'auto',
});

chart.data([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export function chartEmitBrushHighlightAxisCross(context) {
container.appendChild(wrapperDiv);

const chart = new Chart({
theme: 'classic',
container: wrapperDiv,
canvas,
});
Expand Down
2 changes: 0 additions & 2 deletions __tests__/plots/api/chart-emit-brush-highlight-x.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export function chartEmitBrushHighlightX(context) {
container.appendChild(wrapperDiv);

const chart = new Chart({
theme: 'classic',
container: wrapperDiv,
paddingBottom: 120,
width: 1000,
canvas,
});
Expand Down
1 change: 0 additions & 1 deletion __tests__/plots/api/chart-emit-click-tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export function chartEmitClickTooltip(context) {
const { container, canvas } = context;

const chart = new Chart({
theme: 'classic',
container: container,
canvas,
});
Expand Down
2 changes: 0 additions & 2 deletions __tests__/plots/api/chart-emit-element-highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export function chartEmitElementHighlight(context) {
container.appendChild(wrapperDiv);

const chart = new Chart({
theme: 'classic',
container: wrapperDiv,
padding: 'auto',
canvas,
});

Expand Down
2 changes: 0 additions & 2 deletions __tests__/plots/api/chart-emit-element-select-single.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export function chartEmitElementSelectSingle(context) {
container.appendChild(wrapperDiv);

const chart = new Chart({
theme: 'classic',
container: wrapperDiv,
padding: 'auto',
canvas,
});

Expand Down
2 changes: 0 additions & 2 deletions __tests__/plots/api/chart-emit-element-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export function chartEmitElementSelect(context) {
container.appendChild(wrapperDiv);

const chart = new Chart({
theme: 'classic',
container: wrapperDiv,
padding: 'auto',
canvas,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export function chartEmitItemTooltipHideContent(context) {
container.appendChild(p);

const chart = new Chart({
theme: 'classic',
container: wrapperDiv,
canvas,
});
Expand Down
1 change: 0 additions & 1 deletion __tests__/plots/api/chart-emit-item-tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export function chartEmitItemTooltip(context) {
container.appendChild(p);

const chart = new Chart({
theme: 'classic',
container: wrapperDiv,
canvas,
});
Expand Down
1 change: 0 additions & 1 deletion __tests__/plots/api/chart-emit-legend-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export function chartEmitLegendFilter(context) {
container.appendChild(wrapperDiv);

const chart = new Chart({
theme: 'classic',
container: wrapperDiv,
canvas,
});
Expand Down
2 changes: 0 additions & 2 deletions __tests__/plots/api/chart-emit-legend-highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ export function chartEmitLegendHighlight(context) {
container.appendChild(wrapperDiv);

const chart = new Chart({
theme: 'classic',
container: wrapperDiv,
canvas,
});

chart.options({
paddingLeft: 60,
type: 'interval',
data: profit,
axis: { y: { labelFormatter: '~s' } },
Expand Down
1 change: 0 additions & 1 deletion __tests__/plots/api/chart-emit-pie-tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export function chartEmitPieTooltip(context) {
container.appendChild(p);

const chart = new Chart({
theme: 'classic',
container: wrapperDiv,
canvas,
});
Expand Down
2 changes: 0 additions & 2 deletions __tests__/plots/api/chart-emit-scrollbar-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export function chartEmitScrollbarFilter(context) {
container.appendChild(wrapperDiv);

const chart = new Chart({
theme: 'classic',
container: wrapperDiv,
paddingBottom: 120,
width: 400,
canvas,
clip: true,
Expand Down
1 change: 0 additions & 1 deletion __tests__/plots/api/chart-emit-series-tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export function chartEmitSeriesTooltip(context) {
container.appendChild(p);

const chart = new Chart({
theme: 'classic',
container: wrapperDiv,
canvas,
});
Expand Down
3 changes: 0 additions & 3 deletions __tests__/plots/api/chart-emit-slider-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ export function chartEmitSliderFilter(context) {
container.appendChild(wrapperDiv);

const chart = new Chart({
theme: 'classic',
container: wrapperDiv,
paddingLeft: 80,
paddingBottom: 120,
canvas,
});

Expand Down
2 changes: 1 addition & 1 deletion __tests__/plots/api/chart-hom-mark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function HOMMark(options) {
export function chartHOMMark(context) {
const { container, canvas } = context;

const chart = new Chart({ theme: 'classic', container, canvas });
const chart = new Chart({ container, canvas });

chart.data([
{ genre: 'Sports', sold: 275 },
Expand Down
1 change: 0 additions & 1 deletion __tests__/plots/api/chart-on-brush-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export function chartOnBrushFilter(context) {
const { container, canvas } = context;

const chart = new Chart({
theme: 'classic',
container,
canvas,
});
Expand Down
2 changes: 0 additions & 2 deletions __tests__/plots/api/chart-on-focus-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export function chartOnFocusContext(context) {
container.appendChild(focusContainer);

const focusView = new Chart({
theme: 'classic',
container: focusContainer,
canvas: canvas1,
});
Expand All @@ -30,7 +29,6 @@ export function chartOnFocusContext(context) {
container.appendChild(contextContainer);

const contextView = new Chart({
theme: 'classic',
container: contextContainer,
canvas: canvas2,
});
Expand Down
2 changes: 1 addition & 1 deletion __tests__/plots/api/chart-on-item-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Chart } from '../../../src';
export function chartOnItemElement(context) {
const { container, canvas } = context;

const chart = new Chart({ theme: 'classic', container, canvas });
const chart = new Chart({ container, canvas });

chart.data([
{ genre: 'Sports', sold: 275 },
Expand Down
2 changes: 1 addition & 1 deletion __tests__/plots/api/chart-on-series-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { temperatures } from '../../data/temperatures';
export function chartOnSeriesElement(context) {
const { container, canvas } = context;

const chart = new Chart({ theme: 'classic', container, canvas });
const chart = new Chart({ container, canvas });

chart.data(temperatures);

Expand Down
2 changes: 1 addition & 1 deletion __tests__/plots/api/chart-on-text-click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Chart } from '../../../src';
export function chartOnTextClick(context) {
const { container, canvas } = context;

const chart = new Chart({ theme: 'classic', container, canvas });
const chart = new Chart({ container, canvas });

chart.text().style({
x: 290, // 像素坐标
Expand Down
1 change: 0 additions & 1 deletion __tests__/plots/api/chart-options-change-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export function chartOptionsChangeData(context) {
container.appendChild(div);

const chart = new Chart({
theme: 'classic',
container,
canvas,
});
Expand Down
2 changes: 1 addition & 1 deletion __tests__/plots/api/chart-options-composite-mark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Pie(options, context) {
export function chartOptionsCompositeMark(context) {
const { container, canvas } = context;

const chart = new Chart({ theme: 'classic', container, canvas });
const chart = new Chart({ container, canvas });

chart.options({
type: Pie,
Expand Down
1 change: 0 additions & 1 deletion __tests__/plots/api/chart-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export function chartOptions(context) {
});

chart.options({
theme: 'classic',
type: 'line',
clip: true,
title: '标题',
Expand Down
Loading

0 comments on commit 91c3dd7

Please sign in to comment.