Skip to content

Instantly share code, notes, and snippets.

@bkamapantula
Created June 9, 2020 12:05
Show Gist options
  • Save bkamapantula/1ac2053ab77acecedbf3b49d13ed299c to your computer and use it in GitHub Desktop.
Save bkamapantula/1ac2053ab77acecedbf3b49d13ed299c to your computer and use it in GitHub Desktop.
Created with Gramex Charts. Visit at https://gramener.com/gramexcharts
[
{
"a": 1,
"b": 2
}
]
data = {
// JSON or a CSV endpoint
url: "https://gist.githubusercontent.com/LakshmiVSeelam/9f8dedc6018457c40e91cac9009e0951/raw/a7d3b580bb01d5770f1806c12e05179f5ee7b02e/horz_bar_data.json"
}
base_spec = "https://gist.githubusercontent.com/LakshmiVSeelam/8061a0e1a5a948f3f0611835da8ae093/raw/bfdaf46b986214b7b1b368c24363665b530d0283/horz_bar_config.json"
function draw(data, el, opts) {
$.getJSON(base_spec, function(spec) {
var mark_bar = _.filter(spec.marks, function(mark) { return mark.name == 'bars' })[0]
mark_bar.encode.update.tooltip = {signal: "datum"}
new vega.View(vega.parse(spec))
.renderer('svg')
.tooltip(new vegaTooltip.Handler().call)
.logLevel(vega.Warn)
.initialize(el)
.hover()
.run()
}) // getJSON
}
scripts = [
"https://unpkg.com/vega@5.10.1/build/vega.min.js",
"https://unpkg.com/vega-tooltip@0.22.1/build/vega-tooltip.min.js"
]
options = {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment