Skip to content

Instantly share code, notes, and snippets.

@XavierGimenez
XavierGimenez / .block
Last active July 13, 2023 08:18
Chord Diagram with vega.js
license: bsd-3-clause
@XavierGimenez
XavierGimenez / .block
Last active March 9, 2023 12:09 — forked from mbostock/.block
Grouping nodes in a Force-Directed Graph
license: gpl-3.0
height: 600
@XavierGimenez
XavierGimenez / README.md
Last active February 17, 2023 03:11
Sankey diagram with vega.js
@XavierGimenez
XavierGimenez / VegaChart.js
Last active May 6, 2020 10:40
React component for Vega charts
/**
* @fileOverview React component to wrap Vega.js chart rendering.
* @author Xavi Giménez (xavi@xavigimenez.net)
*/
import React, { Component } from 'react';
import * as vega from 'vega';
import * as _ from 'lodash';
var vegaTooltip = require('vega-tooltip/build/vega-tooltip');
@XavierGimenez
XavierGimenez / data.csv
Last active February 17, 2020 03:00
Waffle Chart
age population
<10 2704659
10-20 4499890
21-30 2159981
31-40 3853788
41-50 14106543
51-60 8819342
61-70 612463
71-80 144320
81-90 3730220
@XavierGimenez
XavierGimenez / what-forces-layout.md
Created January 15, 2020 13:43 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@XavierGimenez
XavierGimenez / README.md
Last active March 2, 2019 06:49
Slopechart with vega.js

Quick implementation of a slope chart, not to represent changes over time but to emulate Ben Fry's piece Salaries vs Performance

Todo: Values should be ranked to avoid overlapping

@XavierGimenez
XavierGimenez / README.md
Last active January 14, 2019 15:22
sorted stacked chart with vega.js

Sankey diagram with vega.js.

data transforms: stack + joinaggregate + collect

@XavierGimenez
XavierGimenez / README.md
Last active December 13, 2018 10:25
choropleth map with vega.js

More testing on making maps with vega.js. No effort thanks to the lookup transform and conditional blocks for coloring the features.

@XavierGimenez
XavierGimenez / README.md
Last active December 12, 2018 12:16
Fitting maps automatically with vega.js

Creating maps with vega.js. Simple example of how to use the "fit" and "size" properties of the projection object, so centering/scaling the map is done automatically