From 7baf7a778257dab9781c3c7a867c7ad1030eaf26 Mon Sep 17 00:00:00 2001 From: Daniel Mane Date: Tue, 4 Feb 2014 15:29:29 -0800 Subject: [PATCH] Last-minute changes for the demo, such as making a seperate page for the crazy css demo --- examples/demo-day-crazy.css | 5 ++++ examples/demo-day-crazy.html | 20 ++++++++++++++++ examples/demoDay.ts | 45 ------------------------------------ examples/exampleUtil.ts | 33 ++++++++++++++++++++++++++ index.html | 3 ++- 5 files changed, 60 insertions(+), 46 deletions(-) create mode 100644 examples/demo-day-crazy.html diff --git a/examples/demo-day-crazy.css b/examples/demo-day-crazy.css index e1638cee10..00304266cf 100644 --- a/examples/demo-day-crazy.css +++ b/examples/demo-day-crazy.css @@ -27,3 +27,8 @@ circle { .selected-point { fill: black; } + +.drag-box { + fill: red; + opacity: 0.5; +} diff --git a/examples/demo-day-crazy.html b/examples/demo-day-crazy.html new file mode 100644 index 0000000000..ee114e7d2a --- /dev/null +++ b/examples/demo-day-crazy.html @@ -0,0 +1,20 @@ + + + + + + + +


+ +


+ + + + + + + + + + diff --git a/examples/demoDay.ts b/examples/demoDay.ts index 35fb30df18..4f9dfee525 100644 --- a/examples/demoDay.ts +++ b/examples/demoDay.ts @@ -9,10 +9,6 @@ /// if (( window).demoName === "demo-day") { - -// First we make the scatterplot that shows the full dataset - - var N_BINS = 25; function makeScatterPlotWithSparkline(data) { var s: any = {}; @@ -88,46 +84,6 @@ function makeScatterHisto(data) { return {table: table, s: s, h: h}; } -function filterSelectedData(data) { - var p = (d) => d.selected; - return data.filter(p); -} - -function makeBinFunction(accessor, range, nBins) { - return (d) => binByVal(d, accessor, range, nBins); -} - -function binByVal(data: any[], accessor: IAccessor, range=[0,100], nBins=10) { - if (accessor == null) {accessor = (d) => d.x}; - var min = range[0]; - var max = range[1]; - var spread = max-min; - var binBeginnings = _.range(nBins).map((n) => min + n * spread / nBins); - var binEndings = _.range(nBins) .map((n) => min + (n+1) * spread / nBins); - var counts = new Array(nBins); - _.range(nBins).forEach((b, i) => counts[i] = 0); - data.forEach((d) => { - var v = accessor(d); - var found = false; - for (var i=0; i { - var bin: any = {}; - bin.x = binBeginnings[i]; - bin.x2 = binEndings[i]; - bin.y = count; - return bin; - }) - return bins; -} - function coordinator(chart: any, dataset: IDataset) { var scatterplot = chart.s; var histogram = chart.h; @@ -164,7 +120,6 @@ function coordinator(chart: any, dataset: IDataset) { function grabIndices(itemsToGrab: any[], indices: number[]) { return indices.map((i) => itemsToGrab[i]); } - var clump1 = makeNormallyDistributedData(300, -10, 5, 7, 1); var clump2 = makeNormallyDistributedData(300, 2, 0.5, 3, 3); var clump3 = makeNormallyDistributedData(30, 5, 10, -3, 9); diff --git a/examples/exampleUtil.ts b/examples/exampleUtil.ts index de6bbd7ec1..9a31034a68 100644 --- a/examples/exampleUtil.ts +++ b/examples/exampleUtil.ts @@ -19,7 +19,40 @@ function makeNormallyDistributedData(n=100, xMean?, xStdDev?, yMean?, yStdDev?) } return results; } +function makeBinFunction(accessor, range, nBins) { + return (d) => binByVal(d, accessor, range, nBins); +} +function binByVal(data: any[], accessor: IAccessor, range=[0,100], nBins=10) { + if (accessor == null) {accessor = (d) => d.x}; + var min = range[0]; + var max = range[1]; + var spread = max-min; + var binBeginnings = _.range(nBins).map((n) => min + n * spread / nBins); + var binEndings = _.range(nBins) .map((n) => min + (n+1) * spread / nBins); + var counts = new Array(nBins); + _.range(nBins).forEach((b, i) => counts[i] = 0); + data.forEach((d) => { + var v = accessor(d); + var found = false; + for (var i=0; i { + var bin: any = {}; + bin.x = binBeginnings[i]; + bin.x2 = binEndings[i]; + bin.y = count; + return bin; + }) + return bins; +} function makeRandomBucketData(numBuckets: number, bucketWidth: number, maxValue = 10): IDataset { var data = []; for (var i=0; i < numBuckets; i++) { diff --git a/index.html b/index.html index 15cd1221c6..d9c8deee16 100644 --- a/index.html +++ b/index.html @@ -12,6 +12,7 @@

Tests

The old demo

Sparkline demo

Demo Day

-

TSC Demo

+

Demo Day With Crazy CSS

+

TSC Demo

(the code)