Export Image
Export Code

Fork of HTML Starter

Sebastian Rojas

Last edited Sep 24, 2021
Created on Sep 24, 2021
Forked from HTML Starter

A bare minimum HTML page demonstrating use of CSS and JavaScript.

See also React Starter. (function (d3, vega, vegaLite, vl, vegaTooltip) { 'use strict';

vega = vega && Object.prototype.hasOwnProperty.call(vega, 'default') ? vega['default'] : vega; vegaLite = vegaLite && Object.prototype.hasOwnProperty.call(vegaLite, 'default') ? vegaLite['default'] : vegaLite; vl = vl && Object.prototype.hasOwnProperty.call(vl, 'default') ? vl['default'] : vl;

const csvUrl = 'file.csv'; const getData = async () => { const data = await d3.csv(csvUrl); console.log(data[0]); return data; };

// Appearance customization to improve readability. // See https://vega.github.io/vega-lite/docs/ const dark = '#3e3c38'; const config = { axis: { domain: false, tickColor: 'lightGray' }, style: { "guide-label": { fontSize: 13, fill: dark }, "guide-title": { fontSize: 17, fill: dark } } };

const g1 = vl .markPoint({ opacity: 0.4}) .encode( vl.x().fieldT('Date').timeUnit('daymonth'), vl.y().fieldQ('Comments'), vl.color().fieldN('Network'), vl.size().fieldQ('Likes'), vl.tooltip().fieldN('Post') );

const g2 = vl .markLine({ size : 1 }) .encode( vl.x().fieldT('Date').timeUnit("date"), vl.y().fieldQ('Likes').aggregate('average'), vl.color().fieldN('Sentiment'), vl.tooltip().fieldT('Date').timeUnit('date') );

// import { message } from './myMessage';

vl.register(vega, vegaLite, { view: { renderer: 'svg' }, init: view => { view.tooltip(new vegaTooltip.Handler().call); } });

const run = async () => { const data = await getData(); const marks = g1 .data(data) .width(window.innerWidth) //window.innerWidth .height(1000) .autosize({ type: 'pad', contains: 'padding' }) .config(config);

	const marks2 = g2
  .data(data)
  .width(window.innerWidth)
  .height(400)
  .autosize({ type: 'pad', contains: 'padding'})
  .config(config);

document.body.appendChild(await marks.render());
//document.body.appendChild(await marks2.render());

};

run();

}(d3, vega, vegaLite, vl, vegaTooltip));

//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJma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