Skip to content

Instantly share code, notes, and snippets.

@bkamapantula
bkamapantula / README.md
Created May 27, 2020 14:41
Created with Gramex Charts. Visit at https://gramener.com/gramexcharts

New chart

@bkamapantula
bkamapantula / README.md
Created May 27, 2020 14:20
Created with Gramex Charts. Visit at https://gramener.com/gramexcharts

New chart

@bkamapantula
bkamapantula / README.md
Created May 27, 2020 14:14
Created with Gramex Charts. Visit at https://gramener.com/gramexcharts

New chart

@bkamapantula
bkamapantula / create_gist.py
Last active May 26, 2020 14:43
Create GitHub Gist with Python requests
# this example is adapted from https://stackoverflow.com/a/50704456
import requests, json
# handler below is a Gramex FunctionHandler object
# ref: https://learn.gramener.com/guide/functionhandler/
# three arguments are passed from the user input: ?js=, ?json=, and ?md=
data = json.dumps({
"public":"true",

test

content

@bkamapantula
bkamapantula / heatmap-google-mobility-spec.json
Last active June 16, 2020 05:41
Heatmap spec for google mobility data
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "Mobility changes for different aspects in Indian regions",
"width": 750,
"height": 700,
"padding": 5,
"title": {
"text": "India regional mobility changes",
"anchor": "middle",
"fontSize": 16,
@bkamapantula
bkamapantula / google-mobility-data.json
Last active June 16, 2020 05:41
India Google Mobility data
This file has been truncated, but you can view the full file.
[
{
"sub_region_1": "India",
"date": "2020-02-15",
"retail_and_recreation_percent_change_from_baseline": 1,
"grocery_and_pharmacy_percent_change_from_baseline": 2,
"parks_percent_change_from_baseline": 3,
"transit_stations_percent_change_from_baseline": 3,
"workplaces_percent_change_from_baseline": 5,
"residential_percent_change_from_baseline": 0
@bkamapantula
bkamapantula / README.md
Created May 7, 2020 15:04
Export SVG to image (SVG, PNG) formats

While external style definitions are retained for SVG they aren't for PNG export.

@bkamapantula
bkamapantula / update_vega_chart.js
Last active May 5, 2020 06:51
update vega chart data
// where data is a JSON object
let changeset = vega.changeset().remove(() => true).insert(data)
view.change('table', changeset)
.run()
// and where view is
view = new vega.View(vega.parse(spec))
.renderer('svg')
.logLevel(vega.Warn)
.initialize('chart-container')
@bkamapantula
bkamapantula / bararea.json
Last active December 29, 2020 06:33
chart specifications
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A basic bar chart example, with value labels shown upon mouse hover.",
"width": 650,
"height": 500,
"title": {
"text": "Bar Area Chart",
"anchor": "start",
"fontSize": 13,
"font": "Roboto",