Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add example for custom style of view frame #5749

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions site/examples/composition/facet/demo/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
"en": "Facet Circle"
},
"screenshot": "https://mdn.alipayobjects.com/mdn/huamei_qa8qxu/afts/img/A*Tsx5RJVrVtsAAAAAAAAAAAAADmJ7AQ"
},
{
"filename": "rect-frame.ts",
"title": {
"zh": "自定义视图边框",
"en": "Custom Frame Style"
},
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*aofoR4mGPVUAAAAAAAAAAAAADmJ7AQ/original"
}
]
}
33 changes: 33 additions & 0 deletions site/examples/composition/facet/demo/rect-frame.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* A recreation of one of these demos: https://observablehq.com/@observablehq/plot-facets?collection=@observablehq/plot
*/
import { Chart } from '@antv/g2';

const chart = new Chart({
container: 'container',
width: 928,
height: 320,
paddingLeft: 60,
paddingBottom: 60,
});

const facetRect = chart
.facetRect()
.data({
type: 'fetch',
value: 'https://assets.antv.antgroup.com/g2/anscombe.json',
})
.encode('x', 'series');

facetRect
.point()
.attr('inset', 10)
.encode('x', 'x')
.encode('y', 'y')
.style('stroke', '#000')
.attr('frame', false) // Hide the default frame.
.viewStyle('plotStroke', 'red') // Customize the plot area to mock a frame.
.viewStyle('plotStrokeWidth', 2)
.viewStyle('plotOpacity', 0.5);

chart.render();
Loading