Skip to content

Commit

Permalink
d3.csv/d3.json semantics change
Browse files Browse the repository at this point in the history
  • Loading branch information
kum-deepak authored and gordonwoodhull committed Apr 11, 2018
1 parent 900849d commit a9847ee
Show file tree
Hide file tree
Showing 48 changed files with 56 additions and 181 deletions.
11 changes: 5 additions & 6 deletions web/ep/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,11 @@ <h1 class="page-header">Members of the European parliament</h1>
</div>

<script>
$(function() {
d3.csv("mep.csv", function(d) {return d;}
,function(error, rows) {
grid ("#ep2014list",rows);
});
});
$(function () {
d3.csv("mep.csv").then(function (rows) {
grid("#ep2014list", rows);
});
});
</script>

<style>
Expand Down
2 changes: 1 addition & 1 deletion web/examples/area.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<script type="text/javascript">

var chart = dc.lineChart("#test");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

experiments.forEach(function(x) {
x.Speed = +x.Speed;
Expand Down
2 changes: 1 addition & 1 deletion web/examples/bar-extra-line.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<script type="text/javascript">

var chart = dc.barChart("#test");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

experiments.forEach(function(x) {
x.Speed = +x.Speed;
Expand Down
2 changes: 1 addition & 1 deletion web/examples/bar-single-select.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<script type="text/javascript">

var chart = dc.barChart("#test");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

experiments.forEach(function(x) {
x.Speed = +x.Speed;
Expand Down
2 changes: 1 addition & 1 deletion web/examples/bar.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<script type="text/javascript">

var chart = dc.barChart("#test");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

experiments.forEach(function(x) {
x.Speed = +x.Speed;
Expand Down
2 changes: 1 addition & 1 deletion web/examples/box-plot-time.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
var chart = dc.boxPlot("#box-test"),
pie = dc.pieChart("#pie-chart");

d3.csv("monthly-move.csv", function(error, data) {
d3.csv("monthly-move.csv").then(function(data) {

data.forEach(function(x) {
x.date = new Date(x.date);
Expand Down
2 changes: 1 addition & 1 deletion web/examples/box-plot.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

var chart = dc.boxPlot("#box-test"),
pie = dc.pieChart("#pie-chart");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

experiments.forEach(function(x) {
x.Speed = +x.Speed;
Expand Down
2 changes: 1 addition & 1 deletion web/examples/complex-reduce.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ <h4>Experiment</h4>
};

var runChart = dc.barChart("#test-run"), exptChart = dc.barChart("#test-expt");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {
experiments.forEach(function(x) {
x.Speed = +x.Speed;
});
Expand Down
9 changes: 3 additions & 6 deletions web/examples/composite.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,16 @@
<script type="text/javascript" src="header.js"></script>
<div id="test_composed"></div>

<script type="text/javascript" src="../js/queue.js"></script>
<script type="text/javascript" src="../js/d3.js"></script>
<script type="text/javascript" src="../js/crossfilter.js"></script>
<script type="text/javascript" src="../js/dc.js"></script>
<script type="text/javascript">

var composite = dc.compositeChart("#test_composed");

var q = queue()
.defer(d3.csv, "morley.csv")
.defer(d3.csv, "morley2.csv");

q.await(function(error, exp1, exp2) {
Promise.all([d3.csv("morley.csv"), d3.csv("morley2.csv")]).then(function(results) {
var exp1 = results[0],
exp2 = results[1];

var ndx = crossfilter();
ndx.add(exp1.map(function(d) {
Expand Down
2 changes: 1 addition & 1 deletion web/examples/filter-stacks.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

var chart = dc.barChart("#test"),
pie = dc.pieChart('#pie');
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

experiments.forEach(function(x) {
x.Speed = +x.Speed;
Expand Down
2 changes: 1 addition & 1 deletion web/examples/filtering-removing.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
spendHistChart = dc.barChart("#chart-hist-spend"),
spenderRowChart = dc.rowChart("#chart-row-spenders");

// use static or load via d3.csv("spendData.csv", function(error, spendData) {/* do stuff */});
// use static or load via d3.csv("spendData.csv").then(function(spendData) {/* do stuff */});
var spendData = [
{Name: 'Mr A', Spent: '$40', Year: 2011},
{Name: 'Mr B', Spent: '$10', Year: 2011},
Expand Down
2 changes: 1 addition & 1 deletion web/examples/heat.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h2>Michelson–Morley experiment</h2>
<script type="text/javascript">

var chart = dc.heatMap("#test");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

var ndx = crossfilter(experiments),
runDim = ndx.dimension(function(d) { return [+d.Run, +d.Expt]; }),
Expand Down
2 changes: 1 addition & 1 deletion web/examples/heatmap-filtering.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h2>Nasdaq 100 Percentage Gain by Month of Year</h2>
var heatmapChart = dc.heatMap("#heatmap", chartGroup);
var barChart = dc.barChart("#barchart", chartGroup);

d3.csv("../ndx.csv", function(error, data) {
d3.csv("../ndx.csv").then(function(data) {

var dateFormatSpecifier = "%m/%d/%Y";
var dateFormat = d3.timeFormat(dateFormatSpecifier);
Expand Down
2 changes: 1 addition & 1 deletion web/examples/line.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<script type="text/javascript">

var chart = dc.lineChart("#test");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

experiments.forEach(function(x) {
x.Speed = +x.Speed;
Expand Down
2 changes: 1 addition & 1 deletion web/examples/multi-focus.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
var chart3 = dc.barChart("#test3");
var chart4 = dc.barChart("#test4");

d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

experiments.forEach(function(x) {
x.Speed = +x.Speed;
Expand Down
2 changes: 1 addition & 1 deletion web/examples/multi-scatter.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<script type="text/javascript">

var chart = dc.compositeChart("#test");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

experiments.forEach(function(x) {
x.Speed = +x.Speed;
Expand Down
2 changes: 1 addition & 1 deletion web/examples/number.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
boxND = dc.numberDisplay("#number-box"),
meanND = dc.numberDisplay("#mean"),
expnND = dc.numberDisplay("#expn");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

experiments.forEach(function(x) {
x.Speed = +x.Speed * 1000;
Expand Down
5 changes: 1 addition & 4 deletions web/examples/ordinal-bar.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@

var chart = dc.barChart('#test');

d3.json('fruits.json', function(error, counts) {
if(error)
throw new Error(error);

d3.json('fruits.json').then(function(counts) {
var ndx = crossfilter(counts),
fruitDimension = ndx.dimension(function(d) {return d.name;}),
sumGroup = fruitDimension.group().reduceSum(function(d) {return d.cnt;});
Expand Down
5 changes: 1 addition & 4 deletions web/examples/ordinal-line.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@

var chart = dc.lineChart('#test');

d3.json('fruits.json', function(error, counts) {
if(error)
throw new Error(error);

d3.json('fruits.json').then(function(counts) {
var ndx = crossfilter(counts),
fruitDimension = ndx.dimension(function(d) {return d.name;}),
sumGroup = fruitDimension.group().reduceSum(function(d) {return d.cnt;});
Expand Down
2 changes: 1 addition & 1 deletion web/examples/pie-external-labels.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<script type="text/javascript">

var chart = dc.pieChart("#test");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

var ndx = crossfilter(experiments),
runDimension = ndx.dimension(function(d) {return "run-"+d.Run;})
Expand Down
2 changes: 1 addition & 1 deletion web/examples/pie.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<script type="text/javascript">

var chart = dc.pieChart("#test");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

var ndx = crossfilter(experiments),
runDimension = ndx.dimension(function(d) {return "run-"+d.Run;})
Expand Down
2 changes: 1 addition & 1 deletion web/examples/range-series.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
var overviewChart = dc.seriesChart("#test-overview");
var ndx, runDimension, runGroup, overviewRunDimension, overviewRunGroup;

d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

ndx = crossfilter(experiments);
runDimension = ndx.dimension(function(d) {return [+d.Expt, +d.Run]; });
Expand Down
2 changes: 1 addition & 1 deletion web/examples/right-axis.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<script type="text/javascript">
var moveChart = dc.compositeChart("#monthly-move-chart");

d3.csv("monthly-move.csv", function (error, data) {
d3.csv("monthly-move.csv").then(function (data) {
var dateFormatSpecifier = "%m/%d/%Y";
var dateFormat = d3.timeFormat(dateFormatSpecifier);
var dateFormatParser = d3.timeParse(dateFormatSpecifier);
Expand Down
2 changes: 1 addition & 1 deletion web/examples/row-vertical-line.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<script type="text/javascript">

var chart = dc.rowChart("#test");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

experiments.forEach(function(x) {
x.Speed = +x.Speed;
Expand Down
2 changes: 1 addition & 1 deletion web/examples/row.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<script type="text/javascript">

var chart = dc.rowChart("#test");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

experiments.forEach(function(x) {
x.Speed = +x.Speed;
Expand Down
2 changes: 1 addition & 1 deletion web/examples/scatter-series.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
var chart = dc.seriesChart("#test");
var ndx, runDimension, runGroup;

d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

ndx = crossfilter(experiments);
runDimension = ndx.dimension(function(d) {return [+d.Expt, +d.Run]; });
Expand Down
2 changes: 1 addition & 1 deletion web/examples/scatter.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<script type="text/javascript">

var chart = dc.scatterPlot("#test");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

experiments.forEach(function(x) {
x.Speed = +x.Speed;
Expand Down
4 changes: 2 additions & 2 deletions web/examples/series.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var chart = dc.seriesChart("#test");
var ndx, runDimension, runGroup;

d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

ndx = crossfilter(experiments);
runDimension = ndx.dimension(function(d) {return [+d.Expt, +d.Run]; });
Expand Down Expand Up @@ -55,7 +55,7 @@

function load_button(file) {
return function load_it() {
d3.csv(file, function(error, experiments) {
d3.csv(file).then(function(experiments) {
ndx.remove();
ndx.add(experiments);
dc.redrawAll();
Expand Down
2 changes: 1 addition & 1 deletion web/examples/sparkline.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h3>Sparklines</h3>

var barChart = dc.barChart("#bartest");
var lineChart = dc.lineChart("#linetest");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

experiments.forEach(function(x) {
x.Speed = +x.Speed;
Expand Down
5 changes: 1 addition & 4 deletions web/examples/splom.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@
d3.select('#wait-url').attr('href', location.origin + location.pathname + '?nowait');
}

d3.csv('iris.csv', function(error, iris) {
if(error)
throw new Error(error);

d3.csv('iris.csv').then(function(iris) {
iris.forEach(function(d) {
Object.keys(fields).forEach(function(ab) {
d[fields[ab]] = +d[fields[ab]];
Expand Down
2 changes: 1 addition & 1 deletion web/examples/stacked-bar.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<script type="text/javascript">

var chart = dc.barChart("#test");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {

experiments.forEach(function(x) {
x.Speed = +x.Speed;
Expand Down
5 changes: 1 addition & 4 deletions web/examples/switching-time-intervals.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@
aggregate = find_query('aggregate') || 'average';

var chart = dc.barChart("#test"), counter = dc.numberDisplay('#counter');
d3.csv(data, function(error, posts) {
if(error)
throw new Error(error);

d3.csv(data).then(function(posts) {
posts.forEach(function(d) {
d[date_col] = new Date(d[date_col]);
d[val_col] = +d[val_col];
Expand Down
2 changes: 1 addition & 1 deletion web/examples/table-on-aggregated-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<script type="text/javascript">

var chart = dc.dataTable("#test");
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {
/* We will create a table that sorts the experiments
from the one that has the highest average speed
to the one that has the lowest average speed
Expand Down
2 changes: 1 addition & 1 deletion web/examples/table-pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

var chart = dc.dataTable("#test");
var ndx;
d3.csv("morley.csv", function(error, experiments) {
d3.csv("morley.csv").then(function(experiments) {
ndx = crossfilter(experiments);
var fmt = d3.format('02d');
var runDimension = ndx.dimension(function(d) {return [fmt(+d.Expt),fmt(+d.Run)];}),
Expand Down
2 changes: 1 addition & 1 deletion web/examples/time-intervals.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
var monthChart = dc.barChart("#month");
var costChart = dc.barChart("#cost");
// data from http://stackoverflow.com/questions/22603788/crossfilter-how-to-extract-time-information-from-start-date-and-end-date-column
d3.csv("intervals.csv", function(error, projects) {
d3.csv("intervals.csv").then(function(projects) {

projects.forEach(function(x) {
x['Start Date'] = dateFormatParser(x['Start Date']);
Expand Down
Loading

0 comments on commit a9847ee

Please sign in to comment.