Published
Edited
May 2, 2021
2 stars
Insert cell
md`# Vis of the day (trigger "chart.render()" manual)`
Insert cell
html`<div id="container" style="height:500px;width:100%;position: relative;" />`
Insert cell
chart.render()
Insert cell
Chart = G2.Chart
Insert cell
G2.registerInteraction('element-jump-link', {
start: [
{
trigger: 'element:click',
action: ({ view, event }) => {
const link = event.data?.data?.['Link to Tableau Public'];
if (link) {
window.open(link);
}
},
},
{
trigger: 'element:mouseenter',
action: ({ view, event }) => {
const link = event.data?.data?.['Link to Tableau Public'];
if (link) {
view.getCanvas().setCursor('pointer');
}
},
},
],
end: [
{
trigger: 'element:mouseleave',
action: ['cursor:default'],
},
],
});
Insert cell
chart = new Chart({
container: "container",
autoFit: true,
height: 500
})
Insert cell
data = FileAttachment("votd@1.json").json()
Insert cell
chart.data(data)
Insert cell
chart
.point()
.position("year*date")
.size("Number Of Favorites", [4, 20])
.color("Number Of Favorites")
.shape("circle")
.tooltip({
fields: [
"gallery item publish date",
"Author Name",
"View Count",
"Number Of Favorites"
]
})
.style({
lineWidth: 0.2,
fillOpacity: 0.85
})
Insert cell
chart
.coordinate("polar", {
radius: 0.88,
innerRadius: 0.3
})
.transpose()
.rotate(-Math.PI / 2)
Insert cell
chart.annotation().html({
position: ["50%", "50%"],
html: () => {
return `<div style="transform:translate(-50%,0);font-size:24px;">VIS OF THE DAY</div>`;
}
})
Insert cell
chart.legend(false)
Insert cell
chart.tooltip({ showMarkers: false })
Insert cell
chart.interaction("element-active")
Insert cell
chart.interaction("element-jump-link")
Insert cell
G2 = require("@antv/g2")
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more