From 110aac896af049eda4f0a823af883289bab2fb5b Mon Sep 17 00:00:00 2001 From: Shiv Parikh Date: Wed, 4 Jan 2017 14:49:02 -0800 Subject: [PATCH 1/4] updated lodash to 4.17.4 in all examples --- examples/showcase/area/area-basic/demo.html | 2 +- examples/showcase/area/area-combo/demo.html | 2 +- examples/showcase/area/area-stacked/demo.html | 2 +- examples/showcase/bar/bar-basic/demo.html | 2 +- examples/showcase/bar/bar-export/demo.html | 2 +- examples/showcase/bar/bar-grouped/demo.html | 2 +- examples/showcase/bar/bar-image/demo.html | 2 +- examples/showcase/bar/bar-stacked/demo.html | 2 +- examples/showcase/bar/bar-styled/demo.html | 2 +- examples/showcase/column/column-basic/demo.html | 2 +- examples/showcase/column/column-grouped/demo.html | 2 +- examples/showcase/column/column-stacked/demo.html | 2 +- examples/showcase/column/column-styled/demo.html | 2 +- examples/showcase/column/column-width/demo.html | 2 +- examples/showcase/line/line-basic/demo.html | 2 +- examples/showcase/line/line-dates/demo.html | 2 +- examples/showcase/line/line-export/demo.html | 2 +- examples/showcase/line/line-markers/demo.html | 2 +- examples/showcase/line/line-multi-basic/demo.html | 2 +- examples/showcase/line/line-sine/demo.html | 2 +- examples/showcase/pie/donut-series/demo.html | 2 +- examples/showcase/pie/pie-basic/demo.html | 2 +- examples/showcase/pie/pie-donut/demo.html | 2 +- examples/showcase/pie/pie-gauge/demo.html | 2 +- examples/showcase/pie/pie-series/demo.html | 2 +- examples/showcase/scatter/scatter-basic/demo.html | 2 +- examples/showcase/scatter/scatter-export/demo.html | 2 +- examples/showcase/scatter/scatter-trendline/demo.html | 2 +- src/documentation/fiddle/Contour.expose/demo.html | 2 +- src/documentation/fiddle/config.area.areaBase/demo.html | 2 +- src/documentation/fiddle/config.area.preprocess/demo.html | 2 +- src/documentation/fiddle/config.area.stacked/demo.html | 2 +- src/documentation/fiddle/config.area/demo.html | 2 +- src/documentation/fiddle/config.bar.barClass/demo.html | 2 +- src/documentation/fiddle/config.bar.barWidth/demo.html | 2 +- src/documentation/fiddle/config.bar.groupPadding/demo.html | 2 +- src/documentation/fiddle/config.bar.offset/demo.html | 2 +- src/documentation/fiddle/config.bar.preprocess/demo.html | 2 +- src/documentation/fiddle/config.bar.stacked/demo.html | 2 +- src/documentation/fiddle/config.bar.style/demo.html | 2 +- src/documentation/fiddle/config.bar/demo.html | 2 +- .../fiddle/config.chart.animations.duration/demo.html | 2 +- .../fiddle/config.chart.animations.enable/demo.html | 2 +- src/documentation/fiddle/config.chart.defaultAspect/demo.html | 2 +- src/documentation/fiddle/config.chart.defaultWidth/demo.html | 2 +- src/documentation/fiddle/config.chart.gridlines/demo.html | 2 +- src/documentation/fiddle/config.chart.height/demo.html | 2 +- src/documentation/fiddle/config.chart.margin.bottom/demo.html | 2 +- src/documentation/fiddle/config.chart.margin.left/demo.html | 2 +- src/documentation/fiddle/config.chart.margin.right/demo.html | 2 +- src/documentation/fiddle/config.chart.margin.top/demo.html | 2 +- src/documentation/fiddle/config.chart.padding.bottom/demo.html | 2 +- src/documentation/fiddle/config.chart.padding.left/demo.html | 2 +- src/documentation/fiddle/config.chart.padding.right/demo.html | 2 +- src/documentation/fiddle/config.chart.padding.top/demo.html | 2 +- src/documentation/fiddle/config.chart.width/demo.html | 2 +- src/documentation/fiddle/config.chart/demo.html | 2 +- src/documentation/fiddle/config.column.columnClass/demo.html | 2 +- src/documentation/fiddle/config.column.columnWidth/demo.html | 2 +- src/documentation/fiddle/config.column.groupPadding/demo.html | 2 +- src/documentation/fiddle/config.column.offset/demo.html | 2 +- src/documentation/fiddle/config.column.stacked/demo.html | 2 +- src/documentation/fiddle/config.column.style/demo.html | 2 +- src/documentation/fiddle/config.column/demo.html | 2 +- src/documentation/fiddle/config.legend.direction/demo.html | 2 +- src/documentation/fiddle/config.legend.el/demo.html | 2 +- src/documentation/fiddle/config.legend.hAlign/demo.html | 2 +- src/documentation/fiddle/config.legend.vAlign/demo.html | 2 +- src/documentation/fiddle/config.legend/demo.html | 2 +- src/documentation/fiddle/config.line.marker.enable/demo.html | 2 +- src/documentation/fiddle/config.line.marker.size/demo.html | 2 +- src/documentation/fiddle/config.line.preprocess/demo.html | 2 +- src/documentation/fiddle/config.line.smooth/demo.html | 2 +- src/documentation/fiddle/config.line.stacked/demo.html | 2 +- src/documentation/fiddle/config.line/demo.html | 2 +- src/documentation/fiddle/config.pie.innerRadius/demo.html | 2 +- src/documentation/fiddle/config.pie.outerRadius/demo.html | 2 +- src/documentation/fiddle/config.pie.piePadding.bottom/demo.html | 2 +- src/documentation/fiddle/config.pie.piePadding.left/demo.html | 2 +- src/documentation/fiddle/config.pie.piePadding.right/demo.html | 2 +- src/documentation/fiddle/config.pie.piePadding.top/demo.html | 2 +- src/documentation/fiddle/config.pie.piePadding/demo.html | 2 +- src/documentation/fiddle/config.pie.sliceClass/demo.html | 2 +- src/documentation/fiddle/config.pie.style/demo.html | 2 +- src/documentation/fiddle/config.pie/demo.html | 2 +- src/documentation/fiddle/config.scatter.preprocess/demo.html | 2 +- src/documentation/fiddle/config.scatter.radius/demo.html | 2 +- src/documentation/fiddle/config.scatter/demo.html | 2 +- src/documentation/fiddle/config.tooltip.animate/demo.html | 2 +- src/documentation/fiddle/config.tooltip.distance/demo.html | 2 +- src/documentation/fiddle/config.tooltip.formatter/demo.html | 2 +- src/documentation/fiddle/config.tooltip.hideTime/demo.html | 2 +- src/documentation/fiddle/config.tooltip.opacity/demo.html | 2 +- src/documentation/fiddle/config.tooltip.showTime/demo.html | 2 +- src/documentation/fiddle/config.tooltip/demo.html | 2 +- src/documentation/fiddle/config.xAxis.categories/demo.html | 2 +- src/documentation/fiddle/config.xAxis.firstAndLast/demo.html | 2 +- .../fiddle/config.xAxis.innerRangePadding/demo.html | 2 +- src/documentation/fiddle/config.xAxis.innerTickSize/demo.html | 2 +- src/documentation/fiddle/config.xAxis.labels.format/demo.html | 2 +- .../fiddle/config.xAxis.labels.formatter/demo.html | 2 +- src/documentation/fiddle/config.xAxis.linearDomain/demo.html | 2 +- src/documentation/fiddle/config.xAxis.max/demo.html | 2 +- src/documentation/fiddle/config.xAxis.maxTicks/demo.html | 2 +- src/documentation/fiddle/config.xAxis.min/demo.html | 2 +- src/documentation/fiddle/config.xAxis.orient/demo.html | 2 +- .../fiddle/config.xAxis.outerRangePadding/demo.html | 2 +- src/documentation/fiddle/config.xAxis.outerTickSize/demo.html | 2 +- src/documentation/fiddle/config.xAxis.tickPadding/demo.html | 2 +- src/documentation/fiddle/config.xAxis.tickValues/demo.html | 2 +- src/documentation/fiddle/config.xAxis.ticks/demo.html | 2 +- src/documentation/fiddle/config.xAxis.title/demo.html | 2 +- src/documentation/fiddle/config.xAxis.titlePadding/demo.html | 2 +- src/documentation/fiddle/config.xAxis.type/demo.html | 2 +- src/documentation/fiddle/config.xAxis/demo.html | 2 +- src/documentation/fiddle/config.yAxis.innerTickSize/demo.html | 2 +- src/documentation/fiddle/config.yAxis.labels.format/demo.html | 2 +- .../fiddle/config.yAxis.labels.formatter/demo.html | 2 +- .../fiddle/config.yAxis.labels.verticalAlign/demo.html | 2 +- src/documentation/fiddle/config.yAxis.max/demo.html | 2 +- src/documentation/fiddle/config.yAxis.min/demo.html | 2 +- src/documentation/fiddle/config.yAxis.orient/demo.html | 2 +- src/documentation/fiddle/config.yAxis.outerTickSize/demo.html | 2 +- src/documentation/fiddle/config.yAxis.smartAxis/demo.html | 2 +- src/documentation/fiddle/config.yAxis.tickPadding/demo.html | 2 +- src/documentation/fiddle/config.yAxis.tickValues/demo.html | 2 +- src/documentation/fiddle/config.yAxis.ticks/demo.html | 2 +- src/documentation/fiddle/config.yAxis.title/demo.html | 2 +- src/documentation/fiddle/config.yAxis.titlePadding/demo.html | 2 +- src/documentation/fiddle/config.yAxis.zeroAnchor/demo.html | 2 +- src/documentation/fiddle/config.yAxis/demo.html | 2 +- 131 files changed, 131 insertions(+), 131 deletions(-) diff --git a/examples/showcase/area/area-basic/demo.html b/examples/showcase/area/area-basic/demo.html index dd27ac75..41925497 100644 --- a/examples/showcase/area/area-basic/demo.html +++ b/examples/showcase/area/area-basic/demo.html @@ -2,7 +2,7 @@ - +
diff --git a/examples/showcase/area/area-combo/demo.html b/examples/showcase/area/area-combo/demo.html index 5a55e1c1..54494008 100644 --- a/examples/showcase/area/area-combo/demo.html +++ b/examples/showcase/area/area-combo/demo.html @@ -2,7 +2,7 @@ - +
Sales by Region
2014 - Estimated
diff --git a/examples/showcase/area/area-stacked/demo.html b/examples/showcase/area/area-stacked/demo.html index 08cc5388..6fc33029 100644 --- a/examples/showcase/area/area-stacked/demo.html +++ b/examples/showcase/area/area-stacked/demo.html @@ -2,7 +2,7 @@ - +
Responses by Channel
diff --git a/examples/showcase/bar/bar-basic/demo.html b/examples/showcase/bar/bar-basic/demo.html index e8a09444..fd751f5e 100644 --- a/examples/showcase/bar/bar-basic/demo.html +++ b/examples/showcase/bar/bar-basic/demo.html @@ -2,7 +2,7 @@ - +
diff --git a/examples/showcase/bar/bar-export/demo.html b/examples/showcase/bar/bar-export/demo.html index c3559c82..b6ba3de6 100644 --- a/examples/showcase/bar/bar-export/demo.html +++ b/examples/showcase/bar/bar-export/demo.html @@ -2,7 +2,7 @@ - +
Estate Tax Collection
diff --git a/examples/showcase/bar/bar-grouped/demo.html b/examples/showcase/bar/bar-grouped/demo.html index 175eddd6..61ca90e8 100644 --- a/examples/showcase/bar/bar-grouped/demo.html +++ b/examples/showcase/bar/bar-grouped/demo.html @@ -2,7 +2,7 @@ - +
Gross Tax Collection
diff --git a/examples/showcase/bar/bar-image/demo.html b/examples/showcase/bar/bar-image/demo.html index e8a09444..fd751f5e 100644 --- a/examples/showcase/bar/bar-image/demo.html +++ b/examples/showcase/bar/bar-image/demo.html @@ -2,7 +2,7 @@ - +
diff --git a/examples/showcase/bar/bar-stacked/demo.html b/examples/showcase/bar/bar-stacked/demo.html index 3bc89f67..8505d6f1 100644 --- a/examples/showcase/bar/bar-stacked/demo.html +++ b/examples/showcase/bar/bar-stacked/demo.html @@ -2,7 +2,7 @@ - +
diff --git a/examples/showcase/bar/bar-styled/demo.html b/examples/showcase/bar/bar-styled/demo.html index e8a09444..fd751f5e 100644 --- a/examples/showcase/bar/bar-styled/demo.html +++ b/examples/showcase/bar/bar-styled/demo.html @@ -2,7 +2,7 @@ - +
diff --git a/examples/showcase/column/column-basic/demo.html b/examples/showcase/column/column-basic/demo.html index 3448b6a7..6a4b6440 100644 --- a/examples/showcase/column/column-basic/demo.html +++ b/examples/showcase/column/column-basic/demo.html @@ -2,7 +2,7 @@ - +
diff --git a/examples/showcase/column/column-grouped/demo.html b/examples/showcase/column/column-grouped/demo.html index 43b82450..63c5d793 100644 --- a/examples/showcase/column/column-grouped/demo.html +++ b/examples/showcase/column/column-grouped/demo.html @@ -2,7 +2,7 @@ - +
Sales - 2012 vs 2013
diff --git a/examples/showcase/column/column-stacked/demo.html b/examples/showcase/column/column-stacked/demo.html index a4688ad7..6ef0b1b1 100644 --- a/examples/showcase/column/column-stacked/demo.html +++ b/examples/showcase/column/column-stacked/demo.html @@ -2,7 +2,7 @@ - +
Sales by Product
diff --git a/examples/showcase/column/column-styled/demo.html b/examples/showcase/column/column-styled/demo.html index 4b544746..458dde3c 100644 --- a/examples/showcase/column/column-styled/demo.html +++ b/examples/showcase/column/column-styled/demo.html @@ -2,7 +2,7 @@ - +
Per Capita Consumption of Beverages
Selected Types
diff --git a/examples/showcase/column/column-width/demo.html b/examples/showcase/column/column-width/demo.html index 46c8f354..b88870b1 100644 --- a/examples/showcase/column/column-width/demo.html +++ b/examples/showcase/column/column-width/demo.html @@ -2,7 +2,7 @@ - +
diff --git a/examples/showcase/line/line-basic/demo.html b/examples/showcase/line/line-basic/demo.html index 6c09c887..070c929a 100644 --- a/examples/showcase/line/line-basic/demo.html +++ b/examples/showcase/line/line-basic/demo.html @@ -2,7 +2,7 @@ - +
diff --git a/examples/showcase/line/line-dates/demo.html b/examples/showcase/line/line-dates/demo.html index e6736ea9..421e5bea 100644 --- a/examples/showcase/line/line-dates/demo.html +++ b/examples/showcase/line/line-dates/demo.html @@ -2,7 +2,7 @@ - +
NASDAQ Index - 2013
diff --git a/examples/showcase/line/line-export/demo.html b/examples/showcase/line/line-export/demo.html index 57c586b3..e329132c 100644 --- a/examples/showcase/line/line-export/demo.html +++ b/examples/showcase/line/line-export/demo.html @@ -2,7 +2,7 @@ - +
Recorded Speeds
diff --git a/examples/showcase/line/line-markers/demo.html b/examples/showcase/line/line-markers/demo.html index 9350f4e7..58955a16 100644 --- a/examples/showcase/line/line-markers/demo.html +++ b/examples/showcase/line/line-markers/demo.html @@ -2,7 +2,7 @@ - +
Maximum Daily Temperature 2013
South Lake Tahoe
diff --git a/examples/showcase/line/line-multi-basic/demo.html b/examples/showcase/line/line-multi-basic/demo.html index 21255517..1bcf34d3 100644 --- a/examples/showcase/line/line-multi-basic/demo.html +++ b/examples/showcase/line/line-multi-basic/demo.html @@ -2,7 +2,7 @@ - +
Test Scores by Group Size
diff --git a/examples/showcase/line/line-sine/demo.html b/examples/showcase/line/line-sine/demo.html index 3dda5bcb..de5a9733 100644 --- a/examples/showcase/line/line-sine/demo.html +++ b/examples/showcase/line/line-sine/demo.html @@ -2,7 +2,7 @@ - +
diff --git a/examples/showcase/pie/donut-series/demo.html b/examples/showcase/pie/donut-series/demo.html index 8705f7c4..77a933b3 100644 --- a/examples/showcase/pie/donut-series/demo.html +++ b/examples/showcase/pie/donut-series/demo.html @@ -2,7 +2,7 @@ - +
Sales by Country
diff --git a/examples/showcase/pie/pie-basic/demo.html b/examples/showcase/pie/pie-basic/demo.html index 364b037b..bf8fecf1 100644 --- a/examples/showcase/pie/pie-basic/demo.html +++ b/examples/showcase/pie/pie-basic/demo.html @@ -2,7 +2,7 @@ - +
Smartphone Market Share
diff --git a/examples/showcase/pie/pie-donut/demo.html b/examples/showcase/pie/pie-donut/demo.html index fc7065ed..2ebc45c2 100644 --- a/examples/showcase/pie/pie-donut/demo.html +++ b/examples/showcase/pie/pie-donut/demo.html @@ -2,7 +2,7 @@ - +
F1 Wins by Driver - 2013
diff --git a/examples/showcase/pie/pie-gauge/demo.html b/examples/showcase/pie/pie-gauge/demo.html index 781ef31c..59640498 100644 --- a/examples/showcase/pie/pie-gauge/demo.html +++ b/examples/showcase/pie/pie-gauge/demo.html @@ -2,7 +2,7 @@ - +
diff --git a/examples/showcase/pie/pie-series/demo.html b/examples/showcase/pie/pie-series/demo.html index 8705f7c4..77a933b3 100644 --- a/examples/showcase/pie/pie-series/demo.html +++ b/examples/showcase/pie/pie-series/demo.html @@ -2,7 +2,7 @@ - +
Sales by Country
diff --git a/examples/showcase/scatter/scatter-basic/demo.html b/examples/showcase/scatter/scatter-basic/demo.html index 6667b84d..73dd2491 100644 --- a/examples/showcase/scatter/scatter-basic/demo.html +++ b/examples/showcase/scatter/scatter-basic/demo.html @@ -2,7 +2,7 @@ - +
diff --git a/examples/showcase/scatter/scatter-export/demo.html b/examples/showcase/scatter/scatter-export/demo.html index c0ca5e32..abdd63ee 100644 --- a/examples/showcase/scatter/scatter-export/demo.html +++ b/examples/showcase/scatter/scatter-export/demo.html @@ -2,7 +2,7 @@ - +
diff --git a/examples/showcase/scatter/scatter-trendline/demo.html b/examples/showcase/scatter/scatter-trendline/demo.html index 76b075c7..310f46eb 100644 --- a/examples/showcase/scatter/scatter-trendline/demo.html +++ b/examples/showcase/scatter/scatter-trendline/demo.html @@ -2,7 +2,7 @@ - +
Effect of Study in Test Scores
1999 Results
diff --git a/src/documentation/fiddle/Contour.expose/demo.html b/src/documentation/fiddle/Contour.expose/demo.html index 3fc6083d..fff7a599 100644 --- a/src/documentation/fiddle/Contour.expose/demo.html +++ b/src/documentation/fiddle/Contour.expose/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.area.areaBase/demo.html b/src/documentation/fiddle/config.area.areaBase/demo.html index 420cfb85..789e8370 100644 --- a/src/documentation/fiddle/config.area.areaBase/demo.html +++ b/src/documentation/fiddle/config.area.areaBase/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.area.preprocess/demo.html b/src/documentation/fiddle/config.area.preprocess/demo.html index 420cfb85..789e8370 100644 --- a/src/documentation/fiddle/config.area.preprocess/demo.html +++ b/src/documentation/fiddle/config.area.preprocess/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.area.stacked/demo.html b/src/documentation/fiddle/config.area.stacked/demo.html index 420cfb85..789e8370 100644 --- a/src/documentation/fiddle/config.area.stacked/demo.html +++ b/src/documentation/fiddle/config.area.stacked/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.area/demo.html b/src/documentation/fiddle/config.area/demo.html index 420cfb85..789e8370 100644 --- a/src/documentation/fiddle/config.area/demo.html +++ b/src/documentation/fiddle/config.area/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.bar.barClass/demo.html b/src/documentation/fiddle/config.bar.barClass/demo.html index f476748c..da5db8b5 100644 --- a/src/documentation/fiddle/config.bar.barClass/demo.html +++ b/src/documentation/fiddle/config.bar.barClass/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.bar.barWidth/demo.html b/src/documentation/fiddle/config.bar.barWidth/demo.html index c31183d4..da8a896c 100644 --- a/src/documentation/fiddle/config.bar.barWidth/demo.html +++ b/src/documentation/fiddle/config.bar.barWidth/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.bar.groupPadding/demo.html b/src/documentation/fiddle/config.bar.groupPadding/demo.html index 4bde639c..2e17ca92 100644 --- a/src/documentation/fiddle/config.bar.groupPadding/demo.html +++ b/src/documentation/fiddle/config.bar.groupPadding/demo.html @@ -2,7 +2,7 @@ - +
diff --git a/src/documentation/fiddle/config.bar.offset/demo.html b/src/documentation/fiddle/config.bar.offset/demo.html index c31183d4..da8a896c 100644 --- a/src/documentation/fiddle/config.bar.offset/demo.html +++ b/src/documentation/fiddle/config.bar.offset/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.bar.preprocess/demo.html b/src/documentation/fiddle/config.bar.preprocess/demo.html index c31183d4..da8a896c 100644 --- a/src/documentation/fiddle/config.bar.preprocess/demo.html +++ b/src/documentation/fiddle/config.bar.preprocess/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.bar.stacked/demo.html b/src/documentation/fiddle/config.bar.stacked/demo.html index c31183d4..da8a896c 100644 --- a/src/documentation/fiddle/config.bar.stacked/demo.html +++ b/src/documentation/fiddle/config.bar.stacked/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.bar.style/demo.html b/src/documentation/fiddle/config.bar.style/demo.html index c31183d4..da8a896c 100644 --- a/src/documentation/fiddle/config.bar.style/demo.html +++ b/src/documentation/fiddle/config.bar.style/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.bar/demo.html b/src/documentation/fiddle/config.bar/demo.html index c31183d4..da8a896c 100644 --- a/src/documentation/fiddle/config.bar/demo.html +++ b/src/documentation/fiddle/config.bar/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.chart.animations.duration/demo.html b/src/documentation/fiddle/config.chart.animations.duration/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.chart.animations.duration/demo.html +++ b/src/documentation/fiddle/config.chart.animations.duration/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.chart.animations.enable/demo.html b/src/documentation/fiddle/config.chart.animations.enable/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.chart.animations.enable/demo.html +++ b/src/documentation/fiddle/config.chart.animations.enable/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.chart.defaultAspect/demo.html b/src/documentation/fiddle/config.chart.defaultAspect/demo.html index 3fc6083d..fff7a599 100644 --- a/src/documentation/fiddle/config.chart.defaultAspect/demo.html +++ b/src/documentation/fiddle/config.chart.defaultAspect/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.chart.defaultWidth/demo.html b/src/documentation/fiddle/config.chart.defaultWidth/demo.html index 3fc6083d..fff7a599 100644 --- a/src/documentation/fiddle/config.chart.defaultWidth/demo.html +++ b/src/documentation/fiddle/config.chart.defaultWidth/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.chart.gridlines/demo.html b/src/documentation/fiddle/config.chart.gridlines/demo.html index 3fc6083d..fff7a599 100644 --- a/src/documentation/fiddle/config.chart.gridlines/demo.html +++ b/src/documentation/fiddle/config.chart.gridlines/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.chart.height/demo.html b/src/documentation/fiddle/config.chart.height/demo.html index 3fc6083d..fff7a599 100644 --- a/src/documentation/fiddle/config.chart.height/demo.html +++ b/src/documentation/fiddle/config.chart.height/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.chart.margin.bottom/demo.html b/src/documentation/fiddle/config.chart.margin.bottom/demo.html index 3fc6083d..fff7a599 100644 --- a/src/documentation/fiddle/config.chart.margin.bottom/demo.html +++ b/src/documentation/fiddle/config.chart.margin.bottom/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.chart.margin.left/demo.html b/src/documentation/fiddle/config.chart.margin.left/demo.html index 3fc6083d..fff7a599 100644 --- a/src/documentation/fiddle/config.chart.margin.left/demo.html +++ b/src/documentation/fiddle/config.chart.margin.left/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.chart.margin.right/demo.html b/src/documentation/fiddle/config.chart.margin.right/demo.html index 3fc6083d..fff7a599 100644 --- a/src/documentation/fiddle/config.chart.margin.right/demo.html +++ b/src/documentation/fiddle/config.chart.margin.right/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.chart.margin.top/demo.html b/src/documentation/fiddle/config.chart.margin.top/demo.html index 3fc6083d..fff7a599 100644 --- a/src/documentation/fiddle/config.chart.margin.top/demo.html +++ b/src/documentation/fiddle/config.chart.margin.top/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.chart.padding.bottom/demo.html b/src/documentation/fiddle/config.chart.padding.bottom/demo.html index 3fc6083d..fff7a599 100644 --- a/src/documentation/fiddle/config.chart.padding.bottom/demo.html +++ b/src/documentation/fiddle/config.chart.padding.bottom/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.chart.padding.left/demo.html b/src/documentation/fiddle/config.chart.padding.left/demo.html index 3fc6083d..fff7a599 100644 --- a/src/documentation/fiddle/config.chart.padding.left/demo.html +++ b/src/documentation/fiddle/config.chart.padding.left/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.chart.padding.right/demo.html b/src/documentation/fiddle/config.chart.padding.right/demo.html index a749e4ca..b9fa5a0e 100644 --- a/src/documentation/fiddle/config.chart.padding.right/demo.html +++ b/src/documentation/fiddle/config.chart.padding.right/demo.html @@ -2,7 +2,7 @@ - +
diff --git a/src/documentation/fiddle/config.chart.padding.top/demo.html b/src/documentation/fiddle/config.chart.padding.top/demo.html index a749e4ca..b9fa5a0e 100644 --- a/src/documentation/fiddle/config.chart.padding.top/demo.html +++ b/src/documentation/fiddle/config.chart.padding.top/demo.html @@ -2,7 +2,7 @@ - +
diff --git a/src/documentation/fiddle/config.chart.width/demo.html b/src/documentation/fiddle/config.chart.width/demo.html index a749e4ca..b9fa5a0e 100644 --- a/src/documentation/fiddle/config.chart.width/demo.html +++ b/src/documentation/fiddle/config.chart.width/demo.html @@ -2,7 +2,7 @@ - +
diff --git a/src/documentation/fiddle/config.chart/demo.html b/src/documentation/fiddle/config.chart/demo.html index 3fc6083d..fff7a599 100644 --- a/src/documentation/fiddle/config.chart/demo.html +++ b/src/documentation/fiddle/config.chart/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.column.columnClass/demo.html b/src/documentation/fiddle/config.column.columnClass/demo.html index f3078f7a..8ba3bd25 100644 --- a/src/documentation/fiddle/config.column.columnClass/demo.html +++ b/src/documentation/fiddle/config.column.columnClass/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.column.columnWidth/demo.html b/src/documentation/fiddle/config.column.columnWidth/demo.html index f7333823..06bcee18 100644 --- a/src/documentation/fiddle/config.column.columnWidth/demo.html +++ b/src/documentation/fiddle/config.column.columnWidth/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.column.groupPadding/demo.html b/src/documentation/fiddle/config.column.groupPadding/demo.html index f7333823..06bcee18 100644 --- a/src/documentation/fiddle/config.column.groupPadding/demo.html +++ b/src/documentation/fiddle/config.column.groupPadding/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.column.offset/demo.html b/src/documentation/fiddle/config.column.offset/demo.html index f7333823..06bcee18 100644 --- a/src/documentation/fiddle/config.column.offset/demo.html +++ b/src/documentation/fiddle/config.column.offset/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.column.stacked/demo.html b/src/documentation/fiddle/config.column.stacked/demo.html index f7333823..06bcee18 100644 --- a/src/documentation/fiddle/config.column.stacked/demo.html +++ b/src/documentation/fiddle/config.column.stacked/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.column.style/demo.html b/src/documentation/fiddle/config.column.style/demo.html index f7333823..06bcee18 100644 --- a/src/documentation/fiddle/config.column.style/demo.html +++ b/src/documentation/fiddle/config.column.style/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.column/demo.html b/src/documentation/fiddle/config.column/demo.html index f7333823..06bcee18 100644 --- a/src/documentation/fiddle/config.column/demo.html +++ b/src/documentation/fiddle/config.column/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.legend.direction/demo.html b/src/documentation/fiddle/config.legend.direction/demo.html index 3fc6083d..fff7a599 100644 --- a/src/documentation/fiddle/config.legend.direction/demo.html +++ b/src/documentation/fiddle/config.legend.direction/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.legend.el/demo.html b/src/documentation/fiddle/config.legend.el/demo.html index 09440c0f..887c8d55 100644 --- a/src/documentation/fiddle/config.legend.el/demo.html +++ b/src/documentation/fiddle/config.legend.el/demo.html @@ -1,7 +1,7 @@ - + diff --git a/src/documentation/fiddle/config.legend.hAlign/demo.html b/src/documentation/fiddle/config.legend.hAlign/demo.html index 3fc6083d..fff7a599 100644 --- a/src/documentation/fiddle/config.legend.hAlign/demo.html +++ b/src/documentation/fiddle/config.legend.hAlign/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.legend.vAlign/demo.html b/src/documentation/fiddle/config.legend.vAlign/demo.html index 3fc6083d..fff7a599 100644 --- a/src/documentation/fiddle/config.legend.vAlign/demo.html +++ b/src/documentation/fiddle/config.legend.vAlign/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.legend/demo.html b/src/documentation/fiddle/config.legend/demo.html index 3fc6083d..fff7a599 100644 --- a/src/documentation/fiddle/config.legend/demo.html +++ b/src/documentation/fiddle/config.legend/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.line.marker.enable/demo.html b/src/documentation/fiddle/config.line.marker.enable/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.line.marker.enable/demo.html +++ b/src/documentation/fiddle/config.line.marker.enable/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.line.marker.size/demo.html b/src/documentation/fiddle/config.line.marker.size/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.line.marker.size/demo.html +++ b/src/documentation/fiddle/config.line.marker.size/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.line.preprocess/demo.html b/src/documentation/fiddle/config.line.preprocess/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.line.preprocess/demo.html +++ b/src/documentation/fiddle/config.line.preprocess/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.line.smooth/demo.html b/src/documentation/fiddle/config.line.smooth/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.line.smooth/demo.html +++ b/src/documentation/fiddle/config.line.smooth/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.line.stacked/demo.html b/src/documentation/fiddle/config.line.stacked/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.line.stacked/demo.html +++ b/src/documentation/fiddle/config.line.stacked/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.line/demo.html b/src/documentation/fiddle/config.line/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.line/demo.html +++ b/src/documentation/fiddle/config.line/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.pie.innerRadius/demo.html b/src/documentation/fiddle/config.pie.innerRadius/demo.html index 44eeb7bc..f26db27b 100644 --- a/src/documentation/fiddle/config.pie.innerRadius/demo.html +++ b/src/documentation/fiddle/config.pie.innerRadius/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.pie.outerRadius/demo.html b/src/documentation/fiddle/config.pie.outerRadius/demo.html index 44eeb7bc..f26db27b 100644 --- a/src/documentation/fiddle/config.pie.outerRadius/demo.html +++ b/src/documentation/fiddle/config.pie.outerRadius/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.pie.piePadding.bottom/demo.html b/src/documentation/fiddle/config.pie.piePadding.bottom/demo.html index 44eeb7bc..f26db27b 100644 --- a/src/documentation/fiddle/config.pie.piePadding.bottom/demo.html +++ b/src/documentation/fiddle/config.pie.piePadding.bottom/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.pie.piePadding.left/demo.html b/src/documentation/fiddle/config.pie.piePadding.left/demo.html index 44eeb7bc..f26db27b 100644 --- a/src/documentation/fiddle/config.pie.piePadding.left/demo.html +++ b/src/documentation/fiddle/config.pie.piePadding.left/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.pie.piePadding.right/demo.html b/src/documentation/fiddle/config.pie.piePadding.right/demo.html index 44eeb7bc..f26db27b 100644 --- a/src/documentation/fiddle/config.pie.piePadding.right/demo.html +++ b/src/documentation/fiddle/config.pie.piePadding.right/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.pie.piePadding.top/demo.html b/src/documentation/fiddle/config.pie.piePadding.top/demo.html index 44eeb7bc..f26db27b 100644 --- a/src/documentation/fiddle/config.pie.piePadding.top/demo.html +++ b/src/documentation/fiddle/config.pie.piePadding.top/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.pie.piePadding/demo.html b/src/documentation/fiddle/config.pie.piePadding/demo.html index 44eeb7bc..f26db27b 100644 --- a/src/documentation/fiddle/config.pie.piePadding/demo.html +++ b/src/documentation/fiddle/config.pie.piePadding/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.pie.sliceClass/demo.html b/src/documentation/fiddle/config.pie.sliceClass/demo.html index 7d95f499..fd122035 100644 --- a/src/documentation/fiddle/config.pie.sliceClass/demo.html +++ b/src/documentation/fiddle/config.pie.sliceClass/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.pie.style/demo.html b/src/documentation/fiddle/config.pie.style/demo.html index 44eeb7bc..f26db27b 100644 --- a/src/documentation/fiddle/config.pie.style/demo.html +++ b/src/documentation/fiddle/config.pie.style/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.pie/demo.html b/src/documentation/fiddle/config.pie/demo.html index 44eeb7bc..f26db27b 100644 --- a/src/documentation/fiddle/config.pie/demo.html +++ b/src/documentation/fiddle/config.pie/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.scatter.preprocess/demo.html b/src/documentation/fiddle/config.scatter.preprocess/demo.html index 10e2de68..5df716fa 100644 --- a/src/documentation/fiddle/config.scatter.preprocess/demo.html +++ b/src/documentation/fiddle/config.scatter.preprocess/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.scatter.radius/demo.html b/src/documentation/fiddle/config.scatter.radius/demo.html index 10e2de68..5df716fa 100644 --- a/src/documentation/fiddle/config.scatter.radius/demo.html +++ b/src/documentation/fiddle/config.scatter.radius/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.scatter/demo.html b/src/documentation/fiddle/config.scatter/demo.html index 10e2de68..5df716fa 100644 --- a/src/documentation/fiddle/config.scatter/demo.html +++ b/src/documentation/fiddle/config.scatter/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.tooltip.animate/demo.html b/src/documentation/fiddle/config.tooltip.animate/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.tooltip.animate/demo.html +++ b/src/documentation/fiddle/config.tooltip.animate/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.tooltip.distance/demo.html b/src/documentation/fiddle/config.tooltip.distance/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.tooltip.distance/demo.html +++ b/src/documentation/fiddle/config.tooltip.distance/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.tooltip.formatter/demo.html b/src/documentation/fiddle/config.tooltip.formatter/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.tooltip.formatter/demo.html +++ b/src/documentation/fiddle/config.tooltip.formatter/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.tooltip.hideTime/demo.html b/src/documentation/fiddle/config.tooltip.hideTime/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.tooltip.hideTime/demo.html +++ b/src/documentation/fiddle/config.tooltip.hideTime/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.tooltip.opacity/demo.html b/src/documentation/fiddle/config.tooltip.opacity/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.tooltip.opacity/demo.html +++ b/src/documentation/fiddle/config.tooltip.opacity/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.tooltip.showTime/demo.html b/src/documentation/fiddle/config.tooltip.showTime/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.tooltip.showTime/demo.html +++ b/src/documentation/fiddle/config.tooltip.showTime/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.tooltip/demo.html b/src/documentation/fiddle/config.tooltip/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.tooltip/demo.html +++ b/src/documentation/fiddle/config.tooltip/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.categories/demo.html b/src/documentation/fiddle/config.xAxis.categories/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.categories/demo.html +++ b/src/documentation/fiddle/config.xAxis.categories/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.firstAndLast/demo.html b/src/documentation/fiddle/config.xAxis.firstAndLast/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.firstAndLast/demo.html +++ b/src/documentation/fiddle/config.xAxis.firstAndLast/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.innerRangePadding/demo.html b/src/documentation/fiddle/config.xAxis.innerRangePadding/demo.html index f7333823..06bcee18 100644 --- a/src/documentation/fiddle/config.xAxis.innerRangePadding/demo.html +++ b/src/documentation/fiddle/config.xAxis.innerRangePadding/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.innerTickSize/demo.html b/src/documentation/fiddle/config.xAxis.innerTickSize/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.innerTickSize/demo.html +++ b/src/documentation/fiddle/config.xAxis.innerTickSize/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.labels.format/demo.html b/src/documentation/fiddle/config.xAxis.labels.format/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.labels.format/demo.html +++ b/src/documentation/fiddle/config.xAxis.labels.format/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.labels.formatter/demo.html b/src/documentation/fiddle/config.xAxis.labels.formatter/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.labels.formatter/demo.html +++ b/src/documentation/fiddle/config.xAxis.labels.formatter/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.linearDomain/demo.html b/src/documentation/fiddle/config.xAxis.linearDomain/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.linearDomain/demo.html +++ b/src/documentation/fiddle/config.xAxis.linearDomain/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.max/demo.html b/src/documentation/fiddle/config.xAxis.max/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.max/demo.html +++ b/src/documentation/fiddle/config.xAxis.max/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.maxTicks/demo.html b/src/documentation/fiddle/config.xAxis.maxTicks/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.maxTicks/demo.html +++ b/src/documentation/fiddle/config.xAxis.maxTicks/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.min/demo.html b/src/documentation/fiddle/config.xAxis.min/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.min/demo.html +++ b/src/documentation/fiddle/config.xAxis.min/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.orient/demo.html b/src/documentation/fiddle/config.xAxis.orient/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.orient/demo.html +++ b/src/documentation/fiddle/config.xAxis.orient/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.outerRangePadding/demo.html b/src/documentation/fiddle/config.xAxis.outerRangePadding/demo.html index f7333823..06bcee18 100644 --- a/src/documentation/fiddle/config.xAxis.outerRangePadding/demo.html +++ b/src/documentation/fiddle/config.xAxis.outerRangePadding/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.outerTickSize/demo.html b/src/documentation/fiddle/config.xAxis.outerTickSize/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.outerTickSize/demo.html +++ b/src/documentation/fiddle/config.xAxis.outerTickSize/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.tickPadding/demo.html b/src/documentation/fiddle/config.xAxis.tickPadding/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.tickPadding/demo.html +++ b/src/documentation/fiddle/config.xAxis.tickPadding/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.tickValues/demo.html b/src/documentation/fiddle/config.xAxis.tickValues/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.tickValues/demo.html +++ b/src/documentation/fiddle/config.xAxis.tickValues/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.ticks/demo.html b/src/documentation/fiddle/config.xAxis.ticks/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.ticks/demo.html +++ b/src/documentation/fiddle/config.xAxis.ticks/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.title/demo.html b/src/documentation/fiddle/config.xAxis.title/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.title/demo.html +++ b/src/documentation/fiddle/config.xAxis.title/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.titlePadding/demo.html b/src/documentation/fiddle/config.xAxis.titlePadding/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.titlePadding/demo.html +++ b/src/documentation/fiddle/config.xAxis.titlePadding/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis.type/demo.html b/src/documentation/fiddle/config.xAxis.type/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis.type/demo.html +++ b/src/documentation/fiddle/config.xAxis.type/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.xAxis/demo.html b/src/documentation/fiddle/config.xAxis/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.xAxis/demo.html +++ b/src/documentation/fiddle/config.xAxis/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.yAxis.innerTickSize/demo.html b/src/documentation/fiddle/config.yAxis.innerTickSize/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.yAxis.innerTickSize/demo.html +++ b/src/documentation/fiddle/config.yAxis.innerTickSize/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.yAxis.labels.format/demo.html b/src/documentation/fiddle/config.yAxis.labels.format/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.yAxis.labels.format/demo.html +++ b/src/documentation/fiddle/config.yAxis.labels.format/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.yAxis.labels.formatter/demo.html b/src/documentation/fiddle/config.yAxis.labels.formatter/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.yAxis.labels.formatter/demo.html +++ b/src/documentation/fiddle/config.yAxis.labels.formatter/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.yAxis.labels.verticalAlign/demo.html b/src/documentation/fiddle/config.yAxis.labels.verticalAlign/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.yAxis.labels.verticalAlign/demo.html +++ b/src/documentation/fiddle/config.yAxis.labels.verticalAlign/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.yAxis.max/demo.html b/src/documentation/fiddle/config.yAxis.max/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.yAxis.max/demo.html +++ b/src/documentation/fiddle/config.yAxis.max/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.yAxis.min/demo.html b/src/documentation/fiddle/config.yAxis.min/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.yAxis.min/demo.html +++ b/src/documentation/fiddle/config.yAxis.min/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.yAxis.orient/demo.html b/src/documentation/fiddle/config.yAxis.orient/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.yAxis.orient/demo.html +++ b/src/documentation/fiddle/config.yAxis.orient/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.yAxis.outerTickSize/demo.html b/src/documentation/fiddle/config.yAxis.outerTickSize/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.yAxis.outerTickSize/demo.html +++ b/src/documentation/fiddle/config.yAxis.outerTickSize/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.yAxis.smartAxis/demo.html b/src/documentation/fiddle/config.yAxis.smartAxis/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.yAxis.smartAxis/demo.html +++ b/src/documentation/fiddle/config.yAxis.smartAxis/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.yAxis.tickPadding/demo.html b/src/documentation/fiddle/config.yAxis.tickPadding/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.yAxis.tickPadding/demo.html +++ b/src/documentation/fiddle/config.yAxis.tickPadding/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.yAxis.tickValues/demo.html b/src/documentation/fiddle/config.yAxis.tickValues/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.yAxis.tickValues/demo.html +++ b/src/documentation/fiddle/config.yAxis.tickValues/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.yAxis.ticks/demo.html b/src/documentation/fiddle/config.yAxis.ticks/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.yAxis.ticks/demo.html +++ b/src/documentation/fiddle/config.yAxis.ticks/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.yAxis.title/demo.html b/src/documentation/fiddle/config.yAxis.title/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.yAxis.title/demo.html +++ b/src/documentation/fiddle/config.yAxis.title/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.yAxis.titlePadding/demo.html b/src/documentation/fiddle/config.yAxis.titlePadding/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.yAxis.titlePadding/demo.html +++ b/src/documentation/fiddle/config.yAxis.titlePadding/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.yAxis.zeroAnchor/demo.html b/src/documentation/fiddle/config.yAxis.zeroAnchor/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.yAxis.zeroAnchor/demo.html +++ b/src/documentation/fiddle/config.yAxis.zeroAnchor/demo.html @@ -1,7 +1,7 @@ - +
diff --git a/src/documentation/fiddle/config.yAxis/demo.html b/src/documentation/fiddle/config.yAxis/demo.html index c0a29db4..11bf2d1c 100644 --- a/src/documentation/fiddle/config.yAxis/demo.html +++ b/src/documentation/fiddle/config.yAxis/demo.html @@ -1,7 +1,7 @@ - +
From adffa7276978c958ff357fbf1839b433195d2246 Mon Sep 17 00:00:00 2001 From: Shiv Parikh Date: Wed, 4 Jan 2017 15:50:29 -0800 Subject: [PATCH 2/4] added enable option to legend and VisInstanceContainer#setVisibility function to hide specific visualizations --- dist/contour.js | 10 +++++++++- dist/contour.min.js | 6 +++--- dist/contour.min.js.map | 2 +- src/scripts/core/visualization-container.js | 6 ++++++ src/scripts/visualizations/legend.js | 4 ++++ 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/dist/contour.js b/dist/contour.js index 57fb5dc3..06ebccaf 100644 --- a/dist/contour.js +++ b/dist/contour.js @@ -1,4 +1,4 @@ -/*! Contour - v1.0.1 - 2016-12-28 */ +/*! Contour - v1.0.1 - 2017-01-04 */ (function(exports, global) { (function(undefined) { var root = this; @@ -2797,6 +2797,10 @@ this.options = _.merge({}, (this.renderer || {}).defaults || {}, opt); return this.ctx; }, + setVisibility: function(visible) { + var node = this.layer.node(); + visible ? $(node).show() : $(node).hide(); + }, _updateDomain: function() { if (!this.options[this.type]) throw new Error("Set the options before calling setData or _updateDomain"); var isSupportedFormat = (this.ctx || {}).isSupportedDataFormat || _.nw.isSupportedDataFormat; @@ -3193,6 +3197,7 @@ vAlign: "middle", hAlign: "right", direction: "vertical", + enabled: true, formatter: function(d) { return d.name; }, @@ -3217,6 +3222,9 @@ return classes; } function Legend(data, layer, options) { + if (options.legend.enabled === false) { + return; + } var container; if (options.legend.el) { container = d3.select(options.legend.el).node(); diff --git a/dist/contour.min.js b/dist/contour.min.js index bfdfccc0..4bd6294a 100644 --- a/dist/contour.min.js +++ b/dist/contour.min.js @@ -1,4 +1,4 @@ -/*! Contour - v1.0.1 - 2016-12-28 */ +/*! Contour - v1.0.1 - 2017-01-04 */ (function(exports,global){(function(undefined){var root=this;if(typeof module==="object"&&module&&typeof module.exports==="object"){if(typeof require==="function"){root.d3=require("d3");root._=require("lodash")}}if(!d3)throw new Error("You need to include d3.js before Contour. Go to http://d3js.org/");if(!_||!_.merge)throw new Error("You need to include lodash.js before Contour. Go to http://lodash.com/")})();(function(){ // cheap trick to add decimals without hitting javascript issues @@ -678,7 +678,7 @@ Contour.expose("horizontal",frame)})();(function(){var _extent=function(series,f if(!mins.length||!maxs.length)return[];return[_.min(mins),_.max(maxs)]};/*jshint eqnull:true */ var _stackedExtent=function(data){var stack=_.nw.stackLayout();var dataSets=stack(data);var ext=[];_.each(dataSets,function(set){_.each(set.data,function(d,i){var cur=ext[i]||0;ext[i]=cur+d.y})});return[_.min(ext),_.max(ext)]};var _xExtent=_.partialRight(_extent,"x");var _yExtent=_.partialRight(_extent,"y");function VisInstanceContainer(data,categories,options,type,renderer,context){this.type=type;this.renderer=renderer;this.ctx=context;this.categories=categories;this.init(data,options)}VisInstanceContainer.prototype={init:function(data,options){ // set the options first and then the data -this.setOptions(options);this.setData(data)},render:function(layer,options){this.renderer.call(this.ctx,this.data,layer,options);return this.ctx},setData:function(data){var normalizeData=(this.ctx||{}).dataNormalizer||_.nw.normalizeSeries;this.data=normalizeData(data,this.categories);this._updateDomain();return this.ctx},setOptions:function(options){var opt={};opt[this.type]=options||{};this.options={};this.options=_.merge({},(this.renderer||{}).defaults||{},opt);return this.ctx},_updateDomain:function(){if(!this.options[this.type])throw new Error("Set the options before calling setData or _updateDomain");var isSupportedFormat=(this.ctx||{}).isSupportedDataFormat||_.nw.isSupportedDataFormat;if(isSupportedFormat(this.data)){this.xDomain=_.flatten(_.map(this.data,function(set){return _.map(set.data,"x")}));this.xExtent=_xExtent(this.data,"x");this.yExtent=this.options[this.type].stacked?_stackedExtent(this.data):_yExtent(this.data)}}};Contour.VisualizationContainer=VisInstanceContainer})();(function(){var defaults={xAxis:{type:"linear"},area:{stacked:true,areaBase:undefined,preprocess:_.nw.minMaxFilter(1e3)}};/* jshint eqnull:true */ +this.setOptions(options);this.setData(data)},render:function(layer,options){this.renderer.call(this.ctx,this.data,layer,options);return this.ctx},setData:function(data){var normalizeData=(this.ctx||{}).dataNormalizer||_.nw.normalizeSeries;this.data=normalizeData(data,this.categories);this._updateDomain();return this.ctx},setOptions:function(options){var opt={};opt[this.type]=options||{};this.options={};this.options=_.merge({},(this.renderer||{}).defaults||{},opt);return this.ctx},setVisibility:function(visible){var node=this.layer.node();visible?$(node).show():$(node).hide()},_updateDomain:function(){if(!this.options[this.type])throw new Error("Set the options before calling setData or _updateDomain");var isSupportedFormat=(this.ctx||{}).isSupportedDataFormat||_.nw.isSupportedDataFormat;if(isSupportedFormat(this.data)){this.xDomain=_.flatten(_.map(this.data,function(set){return _.map(set.data,"x")}));this.xExtent=_xExtent(this.data,"x");this.yExtent=this.options[this.type].stacked?_stackedExtent(this.data):_yExtent(this.data)}}};Contour.VisualizationContainer=VisInstanceContainer})();(function(){var defaults={xAxis:{type:"linear"},area:{stacked:true,areaBase:undefined,preprocess:_.nw.minMaxFilter(1e3)}};/* jshint eqnull:true */ function renderer(data,layer,options){this.checkDependencies("cartesian");var duration=options.chart.animations.duration!=null?options.chart.animations.duration:400;var x=_.bind(function(val){return this.xScale(val)+this.rangeBand/2+.5},this);var y=_.bind(function(val){return this.yScale(val)+.5},this);var h=options.chart.plotHeight;var classFn=function(d,i){return"series s-"+(i+1)+" "+d.name};var stack=d3.layout.stack().values(function(d){return d.data});var startArea=d3.svg.area().x(function(d){return x(d.x)}).y0(function(d){return h}).y1(function(d){return h});var areaBase=options.area.areaBase!=null?options.area.areaBase:options.yAxis.min;var area=d3.svg.area().x(function(d){return x(d.x)}).y0(function(d){return options.area.stacked?y(d.y0||areaBase||0):y(0)}).y1(function(d){return y((options.area.stacked?d.y0:0)+d.y)});if(options.area.smooth){area.interpolate("cardinal");startArea.interpolate("cardinal")}renderSeries();if(options.tooltip&&options.tooltip.enable)renderTooltipTrackers();function renderSeries(){data=options.area.preprocess(data);var series=layer.selectAll("g.series").data(stack(data));series.enter().append("svg:g").attr("class",classFn).append("path").datum(function(d){return d.data}).attr("class","area").attr("d",startArea);series.exit().remove();if(options.chart.animations&&options.chart.animations.enable){series.select(".area").datum(function(d){return d.data}).transition().duration(options.chart.animations.duration||duration).attr("d",area)}else{series.select(".area").datum(function(d){return d.data}).attr("d",area)}}function renderTooltipTrackers(){var trackerSize=10; // add the tooltip trackers regardless var markers=layer.selectAll(".tooltip-trackers").data(data,function(d){return d.name});markers.enter().append("g").attr("class","tooltip-trackers");markers.exit().remove();var blocks=markers.selectAll(".tooltip-tracker").data(function(d){return d.data},function(d,i){return[d.x,d.y,d.y0].join("&")});blocks.enter().append("rect").attr("class","tooltip-tracker").attr("opacity",0).attr("width",trackerSize*2);blocks.attr("x",function(d){return x(d.x)-trackerSize}).attr("y",function(d){return y((options.area.stacked?d.y0:0)+d.y)}).attr("height",function(d){return y(0)-y(d.y)});blocks.exit().remove()}}renderer.defaults=defaults;/** @@ -746,7 +746,7 @@ cols.attr("style",rectStyle);function stacked(col,enter){var base=y(0);col.attr( * @api public * */ -Contour.export("column",render)})();(function(){Contour.export("coolNarwhal",function(data,layer){layer.append("path").attr("class","cool").attr("opacity",0).attr("transform","scale(.5) translate(500 150)").attr("d","M-220.02,76.509l-0.78,8.927c-0.956,10.949,1.389,20.422,6.188,30.383c10.203,21.173,63.095,84.05,93.72,115.075c20.145,20.406,19.487,23.018,21.549,40.122c2.487,20.621,24.897,66.462,40.838,71.269 c15.086,4.549,12.91-12.398,13.319-37.83c5.746,2.457,10.917,5.638,20.206,12.697c61.697,46.892,139.734,69.97,206.5,71.733c46.209,1.221,81.432-7.081,142.957-33.694c40.484-17.512,54.271-22.098,65.639-21.504c4.432,0.232,22.678,11.204,41.746,21.563c35.398,19.229,69.457,34.595,75.896,34.239c12.609-1.457-0.701-11.783-8.072-24.217c-7.049-11.892-15.414-29.572-18.844-42.134s-4.723-22.272-8.91-27.091c-2.143-2.463-12.812-6.786-21.189-8.146c-18.045-2.933-22.191-2.922-13.531-8.957c13.076-9.115,17.377-11.039,1.826-29.068c-6.383-7.402-11.336-20.003-13.709-39.542c-1.607-13.237,1.057-23.679-3.869-27.451s-17.271,12.341-20.846,19.334c-2.01,3.937-7.102,19.005-11.312,33.485c-13.795,47.427-29.865,65.742-62.693,71.447c-34.361,5.971-71.623-9.506-116.543-48.404c-13.164-11.399-29.533-25.26-39.254-36.913c-13.428-16.101-15.48-18.138-19.785-20.66c-16.166-9.472-54.98-31.694-103.525-63.815c-24.393-16.141-57.72-36.928-71.453-43.693c-27.236-13.417-68.416-28.952-90.731-46.771c-24.665-19.697-38.108-19.793-67.804-5.479c-21.429,10.328-23.941,15.298-26.52,15.726c-8.216-10.129-22.917-11.198-31.647-20.682c-9.529-10.35-28.027-14.098-37.824-24.957c-10.668-11.826-31.25-16.752-40.886-26.94c-11.339-11.989-29.387-16.096-40.838-26.637c-11.617-10.694-27.159-14.843-37.68-24.045c-10.383-9.082-23.187-12.538-31.408-19.163c-8.193-6.601-16.593-9.444-22.026-11.993c-5.433-2.549-7.398-2.522-7.658-1.927c-0.26,0.594,1.355,2.955,6.054,6.447c4.699,3.491,22.193,18.451,31.645,22.77c10.921,5.104,17.502,15.01,29.671,21.375c13.224,6.918,22.212,18.731,36.229,25.924c15.53,7.971,24.754,21.184,39.657,28.253c16.462,7.808,25.503,21.598,39.958,28.36c14.499,6.78,20.647,20.252,34.429,23.428C-238.033,58.207-227.932,70.443-220.02,76.509L-220.02,76.509z").transition().delay(300).duration(2e3).attr("opacity",1)})})();(function(){var defaults={legend:{vAlign:"middle",hAlign:"right",direction:"vertical",formatter:function(d){return d.name},el:undefined}};function validAlignmentClasses(options){var classes=[];if(["top","middle","bottom"].indexOf(options.legend.vAlign)!==-1){classes.push(options.legend.vAlign)}else{classes.push("top")}if(["left","center","right"].indexOf(options.legend.hAlign)!==-1){classes.push(options.legend.hAlign)}else{classes.push("right")}if(options.legend.direction==="vertical"){classes.push("vertical")}return classes}function Legend(data,layer,options){var container;if(options.legend.el){container=d3.select(options.legend.el).node();while(container.firstChild){container.removeChild(container.firstChild)}}else{this.container.selectAll(".contour-legend").remove()}var em=_.nw.textBounds("series",".contour-legend.contour-legend-entry");var count=data.length;var legendHeight=(em.height+4)*count+12;// legend has 1px border and 5px margin (12px) and each entry has ~2px margin +Contour.export("column",render)})();(function(){Contour.export("coolNarwhal",function(data,layer){layer.append("path").attr("class","cool").attr("opacity",0).attr("transform","scale(.5) translate(500 150)").attr("d","M-220.02,76.509l-0.78,8.927c-0.956,10.949,1.389,20.422,6.188,30.383c10.203,21.173,63.095,84.05,93.72,115.075c20.145,20.406,19.487,23.018,21.549,40.122c2.487,20.621,24.897,66.462,40.838,71.269 c15.086,4.549,12.91-12.398,13.319-37.83c5.746,2.457,10.917,5.638,20.206,12.697c61.697,46.892,139.734,69.97,206.5,71.733c46.209,1.221,81.432-7.081,142.957-33.694c40.484-17.512,54.271-22.098,65.639-21.504c4.432,0.232,22.678,11.204,41.746,21.563c35.398,19.229,69.457,34.595,75.896,34.239c12.609-1.457-0.701-11.783-8.072-24.217c-7.049-11.892-15.414-29.572-18.844-42.134s-4.723-22.272-8.91-27.091c-2.143-2.463-12.812-6.786-21.189-8.146c-18.045-2.933-22.191-2.922-13.531-8.957c13.076-9.115,17.377-11.039,1.826-29.068c-6.383-7.402-11.336-20.003-13.709-39.542c-1.607-13.237,1.057-23.679-3.869-27.451s-17.271,12.341-20.846,19.334c-2.01,3.937-7.102,19.005-11.312,33.485c-13.795,47.427-29.865,65.742-62.693,71.447c-34.361,5.971-71.623-9.506-116.543-48.404c-13.164-11.399-29.533-25.26-39.254-36.913c-13.428-16.101-15.48-18.138-19.785-20.66c-16.166-9.472-54.98-31.694-103.525-63.815c-24.393-16.141-57.72-36.928-71.453-43.693c-27.236-13.417-68.416-28.952-90.731-46.771c-24.665-19.697-38.108-19.793-67.804-5.479c-21.429,10.328-23.941,15.298-26.52,15.726c-8.216-10.129-22.917-11.198-31.647-20.682c-9.529-10.35-28.027-14.098-37.824-24.957c-10.668-11.826-31.25-16.752-40.886-26.94c-11.339-11.989-29.387-16.096-40.838-26.637c-11.617-10.694-27.159-14.843-37.68-24.045c-10.383-9.082-23.187-12.538-31.408-19.163c-8.193-6.601-16.593-9.444-22.026-11.993c-5.433-2.549-7.398-2.522-7.658-1.927c-0.26,0.594,1.355,2.955,6.054,6.447c4.699,3.491,22.193,18.451,31.645,22.77c10.921,5.104,17.502,15.01,29.671,21.375c13.224,6.918,22.212,18.731,36.229,25.924c15.53,7.971,24.754,21.184,39.657,28.253c16.462,7.808,25.503,21.598,39.958,28.36c14.499,6.78,20.647,20.252,34.429,23.428C-238.033,58.207-227.932,70.443-220.02,76.509L-220.02,76.509z").transition().delay(300).duration(2e3).attr("opacity",1)})})();(function(){var defaults={legend:{vAlign:"middle",hAlign:"right",direction:"vertical",enabled:true,formatter:function(d){return d.name},el:undefined}};function validAlignmentClasses(options){var classes=[];if(["top","middle","bottom"].indexOf(options.legend.vAlign)!==-1){classes.push(options.legend.vAlign)}else{classes.push("top")}if(["left","center","right"].indexOf(options.legend.hAlign)!==-1){classes.push(options.legend.hAlign)}else{classes.push("right")}if(options.legend.direction==="vertical"){classes.push("vertical")}return classes}function Legend(data,layer,options){if(options.legend.enabled===false){return}var container;if(options.legend.el){container=d3.select(options.legend.el).node();while(container.firstChild){container.removeChild(container.firstChild)}}else{this.container.selectAll(".contour-legend").remove()}var em=_.nw.textBounds("series",".contour-legend.contour-legend-entry");var count=data.length;var legendHeight=(em.height+4)*count+12;// legend has 1px border and 5px margin (12px) and each entry has ~2px margin var mid=(options.chart.plotHeight-legendHeight)/2;var positioner=function(selection){ // adjust position of legend only when is horizontally centered // since we need to have all elements in the legend to calculate its width diff --git a/dist/contour.min.js.map b/dist/contour.min.js.map index 64ac621f..000212f4 100644 --- a/dist/contour.min.js.map +++ b/dist/contour.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["?","../src/scripts/header.js","../src/scripts/core/contour-utils.js","../src/scripts/core/contour.js","../src/scripts/core/axis/y-axis.js","../src/scripts/core/cartesian.js","../src/scripts/core/exportable.js","../src/scripts/version.js","../src/scripts/core/axis/axis-scale-factory.js","../src/scripts/core/axis/linear-scale-axis.js","../src/scripts/core/axis/log-y-axis.js","../src/scripts/core/axis/ordinal-scale-axis.js","../src/scripts/core/axis/smart-y-axis.js","../src/scripts/core/axis/time-scale-axis.js","../src/scripts/core/horizontal-frame.js","../src/scripts/core/visualization-container.js","../src/scripts/visualizations/area.js","../src/scripts/visualizations/bar.js","../src/scripts/visualizations/column.js","../src/scripts/visualizations/cool-narwhal.js","../src/scripts/visualizations/legend.js","../src/scripts/visualizations/line.js","../src/scripts/visualizations/null.js","../src/scripts/visualizations/pie.js","../src/scripts/visualizations/scatter.js","../src/scripts/visualizations/stack-tooltip.js","../src/scripts/visualizations/tooltip.js","../src/scripts/visualizations/trend-line.js"],"names":["exports","global","undefined","root","this","module","require","d3","_","Error","merge","multiplier","x","dig","nw","decDigits","Math","pow","maxMultiplier","a","b","max","addFloat","factor","aa","round","bb","subFloat","mulFloat","divFloat","noop","generalHelpers","getValue","src","deafult","ctx","args","Array","prototype","slice","call","arguments","apply","seriesNameToClass","name","dataFilters","cleanNullValues","series","map","s","extend","data","reduce","acum","datum","y","push","minMaxFilter","desiredLen","length","toReturn","index","increment","floor","hasValidPt","maxPt","minPt","maxIndex","min","intermediateIndex","intermediatePt","logging","warn","msg","console","log","numberHelpers","firstAndLast","ar","roundToNearest","number","multiple","ceil","roundTo","value","digits","trunc","str","abs","toString","parts","split","log10","LN10","clamp","val","l","h","clampLeft","low","clampRight","high","degToRad","deg","PI","radToDeg","rad","rotatePoint","point","cos","sin","translatePoint","delta","linearRegression","dataSrc","lr","n","sum_x","sum_y","sum_xy","sum_xx","sum_yy","i","slope","intercept","r2","sqrt","niceRound","axisHelpers","addAxis","axisCtor","axes","roundToNextTick","num","sign","mag","step","exp","toExponential","replace","raw","niceMinMax","ticks","startAtZero","tickValues","swap","origMax","isNumber","range","concat","exponent","defaultRounding","excelRoundUp","up","roundFn","v","nice","negativeMinAmount","intermediateMax","iMin","inter","roundToDigits","intermediateMin","interval","finalMin","finalMax","ticksValues","prevTick","j","newTick","defaultMinMax","minMax","foundSomethingRound","some","every","tick","extractScaleDomain","domain","zeroAnchor","dataMin","dataMax","niceTicks","calcXLabelsWidths","padding","compact","String","d","textBounds","width","doXLabelsFit","labelFormatter","options","tickWidths","availableWidthForLabels","chart","plotWidth","axisLabelsWidth","sum","getTicksThatFit","reduceTicksByMod","iter","filterMod","finalTicks","filter","stringHelpers","text","css","body","document","getElementsByTagName","wrapper","createElement","dummy","className","style","position","height","visibility","lineHeight","whiteSpace","innerHTML","appendChild","res","clientWidth","clientHeight","removeChild","dateHelpers","dateDiff","d1","d2","diff","getTime","arrayHelpers","array1","array2","sort","isCorrectDataFormat","dataArray","isArray","p","hasOwnProperty","isCorrectSeriesFormat","isArrayOfObjects","isObject","hasDataArrayPerSeries","hasSeriesNamePerSeries","datumInCorrectFormat","normalizeSeries","categories","hasCategories","sortFn","normal","set","hasX","categoryAt","correctDataFormat","correctSeriesFormat","stackLayout","stack","layout","values","outFn","y0s","y0","out","uniq","array","cache","result","len","el","key","acc","cur","maxTickValues","tickInteval","isSupportedDataFormat","domHelpers","selectDom","selector","select","getStyle","elem","styles","offsetParent","ownerDocument","defaultView","getComputedStyle","getCentroid","element","getOffsetParent","t","tagName","parentNode","parentBox","getBoundingClientRect","bbox","left","top","debuggingHelpers","warning","defaults","animations","enable","duration","defaultWidth","defaultAspect","margin","right","bottom","internalPadding","rotatedFrame","plotHeight","plotTop","plotLeft","xAxis","yAxis","tooltip","Contour","init","export","ctorName","renderer","sortSeries","each","shouldSort","isDate","sortFunc","opt","vis","ownData","lastData","VisualizationContainer","_visualizations","expose","functionalityConstructor","ctor","functionality","Object","create","omit","_exposed","_extraOptions","calculateWidth","outerWidth","parseInt","paddingLeft","paddingRight","calculateHeight","outerHeight","paddingTop","paddingBottom","containerHeight","calcWidth","ratio","aspect","calcMetrics","adjustPadding","adjustTitlePadding","composeOptions","allDefaults","mergeExtraOptions","mergeDefaults","baseRender","plotArea","render","renderVisualizations","resize","container","update","chartOpt","attr","svg","append","node","createVisualizationLayer","id","type","visualization","layer","parent","bind","checkDependencies","listOfDependencies","_this","missing","dep","indexOf","join","ensureDefaults","isString","setData","invokeMap","dataNormalizer","define","amd","YAxis","setRange","scale","rangeSize","axis","dMin","dMax","numTicks","format","labels","formatter","_scale","tickFormat","tickSize","innerTickSize","outerTickSize","tickPadding","linear","setDomain","_niceTheScale","gridlines","maxTicks","title","titlePadding","innerRangePadding","outerRangePadding","orient","linearDomain","smartAxis","verticalAlign","cartesian","maxTickSize","readOnlyProps","extraPadding","xDomain","yDomain","_getYScaledDomain","opts","absMin","extent","xOptions","yOptions","_getAdjustedBottomPadding","_getAdjustedTopPadding","_getAdjustedLeftPadding","_getAdjustedRightPadding","xLabels","xAxisText","xLabelBounds","regularXBounds","em","ang","rotation","xLabelHeightUsed","yDomainScaled","tmpScale","yLabels","yAxisText","yLabelBounds","titleBounds","computeXScale","xScale","xScaleGenerator","xScaleFactory","rangeBand","computeYScale","yScaleDomain","yScale","yScaleGenerator","yScaleFactory","setYDomain","redrawYAxis","renderGridlines","_animationDuration","computeScales","_xAxis","_yAxis","renderXAxis","_xAxisGroup","selectAll","enter","transition","postProcessAxis","renderYAxis","_yAxisGroup","_renderYAxisElement","alignmentOffset","middle","renderAxisLabels","adjustFactor","bounds","option","horizontal","vertical","getYTicks","smart","pop","getXTicks","gr","w","lines","exit","remove","offset","renderBackground","background","g","adjustDomain","extents","getExtents","_adjustXDomain","_adjustYDomain","getXDomain","dataVis","flatten","isCategoricalData","dataSrcCategories","sameCats","intersection","yMin","yMax","field","all","defaultParams","fileName","target","backgroundColor","browser","checked","queue","working","exportable","cssIgnoreDiff","cssText","parentRule","cssSharedSvg","font","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","direction","letterSpacing","textDecoration","unicodeBidi","wordSpacing","clip","cursor","display","overflow","opacity","addToQueue","checkBrowser","download","exportImage","place","getSvgDataUrl","dataUrlCreated","makeSvgUrl","makeImageUrl","encodeBase64DataUrl","svgXml","btoa","dataUrlToBlob","dataUrl","byteString","atob","unescape","mimeString","byteArray","Uint8Array","charCodeAt","Blob","XMLSerializer","serializeToString","svgDataUrl","canvas","context","getContext","canvg","renderImageCanvg","renderImageNative","imageRendered","imageDataUrl","toDataURL","createsObjectUrls","imageBlob","domUrl","URL","webkitURL","objectUrl","createObjectURL","revokeObjectURL","svgImg","Image","onload","fillStyle","fillRect","drawImage","onerror","ignoreMouse","ignoreAnimation","offsetX","offsetY","scaleWidth","scaleHeight","renderCallback","createSvgClone","svgNode","svgCloned","createIsolatedNode","nodeClone","destroyIsolatedNode","cloneNodes","cloneLegendDiv","applyStyles","sourceNode","targetNode","sourceStyle","targetStyle","prop","isFinite","newNode","cloneNode","childNodes","childNode","nodeLoaded","iframe","iframeWindow","contentWindow","iframeDocument","destroyIframe","open","write","close","applyDivStylesToSvg","nodeName","rx","borderTopLeftRadius","ry","fill","stroke","borderLeftColor","stroke-width","borderLeftWidth","color","containerDiv","empty","containerDivNode","containerSvg","offsetLeft","clientLeft","offsetTop","clientTop","rect","entriesDivs","entryDivNode","entryDiv","entryDivKeyNode","getEntryDivSubNode","swatch","offsetWidth","offsetHeight","entryDivSeriesNode","textContent","getProportionedBounds","original","specified","exporter","startWork","boundsClone","performExport","svgNodeClone","destroySvgClone","setAttribute","win","aDownloads","savesMsBlobs","url","blob","revokeUrl","exporters","href","click","navigator","msSaveOrOpenBlob","location","doc","setTimeout","finishWork","img","fn","shift","checkEncodesBase64","checkADownloads","checkSavesMsBlobs","checkCreatesObjectUrls","checkExportsSvg","encodesBase64","setupBase64Shim","exportsSvg","querySelector","getAttribute","sourceImg","e","svgExportChecked","xml","encodeURIComponent","setupCanvgShim","chars","InvalidCharacterError","message","input","block","charCode","idx","output","charAt","done","scripts","remaining","script","head","version","helpers","isTimeData","TimeScale","LinearScale","OrdinalScale","axisType","LogYAxis","SmartYAxis","_domain","_getAxisDomain","_setRange","formatLabel","getDate","labelsFit","optMin","optMax","__super","ticksHint","isCategorized","ordinal","optFormat","axisGroup","pos","lineCenter","anchor","text-anchor","ref","toFixed","_range","band","numCats","threshold","rangeType","rangePoints","_extractYTickValues","adjustedDomain","perTreshold","rawMax","nextTick","time","getOptimalTickFormat","axisDomain","spanDays","daysThreshold","_getAxisRange","rangeRound","size","frame","categoryLabels","xLabel","yLabel","lineHeightAdjustment","titleOneEm","_extent","maxs","mins","_stackedExtent","dataSets","ext","_xExtent","partialRight","_yExtent","VisInstanceContainer","setOptions","normalizeData","_updateDomain","isSupportedFormat","xExtent","yExtent","stacked","area","areaBase","preprocess","classFn","startArea","y1","smooth","interpolate","renderSeries","renderTooltipTrackers","trackerSize","markers","blocks","bar","barClass","groupPadding","barWidth","barRender","rectClass","chartOffset","grouped","bars","cssClass","numSeries","column","columnClass","columnWidth","rectStyle","dataKey","filteredData","cols","col","base","delay","legend","vAlign","hAlign","validAlignmentClasses","classes","Legend","firstChild","count","legendHeight","mid","positioner","selection","legendWidth","entries","line","animationDirection","marker","animationDelay","animationsMap","left-to-right","path","totalLength","getTotalLength","ease","bottom-to-top","rawData","shouldAnimate","renderPaths","renderMarkers","seriesClassName","extras","startLine","animFn","startLineFn","partial","dots","class","r","cx","cy","pie","sliceClass","piePadding","innerRadius","outerRadius","normalizePadding","clampBounds","maxWidth","maxHeight","calcPadding","resolveValueUnits","resolvePaddingUnits","shouldCenterX","shouldCenterY","pixelPadding","referenceSize","totalPadding","proposedRadius","radius","pieData","totalWidth","outerPaddingLeft","centerY","baseClass","translatePie","posY","pieGroup","group","arc","startArc","startAngle","endAngle","_current","attrTween","arcTween","scatter","ScatterPlot","halfRangeBand","stackTooltip","valueFormatter","classed","onMouseOver","isNull","mapFn","seriesName","filtered","html","onMouseOut","on","animate","showTime","hideTime","distance","clearHideTimer","clearTimeout","hideTimer","changeOpacity","tooltipElement","positionTooltip","pointOrCentroid","event","mouse","parseFloat","pointX","pointY","alignedRight","clampPosition","verticalPositioner","horizontalPositioner","show","getTooltipText","allPoints","match","params","list","rest","response","first","formatters","dataPoints","findOriginalDataPoint","seriesIndex","normalizeDataSet","dataSet","pluck","isLinear","normalizer","regression","numericDomain","lineY","isNaN"],"mappings":";;CAAC,SAASA,QAASC,SCAnB,SAAWC,WAEP,GAAIC,MAAOC,IAEX,UAAWC,UAAW,UAAYA,cAAiBA,QAAOL,UAAY,SAAU,CAC5E,SAAUM,WAAY,WAAY,CAC9BH,KAAKI,GAAKD,QAAQ,KAClBH,MAAKK,EAAIF,QAAQ,WAIzB,IAAIC,GAAI,KAAM,IAAIE,OAAM,mEACxB,KAAID,IAAMA,EAAEE,MAAO,KAAM,IAAID,OAAM,+ECZvC;;;AAGI,GAAIE,YAAa,SAAUC,GAAK,GAAIC,KAAML,EAAEM,GAAGC,UAAUH,EAAI,OAAOC,OAAQ,EAAI,EAAIG,KAAKC,IAAI,GAAIJ,KACjG,IAAIK,eAAgB,SAAUC,EAAEC,GAAK,MAAOJ,MAAKK,IAAIV,WAAWQ,GAAIR,WAAWS,IAC/E,IAAIE,UAAW,SAAUH,EAAEC,GAAK,GAAIG,QAASL,cAAcC,EAAEC,GAAII,GAAKR,KAAKS,MAAMN,EAAII,QAASG,GAAKV,KAAKS,MAAML,EAAIG,OAAS,QAAQC,GAAKE,IAAMH,OAC9I,IAAII,UAAW,SAAUR,EAAEC,GAAK,GAAIG,QAASL,cAAcC,EAAEC,GAAII,GAAKR,KAAKS,MAAMN,EAAII,QAASG,GAAKV,KAAKS,MAAML,EAAIG,OAAS,QAAQC,GAAKE,IAAMH,OAC9I,IAAIK,UA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,KAAK,KAAMvW,EAAEqK,OAAO,KACpBkM,KAAK,KAAM5T,EAAEq4B,MAAMD,cAAc,KAEpClH,MAAKxV,OAAOC,QAEZ,IAAImW,cAAe,CACfZ,KAAOA,KAAK5W,aAAa7K,SAASA,UAGtCyhB,KAAKtd,KAAK,KAAMvW,EAAEqK,OAAO,KACtBkM,KAAK,KAAM5T,EAAEq4B,MAAMD,cAAc,MACjCxkB,KAAK,KAAMvW,EAAEqK,OAAO,KACpBkM,KAAK,KAAM5T,EAAEq4B,MAAMD,cAAc,OAI5C3mB,KAAKnC;;;;;;;;;;;;;;;;;;AAoBLiB,QAAQE,OAAO,YAAagB,S3BpEiB/U,QAAO,QAAUD,aAAgB,WAAW,MAAOI","file":"contour.min.js","sourcesContent":[null,"(function (undefined) {\n\n var root = this;\n\n if (typeof module === 'object' && module && typeof module.exports === 'object') {\n if(typeof require === 'function') {\n root.d3 = require('d3');\n root._ = require('lodash');\n }\n }\n\n if(!d3) throw new Error('You need to include d3.js before Contour. Go to http://d3js.org/');\n if(!_ || !_.merge) throw new Error('You need to include lodash.js before Contour. Go to http://lodash.com/');\n\n})();\n","(function () {\n // cheap trick to add decimals without hitting javascript issues\n // note that this fails for very large numbers\n var multiplier = function (x) { var dig = _.nw.decDigits(x); return dig === 0 ? 1 : Math.pow(10, dig); };\n var maxMultiplier = function (a,b) { return Math.max(multiplier(a), multiplier(b)); };\n var addFloat = function (a,b) { var factor = maxMultiplier(a,b), aa = Math.round(a * factor), bb = Math.round(b * factor); return (aa + bb) / factor; };\n var subFloat = function (a,b) { var factor = maxMultiplier(a,b), aa = Math.round(a * factor), bb = Math.round(b * factor); return (aa - bb) / factor; };\n var mulFloat = function (a,b) { var factor = maxMultiplier(a,b), aa = Math.round(a * factor), bb = Math.round(b * factor); return (aa * bb) / (factor*factor); };\n var divFloat = function (a,b) { var factor = maxMultiplier(a,b), aa = Math.round(a * factor), bb = Math.round(b * factor); return aa / bb; };\n\n var noop = function () {};\n\n var generalHelpers = {\n // the src is a function returns the function evaluated\n // otherwise returns src\n getValue: function (src, deafult, ctx, args) {\n args = Array.prototype.slice.call(arguments, 3);\n return !src ? deafult : typeof src === 'function' ? src.apply(ctx, args) : src;\n },\n\n seriesNameToClass: function (name) {\n return name || '';\n }\n };\n\n var dataFilters = {\n\n cleanNullValues: function () {\n return function (series) {\n return _.map(series, function (s) {\n return _.extend(s, {\n data: _.reduce(s.data, function (acum, datum) {\n if (datum.y != null) {\n acum.push(datum);\n }\n\n return acum;\n }, [])\n });\n });\n };\n },\n\n minMaxFilter: function (desiredLen) {\n return function(data) {\n if (data.length <= desiredLen)\n return data;\n\n var toReturn = [data[0]]; //always want the first\n var index = 1;\n var increment = Math.floor(data.length / desiredLen);\n\n while (index < data.length - 1) {\n var hasValidPt = false;\n var maxPt;\n var minPt;\n var maxIndex = Math.min(index + increment, data.length);\n\n for (var intermediateIndex = index; intermediateIndex < maxIndex; intermediateIndex++) {\n var intermediatePt = data[index];\n if (intermediatePt.y) {\n if (!hasValidPt || intermediatePt.y > maxPt.y)\n maxPt = intermediatePt;\n\n if (!hasValidPt || intermediatePt.y < minPt.y)\n minPt = intermediatePt;\n\n hasValidPt = true;\n }\n }\n\n if (hasValidPt) {\n if (minPt.x === maxPt.x) {\n toReturn.push(minPt);\n } else if (minPt.x < maxPt.x) {\n toReturn.push(minPt);\n toReturn.push(maxPt);\n } else if (minPt.x > maxPt.x) {\n toReturn.push(maxPt);\n toReturn.push(minPt);\n }\n }\n\n index += Math.max(1, Math.min(data.length - 1 - index, increment));\n }\n toReturn.push(data[data.length - 1]); //always want the last\n return toReturn;\n };\n }\n };\n\n var logging = {\n warn: function (msg) {\n if (console && console.log)\n console.log(msg);\n }\n };\n\n var numberHelpers = {\n firstAndLast: function (ar) {\n return [ar[0], ar[ar.length-1]];\n },\n\n roundToNearest: function (number, multiple) {\n return mulFloat(Math.ceil(divFloat(number, multiple)), multiple);\n },\n\n roundTo: function (value, digits) {\n return divFloat(Math.ceil(mulFloat(value, Math.pow(10, digits))), Math.pow(10, digits));\n },\n\n trunc: function (value) {\n return value - value % 1;\n },\n\n // only works for integers\n digits: function (value) {\n var str = Math.abs(value).toString();\n var parts = str.split('e');\n if (parts.length === 2) {\n return Math.max(0, parts[1]) + 1;\n }\n parts = str.split('.');\n return parts[0].length;\n },\n\n decDigits: function (value) {\n var str = Math.abs(value).toString();\n var parts = str.split('.');\n if (parts.length === 2) {\n return parts[1].length;\n }\n parts = str.split('e');\n if (parts.length === 2) {\n return -Math.min(0, parts[1]);\n }\n return 0;\n },\n\n log10: function (value) {\n return Math.log(value) / Math.LN10;\n },\n\n clamp: function (val, l, h) {\n return val > h ? h : val < l ? l : val;\n },\n\n clampLeft: function (val, low) {\n return val < low ? low : val;\n },\n\n clampRight: function (val, high) {\n return val > high ? high : val;\n },\n\n degToRad: function (deg) {\n return deg * Math.PI / 180;\n },\n\n radToDeg: function (rad) {\n return rad * 180 / Math.PI;\n },\n\n rotatePoint: function (point, rad) {\n return {\n x: point.x * Math.cos(rad) - point.y * Math.sin(rad),\n y: point.x * Math.sin(rad) + point.y * Math.cos(rad)\n };\n },\n\n translatePoint: function (point, delta) {\n return {\n x: point.x + delta.x,\n y: point.y + delta.y\n };\n },\n\n linearRegression: function (dataSrc) {\n var lr = {};\n var n = dataSrc.length;\n var sum_x = 0;\n var sum_y = 0;\n var sum_xy = 0;\n var sum_xx = 0;\n var sum_yy = 0;\n\n for (var i = 0; i < n; i++) {\n sum_x += dataSrc[i].x;\n sum_y += dataSrc[i].y;\n sum_xy += (dataSrc[i].x*dataSrc[i].y);\n sum_xx += (dataSrc[i].x*dataSrc[i].x);\n sum_yy += (dataSrc[i].y*dataSrc[i].y);\n }\n\n lr.slope = (n * sum_xy - sum_x * sum_y) / (n*sum_xx - sum_x * sum_x);\n lr.intercept = (sum_y - lr.slope * sum_x)/n;\n lr.r2 = Math.pow((n*sum_xy - sum_x*sum_y)/Math.sqrt((n*sum_xx-sum_x*sum_x)*(n*sum_yy-sum_y*sum_y)),2);\n\n return lr;\n },\n\n niceRound: function (val) {\n // for now just round(10% above the value)\n return Math.ceil(val + val * 0.10);\n\n // var digits = Math.floor(Math.log(val) / Math.LN10) + 1;\n // var fac = Math.pow(10, digits);\n\n // if(val < 1) return _.nw.roundToNearest(val, 1);\n\n // if(val < fac / 2) return _.nw.roundToNearest(val, fac / 2);\n\n // return _.nw.roundToNearest(val, fac);\n }\n };\n\n var axisHelpers = {\n addAxis: function (name, axisCtor) {\n _.nw.axes = _.nw.axes || {};\n _.nw.axes[name] = axisCtor;\n },\n\n roundToNextTick: function (num) {\n var abs = Math.abs(num);\n var sign = abs === num ? 1 : -1;\n var mag, step;\n if (abs >= 1) {\n mag = Math.floor(_.nw.log10(abs));\n step = mag <= 1 ? 2 : Math.pow(10, mag - 1);\n } else {\n\n var exp = abs.toExponential().replace(/\\.|e-\\d+$/g, '');\n mag = exp.length;\n step = mulFloat((mag === 1 ? 2 : 10), Math.pow(10, -mag));\n }\n\n var raw = _.nw.roundToNearest(abs, step);\n return sign * raw;\n },\n\n niceMinMax: function (min, max, ticks, startAtZero) {\n // return divFloat(Math.ceil(mulFloat(value, Math.pow(10, digits))), Math.pow(10, digits));\n\n // check for errors... min cannot be > max\n if (min > max) {\n return {\n min: min,\n max: min,\n tickValues: []\n };\n }\n\n var swap = max < 0 && min < 0;\n var origMax = max;\n if (swap) {\n max = -min;\n min = -origMax;\n }\n\n // 2 ticks seem to work for min max and passing 5 ticks to d3\n ticks = ticks == null ? 2 : Math.max(1, ticks);\n // if ticks is an array, use that as order of preferred ticks; otherwise return a\n // variable number of ticks in order to keep values round\n if (_.isNumber(ticks)) {\n // for 1, check [1]\n // for 2, check [2, 1]\n // for 3, check [3, 2]\n // for 4, check [4, 5, 3]\n // for 5, check [5, 6, 4, 3]\n // for 6, check [6, 7, 5, 4]\n // for 7, check [7, 8, 6, 5]\n // for 8, check [8, 9, 10, 7, 6]\n // for 9, check [9, 10, 11, 8, 7, 6]\n // for 10, check [10, 11, 12, 9, 8, 7]\n ticks = _.range(ticks, ticks * 1.28)\n .concat(_.range(ticks - 1, (ticks - 1) * 0.72, -1));\n }\n\n if (startAtZero == null) {\n startAtZero = min === 0 || origMax < 0;\n }\n\n var exponent;\n if (min === max) {\n if (max === 0) {\n exponent = -1.0;\n } else {\n exponent = numberHelpers.log10(Math.abs(max));\n }\n } else {\n if(startAtZero) {\n exponent = numberHelpers.log10(Math.abs(max)) - 0.5;\n } else {\n exponent = numberHelpers.log10(max-min) - 0.5;\n }\n }\n\n var defaultRounding = -(exponent >= 0 ? numberHelpers.trunc(exponent) : Math.floor(exponent));\n\n // var defaultRounding = -numberHelpers.trunc((min === max ?\n // max === 0 ? -1.0 : numberHelpers.log10(Math.abs(max)) :\n // startAtZero ? numberHelpers.log10(Math.abs(max)) : numberHelpers.log10(max-min)\n // ) - 0.5);\n\n var excelRoundUp = function (value, up) {\n up = up != null ? up : 0;\n var roundFn = function (v) { return v >= 0 ? Math.ceil(v) : Math.floor(v); };\n return divFloat(roundFn(value * Math.pow(10, up)), Math.pow(10, up));\n };\n\n var nice = function (ticks) {\n var negativeMinAmount = excelRoundUp(Math.max(0, -min) / ticks, defaultRounding - 1);\n\n var intermediateMax = min === max ? max === 0 ? 1 : excelRoundUp(max + negativeMinAmount, defaultRounding)\n : excelRoundUp(max + negativeMinAmount,defaultRounding);\n\n var iMin = 0;\n if (!startAtZero && min !== max) {\n var inter = min + negativeMinAmount;\n var dig = numberHelpers.digits(inter);\n var roundToDigits;\n if (inter > 0) {\n roundToDigits = -Math.floor(_.nw.log10(inter));\n } else {\n roundToDigits = (Math.max(1, Math.abs(dig-2)));\n }\n\n iMin = -numberHelpers.roundTo(-inter, roundToDigits);\n iMin = iMin === 0 ? 0 : iMin;\n // old version:\n // iMin = excelRound(min + negativeMinAmount, defaultRounding + (min < 0 ? 1 : 0))\n }\n\n var intermediateMin = iMin;\n\n var interval = excelRoundUp(divFloat(subFloat(intermediateMax, intermediateMin),ticks), defaultRounding);\n var finalMin = subFloat(intermediateMin, negativeMinAmount);\n var finalMax = addFloat(finalMin, mulFloat(ticks, interval));\n var ticksValues = [finalMin];\n var prevTick = finalMin;\n\n for (var j=1; j < ticks; j++) {\n var newTick = addFloat(prevTick, interval);\n\n ticksValues.push(newTick);\n prevTick = newTick;\n }\n\n // total ticks are going to be either ticks or ticks + 1\n if (Math.abs(prevTick - finalMax) > 1e-10) {\n ticksValues.push(finalMax);\n }\n\n return {\n min: swap ? -finalMax : finalMin,\n max: swap ? -finalMin : finalMax,\n tickValues: ticksValues.map(function (a) { return swap ? -a : a; })\n };\n };\n\n var defaultMinMax;\n var minMax;\n\n var foundSomethingRound = _.some(ticks, function (ticks) {\n minMax = nice(ticks);\n defaultMinMax = defaultMinMax || minMax;\n return _.every(minMax.tickValues, function (tick) {\n return tick === Math.round(tick);\n });\n });\n return foundSomethingRound ? minMax : defaultMinMax;\n },\n\n /*jshint eqnull:true */\n extractScaleDomain: function (domain, min, max, ticks, zeroAnchor) {\n var dataMin = min != null ? min : _.min(domain);\n var dataMax = max != null ? max : _.max(domain);\n ticks = ticks == null ? 5 : ticks;\n\n var niceMinMax = axisHelpers.niceMinMax(dataMin, dataMax, ticks, zeroAnchor);\n\n return [niceMinMax.min, niceMinMax.max];\n\n // // we want null || undefined for all this comparasons\n // // that == null gives us\n // if (min == null && max == null) {\n // return [niceMinMax.min, niceMinMax.max];\n // }\n\n // if (min == null) {\n // return [Math.min(niceMinMax.min, max), max];\n // }\n\n // if (max == null) {\n // return [min, Math.max(min, niceMinMax.max)];\n // }\n\n // return [min, max];\n },\n\n niceTicks: function (min, max, ticks, zeroAnchor) {\n ticks = ticks == null ? 5 : ticks;\n\n var niceMinMax = axisHelpers.niceMinMax(min, max, ticks, zeroAnchor);\n return niceMinMax.tickValues;\n },\n\n calcXLabelsWidths: function (ticks) {\n var padding = 8;\n return _.compact(ticks).map(String).map(function (d) {\n if (!d) {\n return padding * 2;\n }\n return _.nw.textBounds(d, '.x.axis text').width + (padding * 2);\n });\n },\n\n doXLabelsFit: function (ticks, labelFormatter, options) {\n var tickWidths = _.nw.calcXLabelsWidths(ticks.map(labelFormatter));\n var availableWidthForLabels = (options.chart.plotWidth + tickWidths[0] / 2 + tickWidths[ticks.length - 1] / 2);\n var axisLabelsWidth = _.nw.sum(tickWidths);\n return axisLabelsWidth <= availableWidthForLabels;\n },\n\n getTicksThatFit: function (ticks, labelFormatter, options) {\n // reduce the number of ticks incrementally by taking every 2nd, then every 3th, and so on\n // until we find a set of ticks that fits the available space\n function reduceTicksByMod() {\n var tickWidths = _.nw.calcXLabelsWidths(ticks.map(labelFormatter));\n var axisLabelsWidth = _.nw.sum(tickWidths);\n var availableWidthForLabels = (options.chart.plotWidth + tickWidths[0] / 2 + tickWidths[ticks.length - 1] / 2);\n var iter = 1;\n var filterMod = function (d, i) { return (i % iter) === 0; };\n var finalTicks = ticks;\n while(axisLabelsWidth > availableWidthForLabels && finalTicks.length !== 0) {\n iter++;\n finalTicks = _.filter(ticks, filterMod);\n axisLabelsWidth = _.nw.sum(_.nw.calcXLabelsWidths(finalTicks.map(labelFormatter)));\n }\n\n return finalTicks;\n }\n\n // possible alternative way using d3 ticks to calculate the number\n // that fits\n // function reduceTicksByD3() {\n // // while(axisLabelsWidth > availableWidthForLabels && ticks.length !== 1) {\n // // ticks = axis.scale().ticks(Math.floor(--numAutoTicks));\n // // axisLabelsWidth = sum(calcLabelsWidths(ticks.map(formatLabel)));\n // // }\n\n // // axis.ticks(ticks.length);\n // }\n\n return reduceTicksByMod();\n }\n };\n\n\n var stringHelpers = {\n // measure text inside a Contour chart container\n textBounds: function (text, css) {\n var body = document.getElementsByTagName('body')[0];\n var wrapper = document.createElement('span');\n var dummy = document.createElement('span');\n wrapper.className = 'contour-chart';\n dummy.style.position = 'absolute';\n dummy.style.width = 'auto';\n dummy.style.height = 'auto';\n dummy.style.visibility = 'hidden';\n dummy.style.lineHeight = '100%';\n dummy.style.whiteSpace = 'nowrap';\n\n dummy.innerHTML = text;\n dummy.className = css.replace(/\\./g, ' ');\n wrapper.appendChild(dummy);\n body.appendChild(wrapper);\n var res = { width: dummy.clientWidth, height: dummy.clientHeight };\n wrapper.removeChild(dummy);\n body.removeChild(wrapper);\n return res;\n }\n };\n\n var dateHelpers = {\n dateDiff: function(d1, d2) {\n var diff = d1.getTime() - d2.getTime();\n return diff / (24*60*60*1000);\n }\n };\n\n var arrayHelpers = {\n // concatenate and sort two arrays to the resulting array\n // is sorted ie. merge [2,4,6] and [1,3,5] = [1,2,3,4,5,6]\n merge: function (array1, array2) {\n if(typeof(array1) === 'number') array1 = [array1];\n if(typeof(array2) === 'number') array2 = [array2];\n if(!array1 || !array1.length) return array2;\n if(!array2 || !array2.length) return array1;\n\n return [].concat(array1, array2).sort(function (a,b) { return a-b; });\n },\n\n isCorrectDataFormat: function (dataArray) {\n return _.isArray(dataArray) && _.every(dataArray, function (p) { return p.hasOwnProperty('x') && p.hasOwnProperty('y'); });\n },\n\n isCorrectSeriesFormat: function (data) {\n var isArrayOfObjects = _.isArray(data) && _.isObject(data[0]);\n var hasDataArrayPerSeries = _.every(data, function (d) { return d.hasOwnProperty('data'); });\n var hasSeriesNamePerSeries = _.every(data, function (d) { return d.hasOwnProperty('name'); });\n var datumInCorrectFormat = isArrayOfObjects && hasDataArrayPerSeries && arrayHelpers.isCorrectDataFormat(data[0].data);\n\n return isArrayOfObjects && hasDataArrayPerSeries && hasSeriesNamePerSeries && datumInCorrectFormat;\n },\n\n /*jshint eqnull:true */\n // we are using != null to get null & undefined but not 0\n normalizeSeries: function (data, categories) {\n var hasCategories = !!(categories && _.isArray(categories));\n function sortFn(a, b) { return a.x - b.x; }\n function normal(set, name) {\n var d = {\n name: name,\n data: _.map(set, function (d, i) {\n var hasX = d != null && d.hasOwnProperty('x');\n var val = function (v) { return v != null ? v : null; };\n // make sure we return a valid category and not cast nulls as string\n var categoryAt = function (i) { return !hasCategories ? i : categories[i] == null ? null : categories[i] + ''; };\n return hasX ? _.extend(d, { x: d.x, y: val(d.y) }) : { x: categoryAt(i), y: val(d) };\n })\n };\n\n if (!hasCategories) {\n d.data.sort(sortFn);\n }\n\n return d;\n }\n\n var correctDataFormat = arrayHelpers.isCorrectDataFormat(data);\n var correctSeriesFormat = arrayHelpers.isCorrectSeriesFormat(data);\n\n // do not make a new copy, if the data is already in the correct format!\n if (correctSeriesFormat) {\n return data;\n }\n\n // do the next best thing if the data is a set of points in the correct format\n if (correctDataFormat) {\n if (!hasCategories) data.sort(sortFn);\n return [{ name: 'series 1', data: data }];\n }\n\n // for the rest of the cases we need to normalize to the full format of the series\n if (_.isArray(data)) {\n if ((_.isObject(data[0]) && data[0].hasOwnProperty('data')) || _.isArray(data[0])) {\n // this would be the shape for multiple series\n return _.map(data, function (d, i) { return normal(d.data ? d.data : d, d.name ? d.name : 'series ' + (i+1)); });\n } else {\n // this is just the shape [1,2,3,4] or [{x:0, y:1}, { x: 1, y:2}...]\n return [normal(data, 'series 1')];\n }\n }\n\n // nothing to do to the data if it's not in a supported format\n return data;\n },\n\n // returns a function to format the data into a 'stacked' d3 layout\n // passing in a series data will add a y0 to each data point\n // where the point should start relative to the reset of the series points\n // at that x value\n stackLayout: function () {\n var stack = d3.layout\n .stack()\n .values(function (d) { return d.data; });\n // prepare satck to handle different x values with different lengths\n var outFn = function() {\n var y0s = {};\n return function (d, y0, y) {\n d.y0 = y0s[d.x] != null ? y0s[d.x] : 0;\n d.y = y;\n y0s[d.x] = (y0s[d.x] || 0) + y;\n };\n };\n\n stack.out(outFn());\n\n return stack;\n },\n\n // return the uniq elements in the array\n // we are implementing our own version since this algorithm seems\n // to be a lot faster than what lodash uses\n uniq: function (array) {\n var cache = {}, result = [];\n var len = array.length;\n\n for (var j=0; j= len) return domain.slice();\n\n // return d3.scale.linear().domain(domain).ticks(max);\n\n var tickInteval = Math.ceil((len) / (max));\n var cur = 0;\n while (cur < len) {\n values.push(domain[cur]);\n cur += tickInteval;\n }\n\n return values;\n },\n\n isSupportedDataFormat: function (data) {\n // this covers all supported formats so far:\n // [ {data: [...] }, ... ]\n // [ [...], [...] ]\n return _.isArray(data) &&\n (_.isObject(data[0]) && data[0].hasOwnProperty('data') && _.isArray(data[0].data)) ||\n _.isArray(data[0]);\n }\n\n };\n\n var domHelpers = {\n selectDom: function (selector) {\n return d3.select(selector)[0][0];\n },\n\n getStyle: function (el, style) {\n if(!el) return undefined;\n var elem = typeof el === 'string' ? this.selectDom(el) : el;\n // we need a good way to check if the element is detached or not\n var styles = elem.offsetParent ? elem.ownerDocument.defaultView.getComputedStyle(elem, null) : elem.style;\n\n return style ? styles[style] : styles;\n },\n\n getCentroid: function (element) {\n var getOffsetParent = function () {\n if (element.offsetParent) {\n return element.offsetParent;\n }\n\n // we we don't have an offsetParent, we may be in firefox\n // let's just assume that the offset parent is the svg element\n var t = element;\n while(t && t.tagName !== 'svg') {\n t = t.parentNode;\n }\n\n return t;\n };\n\n var parentBox = getOffsetParent().getBoundingClientRect();\n var bbox = element.getBoundingClientRect();\n\n return [bbox.left - parentBox.left + bbox.width/2, bbox.top - parentBox.top + bbox.height/2];\n }\n };\n\n var debuggingHelpers = {\n warning: function (msg) {\n if(console && console.log) {\n console.log('WARNING: ' + msg);\n }\n }\n };\n\n _.nw = _.extend({}, _.nw, numberHelpers, arrayHelpers, stringHelpers, dateHelpers,\n axisHelpers, debuggingHelpers, domHelpers, generalHelpers, logging, dataFilters);\n\n if (!_.noop) {\n _.noop = noop;\n }\n\n})();\n","(function () {\n\n var root = this;\n\n var defaults = {\n\n chart: {\n animations: {\n enable: true,\n // duration of the animation in ms\n duration: 400,\n },\n // by default take the size of the parent container\n defaultWidth: 400,\n // height = width * ratio\n defaultAspect: 1 / 1.61803398875,\n // calculated at render time based on the options & container\n width: undefined,\n // if defined, height takes precedence over aspect\n height: undefined,\n // margin between the container and the chart (ie labels or axis title)\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n // padding between the chart area and the inner plot area */\n padding: {\n top: null,\n right: null,\n bottom: null,\n left: null\n },\n internalPadding: {\n bottom: 0,\n left: 0\n },\n // automatically false by default anyway; adding here to help generate docs\n rotatedFrame: false,\n // width in pixels of the plot area (area inside the axis if any). This gets calculated on render\n plotWidth: undefined,\n // height in pixels of the plot area (area inside the axis if any). This gets calculated on render\n plotHeight: undefined,\n // top edge in pixels (from the edge of the svg) of the plot area (area inside the axis if any). This gets calculated on render\n plotTop: undefined,\n // left edge in pixels (from the edge of the svg) of the plot area (area inside the axis if any). This gets calculated on render\n plotLeft: undefined,\n },\n\n xAxis: {\n },\n\n yAxis: {\n },\n\n tooltip: {\n }\n };\n\n /**\n * Creates a Contour instance, based on the core Contour visualizations object. This instance can contain a set of related visualizations.\n *\n * * Pass the constructor any configuration options in the *options* parameter. Make sure the `el` option contains the selector of the container in which the Contour instance will be rendered.\n * * Set the frame for this Contour instance (e.g. `.cartesian()`).\n * * Add one or more specific visualizations to this Contour instance (e.g. `.scatter()`, `.trend-line()`). Pass each visualization constructor the data it displays. Pass configuration options if desired.\n * * Invoke an action for this Contour instance (e.g. `.render()`).\n *\n * ### Example:\n *\n * new Contour({el: 'myChart'})\n * .cartesian()\n * .line([1,3,2,5])\n * .render()\n *\n *\n * @class Contour()\n * @param {object} options The global configuration options object\n *\n */\n function Contour (options) {\n this.init(options);\n\n return this;\n }\n\n /**\n * Adds a new kind of visualization to the core Contour object.\n * The *renderer* function is called when you add this visualization to instances of Contour.\n * See a sample in the [Contour Gallery](http://forio.com/contour/gallery.html#/chart/pie/pie-gauge).\n *\n * ### Example:\n *\n * Contour.export(\"exampleVisualization\", function(data, layer) {\n * //function body to create exampleVisualization\n * //for example using SVG and/or D3\n * });\n *\n * //to include the visualization into a specific Contour instance\n * new Contour(options)\n * .exampleVisualization(data)\n * .render()\n *\n * @param {String} ctorName Name of the visualization, used as a constructor name.\n * @param {Function} renderer Function called when this visualization is added to a Contour instance. This function receives the data that is passed in to the constructor.\n */\n Contour.export = function (ctorName, renderer) {\n\n if (typeof renderer !== 'function') throw new Error('Invalid render function for ' + ctorName + ' visualization');\n\n function sortSeries(data) {\n if(!data || !data.length) return [];\n\n if(data[0].data) {\n _.each(data, sortSeries);\n }\n\n var shouldSort = _.isObject(data[0]) && _.isDate(data[0].x);\n var sortFunc = function (a, b) { return a.x - b.x; };\n if(shouldSort) {\n data.sort(sortFunc);\n }\n\n return data;\n }\n\n Contour.prototype[ctorName] = function (data, options) {\n var categories = this.options ? this.options.xAxis ? this.options.xAxis.categories : undefined : undefined;\n var opt = _.extend({}, this.options[ctorName], options);\n var vis;\n var ownData = true;\n\n if (!data) {\n data = this.lastData || [];\n ownData = false;\n }\n\n sortSeries(data);\n vis = new Contour.VisualizationContainer(data, categories, opt, ctorName, renderer, this);\n vis.ownData = ownData;\n this._visualizations.push(vis);\n\n // lastData is used to pass the last specified dataset\n // to the next visualiaztion in the chain wihtout\n // the need to specify it again.... this allows you to do\n // new Contour().cartesian().line(dataset).lengend().tooltip().render()\n // and legend and tooltip will recieve dataset\n this.lastData = data;\n\n return this;\n };\n\n /* expose the renderer function so it can be reused\n * by other visualizations though the constructor function\n * ie. Contour.export('customLineChart', function (data, layer, options) {\n * // call the line chart directly\n * return this.line.renderer(data, layer, options);\n * });\n */\n Contour.prototype[ctorName].renderer = renderer;\n };\n\n\n /**\n * Exposes functionality to the core Contour object.\n * Use this to add *functionality* that will be available for any visualizations.\n *\n * ###Example:\n *\n * Contour.expose('example', function ctor(params) {\n * // params are the parameters passed into the constructor function\n * return {\n * // the init function, if provided, is called automatically upon instantiation of the functionality\n * // the options parameter has the global Contour options object\n * init: function (options) { ... },\n *\n * // when included in the instance, the function `.myFunction` is available in the visualizations\n * myFunction: function(data) { .... }\n * };\n * });\n *\n * Contour.export('visualizationThatUsesMyFunction', function(data, layer) {\n * //function body including call to this.myFunction(data)\n * });\n *\n * // to include the functionality into a specific instance\n * new Contour(options)\n * .example({ text: 'someText' })\n * .visualizationThatUsesMyFunction()\n * .render()\n *\n\n */\n Contour.expose = function (ctorName, functionalityConstructor) {\n var ctor = function () {\n var functionality = functionalityConstructor;\n if (typeof functionalityConstructor === 'function') {\n functionality = Object.create(functionalityConstructor);\n functionality = functionalityConstructor.apply(functionality, arguments);\n }\n\n // extend the --instance-- we don't want all charts to be overriden...\n _.extend(this, _.omit(functionality, 'init'));\n\n if(functionality.init) {\n functionality.init.call(this, this.options);\n }\n\n // keep a list of the included functionality into this instance\n // so we can match and check dependencies\n this._exposed.push(ctorName);\n\n return this;\n };\n\n Contour.prototype[ctorName] = ctor;\n\n return this;\n };\n\n Contour.prototype = _.extend(Contour.prototype, {\n _visualizations: undefined,\n\n _extraOptions: undefined,\n\n _exposed: undefined,\n\n // Initializes the instance of Contour\n init: function (options) {\n // for now, just store this options here...\n // the final set of options will be composed before rendering\n // after all components/visualizations have been added\n this.options = options || {};\n\n this._extraOptions = [];\n this._visualizations = [];\n this._exposed = [];\n\n return this;\n },\n\n calculateWidth: function () {\n\n // assume all in pixel units and border-box box-sizing\n var outerWidth = parseInt(_.nw.getStyle(this.options.el, 'width') || 0, 10);\n var paddingLeft = parseInt(_.nw.getStyle(this.options.el, 'padding-left') || 0, 10);\n var paddingRight = parseInt(_.nw.getStyle(this.options.el, 'padding-right') || 0, 10);\n\n var width = outerWidth - paddingRight - paddingLeft;\n\n return this.options.el ? (width || this.options.chart.defaultWidth) : this.options.chart.defaultWidth;\n },\n\n calculateHeight: function () {\n // assume all in pixel units and border-box box-sizing\n var outerHeight = parseInt(_.nw.getStyle(this.options.el, 'height') || 0, 10);\n var paddingTop = parseInt(_.nw.getStyle(this.options.el, 'padding-top') || 0, 10);\n var paddingBottom = parseInt(_.nw.getStyle(this.options.el, 'padding-bottom') || 0, 10);\n var height = outerHeight - paddingTop - paddingBottom;\n\n var containerHeight = this.options.el ? height : undefined;\n var calcWidth = this.options.chart.width;\n var ratio = this.options.chart.aspect || this.options.chart.defaultAspect;\n\n return !!containerHeight && containerHeight > 1 ? containerHeight : Math.round(calcWidth * ratio);\n },\n\n calcMetrics: function () {\n var options = this.options;\n\n this.adjustPadding();\n\n this.adjustTitlePadding();\n\n options.chart.width = options.chart.width || this.calculateWidth();\n options.chart.height = options.chart.height || this.calculateHeight();\n\n this.options = _.merge(options, {\n chart: {\n plotWidth: options.chart.width - options.chart.margin.left - options.chart.margin.right - options.chart.internalPadding.left - options.chart.padding.right,\n plotHeight: options.chart.height - options.chart.margin.top - options.chart.margin.bottom - options.chart.padding.top - options.chart.internalPadding.bottom,\n plotLeft: options.chart.margin.left + options.chart.internalPadding.left,\n plotTop: options.chart.margin.top + options.chart.padding.top\n }\n });\n\n if (this.options.chart.plotWidth <= 0 || this.options.chart.plotHeight <= 0) {\n console.warn('The chart has no space to render. Either the width/height is zero or you have too much padding\\nWidth: ' + options.chart.width +\n '\\nHeight: ' + options.chart.height +\n '\\npadding-left: ' + options.chart.padding.left +\n '\\npadding-right: ' + options.chart.padding.right +\n '\\npadding-top: ' + options.chart.padding.top +\n '\\npadding-bottom: ' + options.chart.padding.bottom);\n\n this.options.chart.plotWidth = this.options.chart.plotWidth < 0 ? 0 : this.options.chart.plotWidth;\n this.options.chart.plotHeight = this.options.chart.plotHeight < 0 ? 0 : this.options.chart.plotHeight;\n }\n },\n\n adjustPadding: function () {\n // overriden by components that need to adjust padding\n return this;\n },\n\n adjustTitlePadding: function () {\n // overriden by components that need to adjust padding\n return this;\n },\n\n composeOptions: function () {\n var allDefaults = _.merge({}, defaults);\n var mergeExtraOptions = function (opt) { _.merge(allDefaults, opt); };\n var mergeDefaults = function (vis) { _.merge(allDefaults, vis.renderer.defaults); };\n\n _.each(this._extraOptions, mergeExtraOptions);\n _.each(this._visualizations, mergeDefaults);\n\n // compose the final list of options right before start rendering\n this.options = _.merge(this.options, _.merge({}, allDefaults, this.options));\n },\n\n baseRender: function () {\n this.plotArea();\n\n return this;\n },\n\n /**\n * Renders this Contour instance and all its visualizations into the DOM.\n *\n * ### Example:\n *\n * new Contour({ el:'.myChart' })\n * .pie([1,2,3])\n * .render();\n *\n * @function render\n *\n */\n render: function () {\n this.composeOptions();\n\n this.calcMetrics();\n\n this.baseRender();\n\n this.renderVisualizations();\n\n return this;\n },\n\n /**\n * Clears this Contour instance and all its visualizations of any size information, so that on the next call to `render()` the instance is re-measured.\n *\n * The function takes two optional arguments `width` and `height`. If given a specific width/height the chart uses that sizing information on the next render.\n *\n * ### Example:\n *\n * var contour = new Contour({ el:'.myChart' })\n * .pie([1,2,3])\n * .render();\n *\n * var onResize = function(e) {\n * contour.resize().render();\n * }\n *\n * window.addEventListener('resize', onResize);\n *\n * @function resize\n * @param {Number} width (optional) The new width for the visualizations. If left blank, the width will be calcuated from options.el's parent.\n * @param {Number} height (optional) The new height for the visualizations. If left blank, the height will be calcuated from options.el's parent.\n */\n resize: function(width, height) {\n\n if (this.container)\n this.container.style('height', 0);\n\n delete this.options.chart.width;\n delete this.options.chart.height;\n delete this.options.chart.plotWidth;\n delete this.options.chart.plotHeight;\n delete this.options.chart.plotLeft;\n delete this.options.chart.plotTop;\n\n if (width)\n this.options.chart.width = width;\n\n if (height)\n this.options.chart.height = height;\n return this;\n },\n\n update: function () {\n this.calcMetrics();\n return this;\n },\n\n plotArea: function () {\n\n var chartOpt = this.options.chart;\n\n this.container = d3.select(this.options.el);\n // fix a flicker im web-kit when animating opacity and the chart is in an iframe\n this.container.attr('style', '-webkit-backface-visibility: hidden; position: relative');\n\n if(!this.svg) {\n this.svg = this.container\n .append('svg')\n .attr('viewBox', '0 0 ' + chartOpt.width + ' ' + chartOpt.height)\n .attr('preserveAspectRatio', 'xMinYMin')\n .attr('class', 'contour-chart')\n .attr('height', chartOpt.height)\n .append('g')\n .attr('transform', 'translate(' + chartOpt.margin.left + ',' + chartOpt.margin.top + ')');\n } else {\n this.svg\n .attr('transform', 'translate(' + chartOpt.margin.left + ',' + chartOpt.margin.top + ')');\n\n d3.select(this.svg.node().parentNode)\n .attr('viewBox', '0 0 ' + chartOpt.width + ' ' + chartOpt.height)\n .attr('height', chartOpt.height);\n }\n\n return this;\n },\n\n createVisualizationLayer: function (vis, id) {\n return this.svg.append('g')\n .attr('vis-id', id)\n .attr('vis-type', vis.type);\n },\n\n renderVisualizations: function () {\n\n _.each(this._visualizations, function (visualization, index) {\n var id = index + 1;\n var layer = visualization.layer || this.createVisualizationLayer(visualization, id);\n var opt = _.merge({}, this.options, visualization.options);\n\n layer.attr('transform', 'translate(' + this.options.chart.internalPadding.left + ',' + (this.options.chart.padding.top || 0) + ')');\n\n visualization.layer = layer;\n visualization.parent = this;\n visualization.render(layer, opt, this);\n }.bind(this));\n\n return this;\n },\n\n /**\n * Assert that all the dependencies are in the Contour instance.\n * For example, if a visualization requires Cartesian to be included in the instance,\n * it could call this.checkDependencies('Cartesian'), and the framework would\n * give a helpful error message if Cartesian was not included.\n *\n * @function checkDependencies\n * @param {string|array} list of dependencies (as specified in the instance constructor)\n *\n */\n checkDependencies: function (listOfDependencies) {\n listOfDependencies = _.isArray(listOfDependencies) ? listOfDependencies : [listOfDependencies];\n var _this = this;\n var missing = [];\n\n _.each(listOfDependencies, function (dep) {\n if (_this._exposed.indexOf(dep) === -1) {\n missing.push(dep);\n }\n });\n\n if (missing.length) {\n throw new Error('ERROR: Missing depeendencies in the Contour instance (ej. new Contour({}).cartesian())\\n The missing dependencies are: [' + missing.join(', ') + ']\\nGo to http://forio.com/contour/documentation.html#key_concepts for more information');\n }\n },\n\n ensureDefaults: function (options, renderer) {\n if (_.isString(renderer)) {\n renderer = this[renderer].renderer;\n }\n\n if (renderer.defaults) {\n var defaults = renderer.defaults;\n options = _.defaults(options || {}, defaults);\n this.options = _.defaults(this.options, defaults);\n }\n },\n\n /**\n * Sets the same data into all visualizations for a Contour instance. Useful for creating interactive\n * visualizations: call after getting the additional data from the user.\n *\n * ###Example:\n *\n * var data = [1,2,3,4,5];\n * var chart = new Contour({ el:'.myChart' })\n * .cartesian()\n * .scatter(data)\n * .trendLine(data);\n *\n * data.push(10);\n * chart.setData(data)\n * .render();\n *\n * @function setData\n *\n */\n setData: function (data) {\n _.invokeMap(this._visualizations, 'setData', data);\n\n return this;\n },\n\n /**\n * Returns a VisualizationContainer object for the visualization at a given index (0-based).\n *\n * ###Example:\n *\n * var chart = new Contour({ el:'.myChart' })\n * .pie([1,2,3])\n * .render();\n *\n * var myPie = chart.select(0);\n *\n * // do something with the visualization, for example updating its data set\n * myPie.setData([6,7,8,9]).render();\n *\n * @function select\n *\n */\n select: function (index) {\n return this._visualizations[index];\n },\n\n // place holder function for now\n data: function () {\n\n },\n\n dataNormalizer: _.nw.normalizeSeries,\n\n isSupportedDataFormat: _.nw.isSupportedDataFormat\n });\n\n // exports for commonJS and requireJS styles\n if (typeof module === 'object' && module && typeof module.exports === 'object') {\n module.exports = Contour;\n } else {\n root.Contour = Contour;\n if (typeof define === 'function' && define.amd) {\n define('contour', [], function () { return Contour; });\n }\n }\n\n})();\n","(function () {\n\n var YAxis = function (data, options, domain) {\n this.data = data;\n this.options = options;\n this.domain = domain;\n };\n\n function setRange(scale, options) {\n var rangeSize = options.chart.rotatedFrame ? options.chart.plotWidth : options.chart.plotHeight;\n var range = options.chart.rotatedFrame ? [0, rangeSize] : [rangeSize, 0];\n return scale.range(range);\n }\n\n YAxis.prototype = {\n axis: function () {\n /*jshint eqnull:true */\n var options = this.options.yAxis;\n var domain = this.domain;\n var dMin = options.min != null ? options.min : options.zeroAnchor ? Math.min(0, domain[0]) : domain[0];\n var dMax = options.max != null ? options.max : domain[1];\n var tickValues = options.tickValues || _.nw.niceTicks(dMin, dMax, options.ticks);\n var numTicks = this.numTicks(domain, options.min, options.max);\n var format = options.labels.formatter || d3.format(options.labels.format);\n\n return d3.svg.axis()\n .scale(this._scale)\n .tickFormat(format)\n .tickSize(options.innerTickSize, options.outerTickSize)\n .tickPadding(options.tickPadding)\n .ticks(numTicks)\n .tickValues(tickValues);\n },\n\n scale: function (domain) {\n if(!this._scale) {\n this._scale = d3.scale.linear();\n this.setDomain(domain);\n }\n\n setRange(this._scale, this.options);\n return this._scale;\n },\n\n setDomain: function (domain) {\n this._scale.domain(domain);\n this._niceTheScale();\n return this._scale;\n },\n\n update: function (domain, dataSrc) {\n this.data = dataSrc;\n this.setDomain(domain);\n this.scale();\n },\n\n /*jshint eqnull:true*/\n numTicks: function () {\n return this.options.yAxis.ticks != null ? this.options.yAxis.ticks : undefined;\n },\n\n _niceTheScale: function () {\n // nothing to do for the regular y-axis\n }\n };\n\n _.nw.addAxis('YAxis', YAxis);\n\n})();\n","(function () {\n /*jshint eqnull:true */\n var defaults = {\n chart: {\n gridlines: 'none',\n padding: {\n top: 6,\n right: 5,\n // this get's defined based on the axis & title\n bottom: undefined,\n // this get's defined based on the axis & title\n left: undefined\n }\n },\n\n xAxis: {\n // type of axis {ordinal|linear|time}\n type: null, // default is linear in line.js (needs to be null here so overrides work)\n categories: undefined,\n max: undefined,\n min: undefined,\n innerTickSize: 6,\n outerTickSize: 0,\n tickPadding: 6,\n maxTicks: undefined,\n ticks: undefined,\n tickValues: undefined,\n title: undefined,\n titlePadding: 4,\n // padding between ranges (ie. columns) expressed in percentage of rangeBand width\n innerRangePadding: 0.1,\n // padding between all ranges (ie. columns) and the axis (left & right) expressed in percentage of rangeBand width\n outerRangePadding: 0.1,\n firstAndLast: false,\n orient: 'bottom',\n labels: {\n format: undefined,\n formatter: undefined\n },\n linearDomain: false, // specify if a time domain should be treated linearly or ....\n },\n\n yAxis: {\n // @param: {linear|smart|log}\n // type: 'smart',\n min: undefined,\n max: undefined,\n zeroAnchor: true,\n smartAxis: false,\n innerTickSize: 6,\n outerTickSize: 6,\n tickPadding: 4,\n tickValues: undefined,\n ticks: undefined,\n title: undefined,\n titlePadding: 4,\n orient: 'left',\n labels: {\n // top, middle, bottom\n verticalAlign: 'middle',\n format: 's', // d3 formats\n formatter: undefined // a function that formats each value ie. function (datum) { return 'x: ' + datum.x + ', y:' + datum.y }\n }\n }\n };\n\n\n /**\n * Provides a Cartesian frame to the Contour instance.\n *\n * This is required for all visualizations displayed in a Cartesian frame, for example line charts, bar charts, area charts, etc. It is not required otherwise; for instance, pie charts do not use a Cartesian frame.\n *\n * ###Example:\n *\n * new Contour(options)\n * .cartesian();\n *\n * @name cartesian\n */\n var cartesian = function () {\n var maxTickSize = function (options) { return Math.max(options.outerTickSize || 0, options.innerTickSize || 0); };\n return {\n dataSrc: [],\n\n init: function (options) {\n\n // readonly properties (ie. user cannot modify)\n var readOnlyProps = {\n chart: {\n rotatedFrame: false,\n internalPadding: {\n bottom: undefined,\n left: undefined\n }\n }\n };\n\n this.options = options || {};\n\n _.merge(this.options, readOnlyProps);\n\n var extraPadding = {};\n if (!this.options.xAxis || !this.options.xAxis.firstAndLast) {\n extraPadding = { chart : { padding: { right: 15 }}};\n }\n\n this._extraOptions.push(_.merge({}, defaults, extraPadding));\n\n return this;\n },\n\n xDomain: [],\n yDomain: [],\n\n _getYScaledDomain: function (domain, options) {\n var opts = this.options.yAxis;\n var absMin = opts.zeroAnchor && domain && domain[0] > 0 ? 0 : undefined;\n var min = opts.min != null ? opts.min : absMin;\n\n if (opts.tickValues) {\n if (opts.min != null && opts.max != null) {\n return [opts.min, opts.max];\n } else if (opts.min != null) {\n return [opts.min, d3.max(opts.zeroAnchor ? [0].concat(opts.tickValues) : opts.tickValues)];\n } else if (opts.max != null) {\n return [d3.min(opts.zeroAnchor ? [0].concat(opts.tickValues) : opts.tickValues), opts.max];\n } else {\n return d3.extent(opts.zeroAnchor || opts.min != null ? [min].concat(opts.tickValues) : opts.tickValues);\n }\n } else if (opts.smartAxis) {\n return d3.extent(opts.zeroAnchor || opts.min != null ? [min].concat(domain) : domain);\n }\n\n return _.nw.extractScaleDomain(domain, min, opts.max, opts.ticks);\n },\n\n /*jshint eqnull:true */\n adjustPadding: function () {\n var xOptions = this.options.xAxis;\n var yOptions = this.options.yAxis;\n // bottom padding calculations\n if (this.options.chart.padding.bottom == null) {\n this.options.chart.internalPadding.bottom = this._getAdjustedBottomPadding(xOptions);\n } else {\n this.options.chart.internalPadding.bottom = this.options.chart.padding.bottom || 0;\n }\n\n this.options.chart.padding.top = this.options.chart.internalPadding.top = this._getAdjustedTopPadding(xOptions);\n\n // left padding calculations\n if (this.options.chart.padding.left == null) {\n this.options.chart.internalPadding.left = this._getAdjustedLeftPadding(yOptions);\n } else {\n this.options.chart.internalPadding.left = this.options.chart.padding.left;\n }\n\n this.options.chart.padding.right = this.options.chart.internalPadding.right = this._getAdjustedRightPadding(yOptions);\n },\n\n _getAdjustedTopPadding: function (options) {\n return this.options.chart.padding.top;\n },\n\n _getAdjustedBottomPadding: function (options) {\n if (options.ticks !== 0) {\n var xLabels = this.xDomain;\n var xAxisText = xLabels.join('
');\n var xLabelBounds = _.nw.textBounds(xAxisText, '.x.axis');\n var regularXBounds = _.nw.textBounds('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890', '.x.axis');\n var em = regularXBounds.height;\n var ang = options.labels && options.labels.rotation ? options.labels.rotation % 360 : 0;\n var xLabelHeightUsed = ang === 0 ? regularXBounds.height : Math.ceil(Math.abs(xLabelBounds.width * Math.sin(_.nw.degToRad(ang))) + em / 5) ;\n return maxTickSize(options) + (options.tickPadding || 0) +\n xLabelHeightUsed;\n } else {\n return maxTickSize(options) + (options.tickPadding || 0);\n }\n },\n\n _getAdjustedLeftPadding: function (options) {\n var yDomainScaled = this._getYScaledDomain(this.yDomain, this.options);\n var tmpScale = d3.scale.linear().domain(yDomainScaled);\n var yLabels = tmpScale.ticks(options.ticks);\n\n var format = options.labels.formatter || d3.format(options.labels.format || ',.0f');\n var yAxisText = _.map(yLabels, format).join('
');\n var yLabelBounds = _.nw.textBounds(yAxisText, '.y.axis');\n return maxTickSize(this.options.yAxis) + (this.options.yAxis.tickPadding || 0) +\n yLabelBounds.width;\n },\n\n _getAdjustedRightPadding: function (options) {\n return this.options.chart.padding.right;\n },\n\n adjustTitlePadding: function () {\n var titleBounds;\n if (this.options.xAxis.title || this.options.yAxis.title) {\n if(this.options.xAxis.title) {\n titleBounds = _.nw.textBounds(this.options.xAxis.title, '.x.axis-title');\n this.options.chart.internalPadding.bottom += titleBounds.height + this.options.xAxis.titlePadding;\n }\n\n if(this.options.yAxis.title) {\n titleBounds = _.nw.textBounds(this.options.yAxis.title, '.y.axis-title');\n this.options.chart.internalPadding.left += titleBounds.height + this.options.yAxis.titlePadding;\n }\n }\n },\n\n computeXScale: function () {\n if (!this.xDomain) throw new Error('You are trying to render without setting data (xDomain).');\n\n if(!this.xScale) {\n this.xScaleGenerator = _.nw.xScaleFactory(this.dataSrc, this.options);\n this.xScale = this.xScaleGenerator.scale(this.xDomain);\n this.rangeBand = this.xScaleGenerator.rangeBand();\n } else {\n this.xScaleGenerator.update(this.xDomain, this.dataSrc);\n this.rangeBand = this.xScaleGenerator.rangeBand();\n }\n },\n\n computeYScale: function () {\n if (!this.yDomain) throw new Error('You are trying to render without setting data (yDomain).');\n\n var yScaleDomain = this._getYScaledDomain(this.yDomain, this.options);\n\n if(!this.yScale) {\n this.yScaleGenerator = _.nw.yScaleFactory(this.dataSrc, this.options, this.options.yAxis.type, this.yDomain);\n this.yScale = this.yScaleGenerator.scale(yScaleDomain);\n } else {\n this.yScaleGenerator.update(yScaleDomain, this.dataSrc);\n }\n },\n\n /**\n * Provides a scaling function based on the xAxis values.\n *\n * ###Example:\n *\n * var scaledValue = this.xScale(100);\n *\n * @function xScale\n * @param {Number|String} value The value to be scaled.\n * @return {Number} The scaled value according to the current xAxis settings.\n */\n xScale: undefined,\n\n /**\n * Provides a scaling function based on the yAxis values.\n *\n * ###Example:\n *\n * var scaledValue = this.yScale(100);\n *\n * @function yScale\n * @param {Number} value The value to be scaled.\n * @return {Number} The scaled value according to the current yAxis settings.\n */\n yScale: undefined,\n\n /**\n * Modifies the domain for the yAxis.\n *\n * ###Example:\n *\n * this.setYDomain([100, 200]);\n *\n * @function setYDomain\n * @param {Array} domain The domain array representing the min and max values visible on the yAxis. */\n setYDomain: function (domain) {\n this.yScaleGenerator.setDomain(domain);\n },\n\n /**\n * Redraws the yAxis with the new settings and domain.\n *\n * ###Example:\n *\n * this.redrawYAxis();\n *\n * @function redrawYAxis\n */\n redrawYAxis: function () {\n this.svg.select('.y.axis').call(this.yAxis());\n this.renderGridlines();\n },\n\n _animationDuration: function () {\n var opt = this.options.chart.animations;\n return opt && opt.enable ?\n opt.duration != null ? opt.duration : 400 :\n 0;\n },\n\n computeScales: function () {\n this.computeXScale();\n this.computeYScale();\n\n return this;\n },\n\n _xAxis: undefined,\n xAxis: function () {\n if (!this._xAxis) {\n this._xAxis = this.xScaleGenerator.axis().orient(this.options.xAxis.orient);\n }\n return this._xAxis;\n },\n\n _yAxis: undefined,\n yAxis: function () {\n if(!this._yAxis) {\n this._yAxis = this.yScaleGenerator.axis().orient(this.options.yAxis.orient);\n }\n return this._yAxis;\n },\n\n renderXAxis: function () {\n var xAxis = this.xAxis();\n var y = this.options.chart.plotHeight + this.options.chart.padding.top;\n var x = this.options.chart.internalPadding.left;\n\n this._xAxisGroup = this.svg.selectAll('.x.axis')\n .data([1]);\n\n if (!this._xAxisGroup.node()) {\n this._xAxisGroup.enter()\n .append('g')\n .attr('transform', 'translate(' + x + ',' + y + ')')\n .attr('class', 'x axis');\n } else {\n d3.select(this._xAxisGroup.node())\n .attr('transform', 'translate(' + x + ',' + y + ')');\n }\n\n\n this._xAxisGroup\n .transition().duration(this._animationDuration())\n .call(xAxis);\n\n this.xScaleGenerator.postProcessAxis(this._xAxisGroup);\n\n return this;\n },\n\n renderYAxis: function () {\n var x = this.options.chart.internalPadding.left;\n var y = this.options.chart.padding.top;\n\n this._yAxisGroup = this.svg.selectAll('.y.axis')\n .data([1]);\n\n if (!this._yAxisGroup.node()) {\n this._yAxisGroup\n .enter().append('g')\n .attr('transform', 'translate(' + x + ',' + y + ')')\n .attr('class', 'y axis');\n } else {\n d3.select(this._yAxisGroup.node())\n .attr('transform', 'translate(' + x + ',' + y + ')');\n }\n\n this._renderYAxisElement();\n\n return this;\n },\n\n _renderYAxisElement: function () {\n var options = this.options.yAxis;\n var alignmentOffset = { bottom: '.8em', middle: '.35em', top: '0' };\n\n this._yAxisGroup\n .transition().duration(this._animationDuration())\n .call(this.yAxis())\n .selectAll('.tick text')\n .attr('dy', alignmentOffset[options.labels.verticalAlign]);\n },\n\n renderAxisLabels: function () {\n var adjustFactor = 40/46.609; // this factor is to account for the difference between the actual svg size and what we get from the DOM\n var bounds, x, y;\n var el;\n\n if (this.options.xAxis.title) {\n bounds = _.nw.textBounds(this.options.xAxis.title, '.x.axis-title');\n y = this.options.chart.internalPadding.bottom;\n x = 0;\n el = this._xAxisGroup.selectAll('.x.axis-title').data([1]);\n if (!el.node()) {\n el.enter().append('text')\n .attr('class', 'x axis-title');\n }\n\n d3.select(el.node())\n .attr('x', x)\n .attr('y', y)\n .attr('alignment-baseline', 'after-edge')\n .attr('dx', (this.options.chart.plotWidth - bounds.width) / 2)\n .text(this.options.xAxis.title);\n }\n\n if (this.options.yAxis.title) {\n bounds = _.nw.textBounds(this.options.yAxis.title, '.y.axis-title');\n y = -this.options.chart.internalPadding.left + bounds.height * adjustFactor;\n x = 0;\n el = this._yAxisGroup.selectAll('.y.axis-title').data([1]);\n if (!el.node()) {\n el.enter().append('text')\n .attr('class', 'y axis-title');\n }\n\n d3.select(el.node())\n .attr('class', 'y axis-title')\n .attr('transform', 'rotate(-90)')\n .attr('x', x)\n .attr('y', y)\n .attr('dx', -(this.options.chart.plotHeight + bounds.width) / 2)\n .attr('dy', 0)\n .text(this.options.yAxis.title);\n }\n\n return this;\n },\n\n renderGridlines: function () {\n var option = this.options.chart.gridlines;\n var horizontal = option === 'horizontal' || option === 'both';\n var vertical = option === 'vertical' || option === 'both';\n\n function getYTicks(axis, smart) {\n var tickValues = axis.tickValues();\n\n if(!tickValues) {\n var numTicks = axis.ticks()[0];\n return axis.scale().ticks(numTicks).slice(1);\n }\n\n if (smart) {\n tickValues.pop();\n }\n\n return tickValues.slice(1);\n }\n\n function getXTicks(axis) {\n return axis.tickValues() || (axis.scale().ticks ? axis.scale().ticks().slice(1) : axis.scale().domain());\n }\n\n var ticks, gr;\n var x = this.xScale;\n var y = this.yScale;\n\n if(horizontal) {\n ticks = getYTicks(this.yAxis(), this.options.yAxis.smartAxis);\n var w = this.options.chart.plotWidth;\n\n // remove previous lines (TODO: we need a better way)\n // this._yAxisGroup.select('g.grid-lines').remove();\n gr = this._yAxisGroup\n .selectAll('.grid-lines')\n .data([ticks]);\n\n gr.enter().append('svg:g')\n .attr('class', 'grid-lines');\n\n var lines = gr.selectAll('.grid-line')\n .data(function (d) { return d; });\n\n lines.transition().duration(this._animationDuration())\n .attr('x1', 0)\n .attr('x2', function () {\n return w;\n })\n .attr('y1', y)\n .attr('y2', y);\n\n lines.enter().append('line')\n .attr('class', 'grid-line')\n .attr('x1', 0)\n .attr('x2', function () {\n return w;\n })\n .attr('y1', y)\n .attr('y2', y);\n\n lines.exit().remove();\n }\n\n if(vertical) {\n // remove previous lines (TODO: we need a better way)\n this._xAxisGroup.select('g.grid-lines').remove();\n gr = this._xAxisGroup.append('svg:g').attr('class', 'grid-lines');\n ticks = getXTicks(this.xAxis());\n var offset = this.rangeBand / 2;\n var h = this.options.chart.plotHeight;\n\n gr.selectAll('.grid-line')\n .data(ticks)\n .enter().append('line')\n .attr('class', 'grid-line')\n .attr('x1', function (d) { return x(d) + offset; })\n .attr('x2', function (d) { return x(d) + offset; })\n .attr('y1', -h)\n .attr('y2', 0);\n }\n\n return this;\n },\n\n renderBackground: function () {\n var options = this.options.chart;\n this.background = this.background || this.createVisualizationLayer('background', 0);\n var g = this.background.selectAll('.plot-area-background').data([null]);\n\n g.enter().append('rect')\n .attr('class', 'plot-area-background')\n .attr('x', options.internalPadding.left)\n .attr('y', options.internalPadding.top)\n .attr('width', options.plotWidth)\n .attr('height', options.plotHeight);\n\n g.exit().remove();\n\n return this;\n },\n\n render: function () {\n\n this.composeOptions();\n this.adjustDomain();\n this.calcMetrics();\n this.computeScales();\n this.baseRender();\n\n this\n .renderBackground()\n .renderXAxis()\n .renderYAxis()\n .renderGridlines()\n .renderAxisLabels()\n .renderVisualizations();\n\n return this;\n },\n\n datum: function (d, index) {\n if(_.isObject(d) && _.isArray(d.data))\n return _.map(d.data, _.bind(this.datum, this));\n\n return {\n y: _.isObject(d) ? d.y : d,\n x: _.isObject(d) ? d.x : this.options.xAxis.categories ? this.options.xAxis.categories[index] : index\n };\n },\n\n adjustDomain: function () {\n var extents = this.getExtents();\n this._adjustXDomain(extents);\n this._adjustYDomain(extents);\n\n this._yAxis = null;\n this._xAxis = null;\n this.yScale = null;\n },\n\n _adjustXDomain: function (extents) {\n this.xDomain = this.getXDomain();\n var dataVis = _.filter(this._visualizations, function (v) { return _.nw.isSupportedDataFormat(v.data); });\n this.dataSrc = _.flatten(\n _.map(dataVis, function (v) {\n return _.flatten(_.map(v.data, _.bind(this.datum, this)));\n }.bind(this))\n );\n\n // _.every() on empty array returns true, so we guard against it\n var isCategoricalData = this.dataSrc.length && _.every(this.dataSrc, function (d) { return +d.x !== d.x; });\n var dataSrcCategories = _.uniq(_.map(this.dataSrc, 'x'));\n var sameCats = this.options.xAxis.categories ?\n this.options.xAxis.categories.length === dataSrcCategories.length && _.intersection(this.options.xAxis.categories, dataSrcCategories).length === dataSrcCategories.length :\n false;\n\n if (isCategoricalData && !(this.options.xAxis.categories && sameCats)) {\n this.options.xAxis.categories = dataSrcCategories;\n }\n },\n\n _adjustYDomain: function (extents) {\n this.yDomain = extents.length ? extents : [0, 10];\n this.yMin = this.yDomain[0];\n this.yMax = this.yDomain[this.yDomain.length - 1];\n },\n\n getExtents: function (axis) {\n var field = axis && axis === 'x' ? 'xExtent' : 'yExtent';\n var dataVis = _.filter(this._visualizations, function (v) { return _.nw.isSupportedDataFormat(v.data); });\n var all = _.flatten(_.map(dataVis, field));\n return all.length ? d3.extent(all) : [];\n },\n\n getXDomain: function () {\n var dataVis = _.filter(this._visualizations, function (v) { return _.nw.isSupportedDataFormat(v.data); });\n var all = _.nw.uniq(_.flatten(_.map(dataVis, 'xDomain')));\n\n return all;\n }\n\n };\n };\n\n Contour.expose('cartesian', cartesian);\n\n})();\n","(function () {\n\n var root = this;\n\n var defaultParams = {\n type: 'image/png', // the mime type of the image; see http://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support for browser support\n fileName: 'contour.png', // the fileName for the `download()`\n target: undefined, // a selector for the container in which to `place()` the image; for example '#image'\n backgroundColor: '#fff', // the fill color of the image, or `null` for transparent background\n width: undefined, // the width of the exported image; if `height` is falsy then the height will be scaled proportionally\n height: undefined // the height of the exported image; if `width` is falsy then the width will be scaled proportionally\n };\n\n // browser capabilities\n var browser = {\n checked: false // true after browser capabilities have been checked\n };\n\n // queue of operations to perform synchronously\n var queue = [];\n // true if working on something\n var working = false;\n\n\n /**\n * Saves a visualization as an image.\n * You can either trigger a download of the image or place the image within a container.\n *\n * ###Example:\n *\n * var chart = new Contour(...)\n * ...\n * .exportable()\n * .render();\n *\n * document.getElementById('save').onclick = function () {\n * chart.download({\n * fileName: 'myContourChart.png'\n * });\n *\n * ###External dependencies:\n *\n * IE9-11 and Safari won't safely export a canvas to which an SVG has been\n * rendered. To get around this limitation in those browsers, we use CanVG\n * (\"canned veggies\"), an implementation of SVG written in JavaScript to\n * render the SVG directly to the canvas. During initialization of the\n * 'exportable' plugin, CanVG is automatically downloaded from\n * http://canvg.googlecode.com/svn/trunk/ if the browser fails the test\n * SVG export.\n *\n * @name exportable\n */\n var exportable = function () {\n // CSS properties to ignore for diff\n var cssIgnoreDiff = {\n cssText: 1,\n parentRule: 1\n };\n // CSS properties shared between HTML and SVG\n var cssSharedSvg = {\n font: 1,\n fontFamily: 1,\n fontSize: 1,\n fontSizeAdjust: 1,\n fontStretch: 1,\n fontStyle: 1,\n fontVariant: 1,\n fontWeight: 1,\n direction: 1,\n letterSpacing: 1,\n textDecoration: 1,\n unicodeBidi: 1,\n wordSpacing: 1,\n clip: 1,\n cursor: 1,\n display: 1,\n overflow: 1,\n visibility: 1,\n opacity: 1\n };\n\n\n // interface\n\n return {\n init: function () {\n // check browser capabilities and set up necessary shims\n // only do this once per page load\n if (!browser.checked) {\n addToQueue(checkBrowser);\n }\n\n return this;\n },\n\n /**\n * Saves a visualization as an image, triggering a download.\n *\n * ###Browser variations:\n *\n * - Chrome saves the image.\n * - Firefox and IE10-11 display a prompt, then save the image.\n * - IE9 and Safari open the image in a new tab, enabling the user to manually save the image.\n *\n * ###Example:\n *\n * var chart = new Contour(...)\n * ...\n * .exportable()\n * .render();\n *\n * document.getElementById('save').onclick = function () {\n * chart.download({\n * fileName: 'contour.png',\n * width: 640\n * });\n *\n * @name download\n * @param {object} options Configuration options specific to downloading the image.\n * @param {string} options.type Specifies the mime type of the image. See http://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support for browser support. Default: 'image/png'.\n * @param {string} options.fileName Specifies the file name for the download. Default: 'contour.png'.\n * @param {string} options.backgroundColor Specifies the fill color of the image. Use `null` for transparent background. Default: '#fff'.\n * @param {int} options.width Specifies the width of the exported image. If `height` is falsy then the height is scaled proportionally. Default: `undefined`, which means don't do any scaling.\n * @param {int} options.height Specifies the height of the exported image. If `width` is falsy then the width is scaled proportionally. Default: `undefined`, which means don't do any scaling.\n */\n download: function (options) {\n var container = this.container;\n\n addToQueue(function () {\n exportImage(container, options, 'download');\n });\n\n return this;\n },\n\n /**\n * Saves a visualization as an image, placing it within a container.\n *\n * ###Example:\n *\n * var chart = new Contour(...)\n * ...\n * .exportable()\n * .render();\n * document.getElementById('save').onclick = function () {\n * chart.place({\n * target: '#image'\n * });\n *\n * @name place\n * @param {object} options Configuration options specific to placing the image in a container.\n * @param {string} options.type Specifies the mime type of the image. See http://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support for browser support. Default: 'image/png'.\n * @param {string} options.target Specifies a selector for the container. For example: '#image' will append the image into `
`.\n * @param {string} options.backgroundColor Specifies the fill color of the image. Use `null` for transparent background. Default: '#fff'.\n * @param {int} options.width Specifies the width of the exported image. If `height` is falsy then the height is scaled proportionally. Default: `undefined`, which means don't do any scaling.\n * @param {int} options.height specifies the height of the exported image. If `width` is falsy then the width is scaled proportionally. Default: `undefined`, which means don't do any scaling.\n */\n place: function (options) {\n var container = this.container;\n\n addToQueue(function () {\n exportImage(container, options, 'place');\n });\n\n return this;\n }\n };\n\n\n // SVG to canvas export function\n // adapted from https://github.com/sampumon/SVG.toDataURL\n // which based on http://svgopen.org/2010/papers/62-From_SVG_to_Canvas_and_Back/#svg_to_canvas\n function getSvgDataUrl(svg, options, dataUrlCreated) {\n switch (options.type) {\n case 'image/svg+xml':\n return makeSvgUrl();\n\n default: // 'image/png' or 'image/jpeg'\n return makeImageUrl();\n }\n\n\n function encodeBase64DataUrl(svgXml) {\n // https://developer.mozilla.org/en/DOM/window.btoa\n return 'data:image/svg+xml;base64,' + btoa(svgXml);\n }\n\n // convert base64/URLEncoded data component to raw binary data held in a string\n function dataUrlToBlob(dataUrl) {\n /*jshint nonstandard:true*/\n var byteString;\n if (dataUrl.split(',')[0].indexOf('base64') >= 0) {\n byteString = atob(dataUrl.split(',')[1]);\n } else {\n byteString = unescape(dataUrl.split(',')[1]);\n }\n\n // separate out the mime component\n var mimeString = dataUrl.split(',')[0].split(':')[1].split(';')[0];\n\n // write the bytes of the string to a typed array\n var byteArray = new Uint8Array(byteString.length);\n for (var i = 0; i < byteString.length; i++) {\n byteArray[i] = byteString.charCodeAt(i);\n }\n\n return new Blob([byteArray], {\n type: mimeString\n });\n }\n\n function makeSvgUrl() {\n var svgXml = (new XMLSerializer()).serializeToString(svg);\n var svgDataUrl = encodeBase64DataUrl(svgXml);\n\n dataUrlCreated(svgDataUrl, null, function () {});\n }\n\n function makeImageUrl() {\n var canvas = document.createElement('canvas');\n var context = canvas.getContext('2d');\n\n var svgXml = (new XMLSerializer()).serializeToString(svg);\n\n if (root.canvg) {\n // use Canvg renderer for image export\n renderImageCanvg();\n } else {\n // use native renderer for image export (this might fail)\n renderImageNative();\n }\n\n function imageRendered() {\n var imageDataUrl = canvas.toDataURL(options.type);\n\n if (browser.createsObjectUrls) {\n var imageBlob = dataUrlToBlob(imageDataUrl);\n\n var domUrl = root.URL || root.webkitURL;\n var objectUrl = domUrl.createObjectURL(imageBlob);\n\n dataUrlCreated(objectUrl, imageBlob, function () {\n domUrl.revokeObjectURL(objectUrl);\n });\n } else {\n dataUrlCreated(imageDataUrl, null, function () {});\n }\n }\n\n function renderImageNative() {\n var svgImg = new Image();\n svgImg.src = encodeBase64DataUrl(svgXml);\n\n svgImg.onload = function () {\n canvas.width = svgImg.width;\n canvas.height = svgImg.height;\n\n if (options.backgroundColor) {\n context.fillStyle = options.backgroundColor;\n context.fillRect(0, 0, svgImg.width, svgImg.height);\n }\n\n context.drawImage(svgImg, 0, 0);\n\n imageRendered();\n };\n\n svgImg.onerror = function () {\n throw new Error('Cannot export image');\n };\n }\n\n function renderImageCanvg() {\n // note that Canvg gets the SVG element dimensions incorrectly if not specified as attributes\n // also this Canvg call is synchronous and blocks\n canvg(canvas, svgXml, {\n ignoreMouse: true,\n ignoreAnimation: true,\n offsetX: undefined,\n offsetY: undefined,\n scaleWidth: undefined,\n scaleHeight: undefined,\n renderCallback: imageRendered\n });\n }\n }\n }\n\n\n // clone SVG in isolation with styles directly applied\n function createSvgClone(svgNode, svgCloned) {\n createIsolatedNode(function (nodeClone, destroyIsolatedNode) {\n // clone nodes and apply styles directly to each node\n cloneNodes(svgNode, nodeClone);\n\n // clone legend DIV as SVG\n cloneLegendDiv(svgNode, nodeClone);\n\n svgCloned(d3.select(nodeClone).select('svg').node(), destroyIsolatedNode);\n });\n\n\n // compare computed styles at this node and apply the differences directly\n function applyStyles(sourceNode, targetNode) {\n var sourceStyle = root.getComputedStyle(sourceNode);\n var targetStyle = root.getComputedStyle(targetNode);\n\n for (var prop in sourceStyle) {\n if (!cssIgnoreDiff[prop] && !isFinite(prop)) {\n // note that checking for sourceStyle.hasOwnProperty(prop) eliminates all valid style properties in Firefox\n if (targetStyle[prop] !== sourceStyle[prop]) {\n targetNode.style[prop] = sourceStyle[prop];\n }\n }\n }\n }\n\n // clone nodes and apply styles directly to each node\n function cloneNodes(sourceNode, targetNode) {\n var newNode = sourceNode.cloneNode(false);\n targetNode.appendChild(newNode);\n\n if (!sourceNode.tagName) return; // skip inner text\n\n // compare computed styles at this node and apply the differences directly\n applyStyles(sourceNode, newNode);\n\n _.each(sourceNode.childNodes, function (childNode) {\n // clone each child node and apply styles\n cloneNodes(childNode, newNode);\n });\n }\n\n function createIsolatedNode(nodeLoaded) {\n var iframe = document.body.appendChild(document.createElement('iframe'));\n iframe.style.visibility = 'hidden';\n var iframeWindow = iframe.contentWindow;\n var iframeDocument = iframeWindow.document;\n\n iframe.onload = function () {\n var nodeClone = iframeDocument.createElement('div');\n iframeDocument.body.appendChild(nodeClone);\n\n var destroyIframe = function () {\n // destroy clone\n iframeDocument.body.removeChild(nodeClone);\n document.body.removeChild(iframe);\n };\n\n nodeLoaded(nodeClone, destroyIframe);\n };\n\n iframeDocument.open();\n iframeDocument.write('');\n iframeDocument.write('');\n iframeDocument.close();\n }\n\n function applyDivStylesToSvg(sourceNode, target) {\n var targetNode = target.node();\n var sourceStyle = root.getComputedStyle(sourceNode);\n var targetStyle = root.getComputedStyle(targetNode);\n\n for (var prop in sourceStyle) {\n if (cssSharedSvg[prop]) {\n // note that checking for sourceStyle.hasOwnProperty(prop) eliminates all valid style properties in Firefox\n if (targetStyle[prop] !== sourceStyle[prop]) {\n targetNode.style[prop] = sourceStyle[prop];\n }\n }\n }\n\n // translate DIV styles to SVG attributes and styles\n switch (targetNode.nodeName) {\n case 'rect':\n target.attr({\n 'rx': sourceStyle.borderTopLeftRadius,\n 'ry': sourceStyle.borderTopLeftRadius\n });\n target.style({\n 'fill': sourceStyle.backgroundColor,\n 'stroke': sourceStyle.borderLeftColor,\n 'stroke-width': sourceStyle.borderLeftWidth\n });\n break;\n case 'text':\n target.style({\n 'fill': sourceStyle.color\n });\n break;\n }\n }\n\n function cloneLegendDiv(sourceNode, targetNode) {\n var containerDiv = d3.select(sourceNode.parentNode).select('div.contour-legend');\n if (containerDiv.empty()) return;\n\n var containerDivNode = containerDiv.node();\n\n var containerSvg = d3.select(targetNode).select('svg').append('g')\n .attr('transform', 'translate(' + (containerDivNode.offsetLeft + containerDivNode.clientLeft) +\n ',' + (containerDivNode.offsetTop + containerDivNode.clientTop) + ')');\n applyDivStylesToSvg(containerDivNode, containerSvg);\n\n var rect = containerSvg.append('rect')\n .attr('width', containerDivNode.clientWidth)\n .attr('height', containerDivNode.clientHeight);\n applyDivStylesToSvg(containerDivNode, rect);\n\n var entriesDivs = containerDiv.selectAll('.contour-legend-entry');\n\n _.each(entriesDivs[0], function (entryDivNode) {\n var entryDiv = d3.select(entryDivNode);\n\n var enter = containerSvg.append('g');\n applyDivStylesToSvg(entryDivNode, enter);\n\n var entryDivKeyNode = getEntryDivSubNode('.contour-legend-key');\n var swatch = enter.append('rect')\n .attr('x', entryDivKeyNode.offsetLeft)\n .attr('y', entryDivKeyNode.offsetTop)\n .attr('width', entryDivKeyNode.offsetWidth - 2)\n .attr('height', entryDivKeyNode.offsetHeight - 2);\n applyDivStylesToSvg(entryDivKeyNode, swatch);\n\n var entryDivSeriesNode = getEntryDivSubNode('.series-name');\n var text = enter.append('text')\n .attr('x', entryDivSeriesNode.offsetLeft + 1)\n .attr('y', entryDivSeriesNode.offsetTop + entryDivSeriesNode.offsetHeight - entryDivSeriesNode.offsetParent.clientTop - 2)\n .text(entryDivSeriesNode.textContent);\n applyDivStylesToSvg(entryDivSeriesNode, text);\n\n function getEntryDivSubNode(selector) {\n return entryDiv.select(selector).node();\n }\n });\n }\n }\n\n\n function getProportionedBounds(original, specified) {\n if (specified.width && specified.height) {\n return specified;\n } else if (specified.width) {\n return {\n width: specified.width,\n height: specified.width * original.height / original.width\n };\n } else if (specified.height) {\n return {\n width: specified.height * original.width / original.height,\n height: specified.height\n };\n } else {\n return original;\n }\n }\n\n\n function exportImage(container, options, exporter) {\n startWork();\n\n // merge configuration options with defaults\n options = options || {};\n _.defaults(options, defaultParams);\n\n var svgNode = container.select('svg').node();\n // get bounds from original SVG, and proportion them based on specified options\n var bounds = svgNode.getBoundingClientRect();\n var boundsClone = getProportionedBounds(bounds, options);\n\n // clone SVG in isolation with styles directly applied\n createSvgClone(svgNode, performExport);\n\n function performExport(svgNodeClone, destroySvgClone) {\n svgNodeClone.setAttribute('width', boundsClone.width);\n svgNodeClone.setAttribute('height', boundsClone.height);\n\n // Safari can only open a new tab with the image\n // the tab must be opened before `getSvgDataUrl()` to avoid getting blocked due to asynchronous callbacks\n var win;\n if (exporter === 'download' && !(browser.aDownloads || browser.savesMsBlobs)) {\n win = root.open();\n }\n\n getSvgDataUrl(svgNodeClone, options, function (url, blob, revokeUrl) {\n destroySvgClone();\n\n // exporter functions\n var exporters = {\n 'download': function () {\n if (browser.aDownloads) {\n // make a link to download and click it\n var a = document.createElement('a');\n a.download = options.fileName;\n a.href = url;\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n } else if (browser.savesMsBlobs && blob) {\n // IE10-11 support a method to save/open a blob\n navigator.msSaveOrOpenBlob(blob, options.fileName);\n } else {\n // Safari and IE9 can only open a new tab with the image\n if (!win) {\n // in case `blob` was falsy or the `open()` above returned undefined, `win` will be undefined, so attempt here (and this might return undefined as well)\n win = root.open();\n }\n if (win) {\n if (browser.createsObjectUrls) {\n // Safari can set the url of the newly-opened tab to the object URL of the blob\n win.location = url;\n } else {\n // for IE9, create a document with the image\n var doc = win.document;\n doc.write('');\n doc.write('');\n doc.write('');\n doc.write('');\n }\n }\n }\n // wait for download to start\n setTimeout(function () {\n revokeUrl();\n finishWork();\n }, 1);\n },\n 'place': function () {\n var img = document.createElement('img');\n img.onload = function () {\n revokeUrl();\n finishWork();\n };\n img.src = url;\n d3.select(options.target).node().appendChild(img);\n }\n };\n // call exporter function\n exporters[exporter]();\n });\n }\n }\n };\n\n\n // queue functions\n\n // queue will wait until any asynchronous tasks are complete prior to calling the next fn()\n function addToQueue(fn) {\n if (working) {\n queue.push(fn);\n } else {\n fn();\n }\n }\n\n // call before starting an asynchronous task\n function startWork() {\n working = true;\n }\n\n // call after finishing an asynchronous task\n function finishWork() {\n working = false;\n\n var fn = queue.shift();\n if (fn) {\n fn();\n }\n }\n\n\n // check browser capabilities and set up necessary shims\n function checkBrowser() {\n startWork();\n browser.checked = true;\n\n checkEncodesBase64();\n checkADownloads();\n checkSavesMsBlobs();\n checkCreatesObjectUrls();\n checkExportsSvg(finishWork);\n\n\n function checkEncodesBase64() {\n browser.encodesBase64 = !!root.btoa;\n\n // setup shim for IE9\n if (!browser.encodesBase64) {\n setupBase64Shim();\n }\n }\n\n function checkADownloads() {\n browser.aDownloads = document.createElement('a').download !== undefined;\n }\n\n function checkSavesMsBlobs() {\n browser.savesMsBlobs = !!navigator.msSaveOrOpenBlob;\n }\n\n function checkCreatesObjectUrls() {\n var domUrl = root.URL || root.webkitURL;\n browser.createsObjectUrls = domUrl && domUrl.createObjectURL;\n }\n\n function checkExportsSvg() {\n startWork();\n\n browser.exportsSvg = false;\n\n var iframe = document.body.appendChild(document.createElement('iframe'));\n iframe.style.visibility = 'hidden';\n var doc = iframe.contentWindow.document;\n\n iframe.onload = function () {\n try {\n var svg = doc.querySelector('svg');\n var img = doc.querySelector('img');\n var canvas = doc.querySelector('canvas');\n var context = canvas.getContext('2d');\n canvas.width = img.getAttribute('width') * 1;\n canvas.height = img.getAttribute('height') * 1;\n var sourceImg = new Image();\n sourceImg.width = canvas.width;\n sourceImg.height = canvas.height;\n sourceImg.onload = function () {\n try {\n context.drawImage(sourceImg, 0, 0, img.width, img.height);\n img.src = canvas.toDataURL();\n\n browser.exportsSvg = true; // yay\n } catch (e) {}\n\n svgExportChecked();\n };\n var xml = (new XMLSerializer()).serializeToString(svg);\n sourceImg.src = 'data:image/svg+xml,' + encodeURIComponent(xml);\n } catch (e) {\n svgExportChecked();\n }\n };\n\n doc.open();\n doc.write('');\n doc.write('');\n doc.write('');\n doc.write('');\n doc.write('');\n doc.write('');\n doc.close();\n\n\n function svgExportChecked() {\n document.body.removeChild(iframe);\n\n // load Canvg SVG renderer for browsers that can't safely export SVG\n if (browser.exportsSvg) {\n finishWork();\n } else {\n setupCanvgShim(finishWork);\n }\n }\n }\n\n // base64 shim, for IE9\n function setupBase64Shim() {\n var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n\n function InvalidCharacterError(message) {\n this.message = message;\n }\n InvalidCharacterError.prototype = new Error();\n InvalidCharacterError.prototype.name = 'InvalidCharacterError';\n\n // base64 encoder\n // from https://gist.github.com/999166\n root.btoa = function (input) {\n var str = String(input);\n for (\n // initialize result and counter\n var block, charCode, idx = 0, map = chars, output = '';\n // if the next str index does not exist:\n // change the mapping table to \"=\"\n // check if d has no fractional digits\n str.charAt(idx | 0) || (map = '=', idx % 1);\n // \"8 - idx % 1 * 8\" generates the sequence 2, 4, 6, 8\n output += map.charAt(63 & block >> 8 - idx % 1 * 8)\n ) {\n charCode = str.charCodeAt(idx += 3 / 4);\n if (charCode > 0xFF) {\n throw new InvalidCharacterError('\"btoa\" failed: The string to be encoded contains characters outside of the Latin1 range.');\n }\n block = block << 8 | charCode;\n }\n return output;\n };\n }\n\n // Canvg shim, for IE9-11 and Safari\n function setupCanvgShim(done) {\n var scripts = [\n 'rgbcolor.js',\n 'StackBlur.js',\n 'canvg.js'\n ];\n var remaining = scripts.length;\n _.each(scripts, function (src) {\n var script = document.createElement('script');\n script.type = 'text/javascript';\n script.onload = function () {\n remaining--;\n if (remaining === 0) done();\n };\n script.src = '//canvg.googlecode.com/svn/trunk/' + src;\n document.head.appendChild(script);\n });\n }\n }\n\n\n Contour.expose('exportable', exportable);\n\n})();\n","Contour.version = '1.0.1';","(function () {\n\n var helpers = {\n xScaleFactory: function (data, options) {\n // if we have dates in the x field of the data points\n // we need a time scale, otherwise is an oridinal\n // two ways to shape the data for time scale:\n // [{ x: date, y: 1}, {x: date, y: 2}]\n // [{ data: [ x: date, y: 1]}, {data: [x: date, y: 100]}]\n // if we get no data, we return an ordinal scale\n var isTimeData = options.xAxis.type === 'time' || (_.isArray(data) && data.length > 0 && data[0].data ?\n data[0].data[0].x && _.isDate(data[0].data[0].x) :\n _.isArray(data) && data.length > 0 && data[0].x && _.isDate(data[0].x));\n\n\n if (isTimeData && options.xAxis.type !== 'ordinal') {\n return new _.nw.axes.TimeScale(data, options);\n }\n\n if (!options.xAxis.categories && options.xAxis.type === 'linear') {\n return new _.nw.axes.LinearScale(data, options);\n }\n\n return new _.nw.axes.OrdinalScale(data, options);\n },\n\n yScaleFactory: function (data, options, axisType, domain) {\n var map = {\n 'log': _.nw.axes.LogYAxis,\n 'smart': _.nw.axes.SmartYAxis,\n 'linear': _.nw.axes.YAxis\n };\n\n if (!axisType) {\n axisType = 'linear';\n }\n\n if (axisType === 'linear' && options.yAxis.smartAxis) {\n axisType = 'smart';\n }\n\n if (map[axisType]) {\n return new map[axisType](data, options, domain);\n }\n\n // try by namespace\n if (_.nw.axes[axisType]) {\n return new _.nw.axes[axisType](data, options, domain);\n }\n\n throw new Error('Unknown axis type: \"' + axisType + '\"');\n }\n\n };\n\n _.nw = _.extend({}, _.nw, helpers);\n\n})();\n","(function () {\n\n function LinearScale(data, options) {\n this.options = options;\n this.data = data;\n\n this.init();\n }\n\n LinearScale.prototype = {\n init: function () {\n delete this._scale;\n },\n\n /*jshint eqnull:true*/\n scale: function (domain) {\n this._domain = domain ? this._getAxisDomain(domain) : this._getAxisDomain(this.data);\n this._scale = this._scale || d3.scale.linear();\n this._scale.domain(this._domain);\n\n if (this.options.xAxis.min == null && this.options.xAxis.max == null) {\n this._scale.nice();\n }\n\n this._setRange();\n\n return this._scale;\n },\n\n axis: function () {\n var options = this.options.xAxis;\n var formatLabel = options.labels.formatter || d3.format(options.labels.format || 'g');\n var axis = d3.svg.axis()\n .scale(this._scale)\n .tickSize(options.innerTickSize, options.outerTickSize)\n .tickPadding(options.tickPadding)\n .tickFormat(function (d) {\n return _.isDate(d) ? d.getDate() : formatLabel(d);\n });\n\n var ticks = axis.scale().ticks();\n var labelsFit = _.nw.doXLabelsFit(ticks, formatLabel, this.options);\n\n if (options.firstAndLast) {\n // show only first and last tick\n axis.tickValues(_.nw.firstAndLast(this._domain));\n } else if (options.tickValues) {\n axis.tickValues(options.tickValues);\n } else if (options.ticks != null) {\n axis.ticks(options.ticks);\n } else if (!labelsFit) {\n var finalTicks = _.nw.getTicksThatFit(ticks, formatLabel, this.options);\n axis.tickValues(finalTicks);\n axis.ticks(finalTicks.length);\n\n }\n\n return axis;\n },\n\n update: function (domain, dataSrc) {\n this.data = dataSrc;\n this.scale(domain);\n },\n\n rangeBand: function () {\n return 1;\n },\n\n postProcessAxis: function () {\n return this;\n },\n\n _setRange: function () {\n var rangeSize = !!this.options.chart.rotatedFrame ? this.options.chart.plotHeight : this.options.chart.plotWidth;\n var range = !!this.options.chart.rotatedFrame ? [rangeSize, 0] : [0, rangeSize];\n return this._scale.range(range);\n },\n\n _getAxisDomain: function (domain) {\n /*jshint eqnull: true*/\n var optMin = this.options.xAxis.min;\n var optMax = this.options.xAxis.max;\n var extents = d3.extent(domain);\n\n if (optMin == null && optMax == null) {\n return extents;\n }\n\n if (optMin == null) {\n return [Math.min(extents[0], optMax), optMax];\n }\n\n if (optMax == null) {\n return [optMin, Math.max(extents[1], optMin)];\n }\n\n // options are invalid, use the extents\n if (optMin > optMax) {\n return extents;\n }\n\n return [optMin, optMax];\n }\n };\n\n _.nw.addAxis('LinearScale', LinearScale );\n\n})();\n","(function () {\n\n var LogYAxis = function (data, options) {\n this.data = data;\n this.options = options;\n };\n\n function setRange(scale, options) {\n var rangeSize = options.chart.rotatedFrame ? options.chart.plotWidth : options.chart.plotHeight;\n var range = options.chart.rotatedFrame ? [0, rangeSize] : [rangeSize, 0];\n return scale.range(range);\n }\n\n var __super = _.nw.axes.YAxis.prototype;\n LogYAxis.prototype = _.extend({}, __super, {\n axis: function () {\n var options = this.options.yAxis;\n var domain = this._scale.domain();\n var ticksHint = Math.ceil(Math.log(domain[1]) / Math.log(10));\n var format = options.labels.formatter || d3.format(options.labels.format || ',.0f');\n\n var axis = d3.svg.axis()\n .scale(this._scale)\n .tickSize(options.innerTickSize, options.outerTickSize)\n .tickPadding(options.tickPadding);\n if(options.labels.formatter) {\n axis.tickFormat(options.labels.formatter);\n } else {\n axis.ticks(options.ticks || ticksHint, format);\n }\n\n\n return axis;\n },\n\n scale: function (domain) {\n if(!this._scale) {\n if(domain[0] <= 0.1) domain[0] = 0.1; //throw new Error('Log scales don\\'t support 0 or negative values');\n\n this._scale = d3.scale.log();\n this.setDomain(domain).clamp(true);\n\n }\n\n setRange(this._scale, this.options);\n\n return this._scale;\n },\n\n update: function (domain, dataSrc) {\n this.data = dataSrc;\n if(domain[0] <= 0.1) domain[0] = 0.1; //throw new Error('Log scales don\\'t support 0 or negative values');\n this.setDomain(domain).clamp(true);\n this.scale();\n },\n });\n\n _.nw.addAxis('LogYAxis', LogYAxis );\n\n})();\n","(function () {\n\n // implements the following interface\n /*\n {\n scale: returns the d3 scale for the type\n\n axis: returns the d3 axis\n\n range: returns the d3 range for the type\n\n postProcessAxis:\n }\n */\n\n function OrdinalScale(data, options) {\n this.options = options;\n this.data = data;\n\n this.init();\n }\n\n OrdinalScale.prototype = {\n init: function () {\n this.isCategorized = true;\n delete this._scale;\n },\n\n scale: function (domain) {\n if(!this._scale) {\n this._scale = new d3.scale.ordinal();\n }\n\n this.setDomain(domain || this.data);\n\n return this._scale;\n },\n\n /* jshint eqnull:true */\n axis: function () {\n var options = this.options.xAxis;\n var optFormat = (options.labels.format ? d3.format(options.labels.format) : 0);\n var formatLabel = options.labels.formatter || d3.format(options.labels.format || 'g');\n\n var tickFormat = options.labels.formatter || (!this.isCategorized ? optFormat : 0) || function (d) { return _.isDate(d) ? d.getDate() : d; };\n var axis = d3.svg.axis()\n .scale(this._scale)\n .innerTickSize(options.innerTickSize)\n .outerTickSize(options.outerTickSize)\n .tickPadding(options.tickPadding)\n .tickFormat(tickFormat);\n\n var ticks = this.isCategorized && options.categories ? options.categories : _.range(this._domain.length) || [];\n var labelsFit = _.nw.doXLabelsFit(ticks, formatLabel, this.options);\n\n if (options.firstAndLast) {\n // show only first and last tick\n axis.tickValues(_.nw.firstAndLast(this._domain));\n } else if (options.maxTicks) {\n axis.tickValues(_.nw.maxTickValues(options.maxTicks, this._domain));\n } else if (options.tickValues) {\n axis.tickValues(options.tickValues);\n } else if (options.ticks != null) {\n axis.ticks(options.ticks);\n if (options.ticks === 0) {\n axis.tickValues([]);\n }\n } else if (!labelsFit) {\n var finalTicks = _.nw.getTicksThatFit(ticks, formatLabel, this.options);\n axis.tickValues(finalTicks);\n axis.ticks(finalTicks.length);\n } else {\n axis.tickValues(options.categories);\n }\n\n return axis;\n },\n\n /* jshint eqnull:true */\n postProcessAxis: function (axisGroup) {\n var options = this.options.xAxis;\n if (!options.labels || options.labels.rotation == null) return;\n\n var deg = options.labels.rotation;\n var rad = _.nw.degToRad(deg);\n var sign = deg > 0 ? 1 : deg < 0 ? -1 : 0;\n var pos = deg < 0 ? -1 : 1;\n var lineHeight = 0.71;\n var lineCenter = lineHeight / 2; // center of text line is at .31em\n var cos = Math.cos(rad);\n var sin = Math.sin(rad);\n var anchor = options.labels.rotation < 0 ? 'end' : options.labels.rotation > 0 ? 'start' : 'middle';\n\n axisGroup.selectAll('.tick text')\n .style({'text-anchor': anchor})\n .attr('transform', function (d, i, j) {\n var x = d3.select(this).attr('x') || 0;\n var y = d3.select(this).attr('y') || 0;\n return 'rotate(' + options.labels.rotation + ' ' + x + ',' + y + ')';\n })\n .attr('dy', function (d, i, j) {\n var ref = deg === 0 ? lineHeight : lineCenter;\n var num = ((cos * ref) + (sin * ref * pos));\n return (num).toFixed(4) + 'em';\n // return (sign * ((cos * lineCenter) + (sin * lineCenter))).toFixed(4) + 'em';\n })\n .attr('dx', function (d, i, j) {\n // var num = ((sin * lineCenter * pos));\n // return -num.toFixed(4) + 'em';\n return -(sin * lineCenter - 0.31 * sign).toFixed(4) + 'em';\n\n });\n },\n\n update: function (domain, data) {\n this.data = data;\n this.scale(domain);\n },\n\n setDomain: function (domain) {\n this._domain = domain;\n this._scale.domain(domain);\n this._range();\n },\n\n rangeBand: function () {\n var band = this._scale.rangeBand();\n if (!band) _.nw.warn('rangeBand is 0, you may have too many points in in the domain for the size of the chart (ie. chartWidth = ' + this.options.chart.plotWidth + 'px and ' + (this._domain.length) + ' X-axis points (plus paddings) means less than 1 pixel per band and there\\'re no half pixels');\n\n return this._scale.rangeBand();\n },\n\n _range: function () {\n var range = this.options.chart.rotatedFrame ? [this.options.chart.plotHeight, 0] : [0, this.options.chart.plotWidth];\n var numCats = (this._domain || []).length;\n var threshold = 30;\n var rangeType = numCats <= threshold ? 'rangeRoundBands' : 'rangeBands';\n\n return this.isCategorized ?\n // this._scale.rangeBands(range, this.options.xAxis.innerRangePadding, this.options.xAxis.outerRangePadding) :\n this._scale[rangeType](range, this.options.xAxis.innerRangePadding, this.options.xAxis.outerRangePadding) :\n this._scale.rangePoints(range);\n }\n };\n\n _.nw.addAxis('OrdinalScale', OrdinalScale );\n\n})();\n","(function () {\n\n var SmartYAxis = function (data, options, domain) {\n this.data = data;\n this.options = options;\n this.yMax = domain[0];\n this.yMin = domain[1];\n this.dataMax = d3.max(_.map(data, 'y'));\n };\n\n /* jshint eqnull: true */\n function _extractYTickValues(domain, min, max, yMin, yMax, dataMax) {\n var adjustedDomain = _.uniq(_.nw.merge(_.nw.merge(domain, yMax), dataMax));\n // we want to be able to remove parameters with default values\n // so to remove the default yAxis.min: 0, you pass yAxis.min: null\n // and for that we need to to a truly comparison here (to get null or undefined)\n if (min == null && max == null)\n return adjustedDomain;\n\n if (min == null) {\n return max > yMin ? _.nw.merge([max], adjustedDomain) : [max];\n }\n\n if (max == null) {\n if (min >= yMax) return [min];\n adjustedDomain[0] = min;\n\n return adjustedDomain;\n }\n\n return _.nw.merge([min, max], yMax);\n }\n\n var __super = _.nw.axes.YAxis.prototype;\n SmartYAxis.prototype = _.extend({}, __super, {\n axis: function () {\n var options = this.options.yAxis;\n this.domain = this._scale.domain();\n var tickValues = _extractYTickValues(this.domain, options.min, options.max, this.yMin, this.yMax, this.dataMax);\n var numTicks = this.numTicks();\n var axis = __super.axis.call(this);\n return axis.ticks(numTicks)\n .tickValues(tickValues);\n },\n\n numTicks: function () {\n return 3;\n },\n\n setDomain: function (domain) {\n var extent = d3.extent(domain);\n this.yMin = extent[0];\n this.yMax = extent[1];\n this._scale.domain(domain);\n\n this._niceTheScale();\n },\n\n _niceTheScale: function () {\n var perTreshold = 0.05;\n var domain = this._scale.domain();\n var min = this.options.yAxis.min || domain[0];\n var rawMax = this.options.yAxis.max || this.dataMax;\n var nextTick = _.nw.roundToNextTick(rawMax);\n\n var max = Math.abs(nextTick - rawMax) < rawMax * perTreshold ? _.nw.roundToNextTick(rawMax + rawMax * perTreshold) : nextTick;\n // var max = nextTick === rawMax ? _.nw.roundToNextTick(rawMax + Math.pow(10, -_.nw.decDigits(rawMax) - 1)) : nextTick;\n var nice = [min, max];\n this._scale.domain(nice);\n }\n });\n\n _.nw.addAxis('SmartYAxis', SmartYAxis );\n})();\n","(function () {\n\n // implements the following interface\n /*\n {\n scale: returns the d3 scale for the type\n\n range: returns the d3 range for the type\n }\n */\n\n function dateDiff(d1, d2) {\n if (!d1 || !d2) return 0;\n var diff = d1.getTime() - d2.getTime();\n return diff / (24*60*60*1000);\n }\n\n\n function TimeScale(data, options) {\n this.options = options;\n this.data = data;\n\n this.init();\n }\n\n TimeScale.prototype = {\n init: function () {\n delete this._scale;\n },\n\n scale: function (domain) {\n\n if(!this._scale) {\n this._scale = new d3.time.scale();\n this.setDomain(domain);\n }\n\n this.range();\n\n return this._scale;\n },\n\n\n /* jshint eqnull:true */\n axis: function () {\n var options = this.options.xAxis;\n var tickFormat = this.getOptimalTickFormat();\n\n var axis = d3.svg.axis()\n .scale(this._scale)\n .tickFormat(tickFormat)\n .tickSize(options.innerTickSize, options.outerTickSize)\n .tickPadding(options.tickPadding)\n .tickValues(this._domain);\n\n if (this.options.xAxis.tickValues != null) {\n axis.tickValues(this.options.xAxis.tickValues);\n } else if (this.options.xAxis.maxTicks != null && this.options.xAxis.maxTicks < this._domain.length) {\n // override the tickValues with custom array based on number of ticks\n // we don't use D3 ticks() because you cannot force it to show a specific number of ticks\n axis.tickValues(_.nw.maxTickValues(options.maxTicks, this._domain));\n\n } else if (this.options.xAxis.firstAndLast) {\n // show only first and last tick\n axis.tickValues(_.nw.firstAndLast(this._domain));\n }\n\n return axis;\n },\n\n update: function (domain, data) {\n this.data = data;\n this.setDomain(domain);\n this.scale();\n },\n\n setDomain: function (domain) {\n this._domain = domain;\n var axisDomain = this._getAxisDomain(this._domain);\n this._scale.domain(axisDomain);\n },\n\n postProcessAxis: function (axisGroup) {\n if (!this.options.xAxis.firstAndLast) return;\n var labels = axisGroup.selectAll('.tick text')[0];\n d3.select(labels[0]).style({'text-anchor': 'start'});\n d3.select(labels[labels.length - 1]).style({'text-anchor': 'end'});\n },\n\n rangeBand: function () {\n return 4;\n },\n\n getOptimalTickFormat: function () {\n if (this.options.xAxis.labels.formatter) return this.options.xAxis.labels.formatter;\n if (this.options.xAxis.labels.format) return d3.time.format(this.options.xAxis.labels.format);\n\n var spanDays = Math.abs(dateDiff(this._domain[this._domain.length-1], this._domain[0]));\n var daysThreshold = this.options.xAxis.maxTicks || 1;\n if (spanDays < daysThreshold) return d3.time.format('%H:%M');\n if (spanDays < 365) return d3.time.format('%d %b');\n\n return d3.time.format('%Y');\n },\n\n range: function () {\n var range = this._getAxisRange(this._domain);\n return this._scale.rangeRound(range, 0.1);\n },\n\n\n _getAxisDomain: function (domain) {\n if(this.options.xAxis.linearDomain) {\n return domain;\n }\n\n return d3.extent(domain);\n },\n\n _getAxisRange: function (domain) {\n var size = this.options.chart.rotatedFrame ? this.options.chart.plotHeight : this.options.chart.plotWidth;\n\n if(this.options.xAxis.linearDomain) {\n return _.range(0, size, size / (domain.length - 1)).concat([size]);\n }\n\n return [0, size];\n }\n };\n\n _.nw.addAxis('TimeScale', TimeScale );\n})();\n","(function () {\n\n var defaults = {\n chart: {\n rotatedFrame: true,\n },\n\n xAxis: {\n orient: 'left'\n },\n\n yAxis: {\n orient: 'bottom'\n }\n };\n\n var frame = {\n\n init: function () {\n _.merge(this.options, defaults);\n },\n\n adjustPadding: function () {\n var categoryLabels = this.options.xAxis.categories || _.map(this.dataSrc, 'x');\n var text = categoryLabels.join('
');\n var xLabel = _.nw.textBounds(text, '.x.axis');\n var yLabel = _.nw.textBounds('ABC', '.y.axis');\n var maxTickSize = function (options) { return Math.max(options.outerTickSize, options.innerTickSize); };\n\n this.options.chart.internalPadding.left = this.options.chart.padding.left || maxTickSize(this.options.xAxis) + this.options.xAxis.tickPadding + xLabel.width;\n this.options.chart.internalPadding.bottom = this.options.chart.padding.bottom || maxTickSize(this.options.yAxis) + this.options.yAxis.tickPadding + yLabel.height;\n },\n\n adjustTitlePadding: function () {\n var titleBounds;\n if (this.options.xAxis.title || this.options.yAxis.title) {\n if(this.options.xAxis.title) {\n titleBounds = _.nw.textBounds(this.options.xAxis.title, '.x.axis-title');\n this.options.chart.internalPadding.left += titleBounds.height + this.options.xAxis.titlePadding;\n }\n\n if(this.options.yAxis.title) {\n titleBounds = _.nw.textBounds(this.options.yAxis.title, '.y.axis-title');\n this.options.chart.internalPadding.bottom += titleBounds.height + this.options.yAxis.titlePadding;\n }\n }\n },\n\n renderYAxis: function () {\n var yAxis = this.yAxis();\n var x = this.options.chart.internalPadding.left;\n var y = this.options.chart.padding.top + this.options.chart.plotHeight;\n\n this._yAxisGroup = this.svg.selectAll('.y.axis')\n .data([1]);\n\n this._yAxisGroup.enter().append('g')\n .attr('class', 'y axis')\n .attr('transform', 'translate(' + x+ ',' + y + ')');\n\n this._yAxisGroup.exit().remove();\n\n this._yAxisGroup\n .transition().duration(this._animationDuration())\n .attr('transform', 'translate(' + x+ ',' + y + ')')\n .call(yAxis);\n\n return this;\n },\n\n renderXAxis: function () {\n var x = this.options.chart.internalPadding.left;\n var y = this.options.chart.padding.top;\n var xAxis = this.xAxis();\n\n this._xAxisGroup = this.svg.selectAll('.x.axis')\n .data([1]);\n\n this._xAxisGroup.enter().append('g')\n .attr('class', 'x axis')\n .attr('transform', 'translate(' + x + ',' + y + ')');\n\n this._xAxisGroup.exit().remove();\n\n this._xAxisGroup\n .transition().duration(this._animationDuration())\n .attr('transform', 'translate(' + x + ',' + y + ')')\n .call(xAxis);\n\n this.xScaleGenerator.postProcessAxis(this._xAxisGroup);\n\n return this;\n },\n\n renderAxisLabels: function () {\n var lineHeightAdjustment = this.titleOneEm * 0.25; // add 25% of font-size for a complete line-height\n var adjustFactor = 40/46.609;\n var el;\n var bounds, anchor, rotation, tickSize, x, y;\n\n if (this.options.xAxis.title) {\n bounds = _.nw.textBounds(this.options.xAxis.title, '.x.axis-title');\n x = this.options.chart.rotatedFrame ? -bounds.height : this.options.chart.plotWidth;\n y = this.options.chart.rotatedFrame ? -this.options.chart.internalPadding.left : this.options.chart.internalPadding.bottom - lineHeightAdjustment;\n\n rotation = this.options.chart.rotatedFrame ? '-90' : '0';\n el = this._xAxisGroup.selectAll('.x.axis-title').data([null]);\n\n el.enter().append('text')\n .attr('class', 'x axis-title');\n\n el.attr('x', 0)\n .attr('y', y)\n .attr('transform', ['rotate(', rotation, ')'].join(''))\n .attr('dy', bounds.height * adjustFactor)\n .attr('dx', -(this.options.chart.plotHeight + bounds.width) / 2)\n .text(this.options.xAxis.title);\n\n el.exit().remove();\n }\n\n if (this.options.yAxis.title) {\n bounds = _.nw.textBounds(this.options.yAxis.title, '.y.axis-title');\n tickSize = Math.max(this.options.yAxis.innerTickSize, this.options.yAxis.outerTickSize);\n anchor = this.options.chart.rotatedFrame ? 'end' : 'middle';\n x = this.options.chart.rotatedFrame ? this.options.chart.plotWidth : 0;\n y = this.options.chart.rotatedFrame ?\n this.options.chart.internalPadding.bottom:\n -this.options.chart.internalPadding.left + this.titleOneEm - lineHeightAdjustment;\n\n rotation = this.options.chart.rotatedFrame ? '0' : '-90';\n\n el = this._yAxisGroup.selectAll('.y.axis-title').data([null]);\n\n el.enter().append('text')\n .attr('class', 'y axis-title');\n\n el.attr('y', y)\n .attr('x', x)\n .attr('dx', -(this.options.chart.plotWidth + bounds.width) / 2)\n .attr('dy', -4) // just because\n .attr('transform', ['rotate(', rotation, ')'].join(''))\n .text(this.options.yAxis.title);\n\n el.exit().remove();\n }\n\n return this;\n }\n };\n\n /**\n * Sets the visualization frame so that the xAxis is vertical and the yAxis is horizontal.\n *\n * This visualization requires `.cartesian()`.\n *\n * This visualization is a prerequiste for rendering bar charts (`.bar()`).\n *\n * ###Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .horizontal()\n * .bar([1, 2, 3, 4, 5, 4, 3, 2, 1])\n * .render()\n *\n * @function horiztonal\n */\n\n Contour.expose('horizontal', frame);\n\n})();\n","(function () {\n\n var _extent = function (series, field) {\n var maxs = [], mins = [];\n _.each(series, function (d) {\n if(!d.data.length) return;\n var values = _.map(d.data, field);\n maxs.push(d3.max(values));\n mins.push(d3.min(values));\n });\n\n //\n if(!mins.length || !maxs.length) return [];\n\n return [_.min(mins), _.max(maxs)];\n };\n\n\n /*jshint eqnull:true */\n var _stackedExtent = function (data) {\n var stack = _.nw.stackLayout();\n var dataSets = stack(data);\n var ext = [];\n _.each(dataSets, function (set) {\n _.each(set.data, function (d, i) {\n var cur = ext[i] || 0;\n ext[i] = cur + d.y;\n });\n });\n\n return [_.min(ext), _.max(ext)];\n };\n\n var _xExtent = _.partialRight(_extent, 'x');\n var _yExtent = _.partialRight(_extent, 'y');\n\n function VisInstanceContainer(data, categories, options, type, renderer, context) {\n this.type = type;\n this.renderer = renderer;\n this.ctx = context;\n this.categories = categories;\n\n this.init(data, options);\n }\n\n VisInstanceContainer.prototype = {\n\n init: function (data, options) {\n // set the options first and then the data\n this.setOptions(options);\n this.setData(data);\n },\n\n render: function (layer, options) {\n this.renderer.call(this.ctx, this.data, layer, options);\n\n return this.ctx;\n },\n\n setData: function (data) {\n var normalizeData = (this.ctx || {}).dataNormalizer || _.nw.normalizeSeries;\n this.data = normalizeData(data, this.categories);\n this._updateDomain();\n\n return this.ctx;\n },\n\n setOptions: function (options) {\n var opt = {};\n opt[this.type] = options || {};\n this.options = {};\n this.options = _.merge({}, (this.renderer || {}).defaults || {}, opt);\n\n return this.ctx;\n },\n\n _updateDomain: function () {\n if(!this.options[this.type]) throw new Error('Set the options before calling setData or _updateDomain');\n\n var isSupportedFormat = (this.ctx || {}).isSupportedDataFormat || _.nw.isSupportedDataFormat;\n\n if (isSupportedFormat(this.data)) {\n this.xDomain = _.flatten(_.map(this.data, function (set) { return _.map(set.data, 'x'); }));\n this.xExtent = _xExtent(this.data, 'x');\n this.yExtent = this.options[this.type].stacked ? _stackedExtent(this.data) : _yExtent(this.data);\n }\n }\n\n };\n\n Contour.VisualizationContainer = VisInstanceContainer;\n\n})();\n","(function () {\n\n var defaults = {\n xAxis: {\n type: 'linear'\n },\n area: {\n stacked: true,\n areaBase: undefined,\n preprocess: _.nw.minMaxFilter(1000)\n }\n };\n\n /* jshint eqnull:true */\n function renderer(data, layer, options) {\n this.checkDependencies('cartesian');\n var duration = options.chart.animations.duration != null ? options.chart.animations.duration : 400;\n var x = _.bind(function (val) { return this.xScale(val) + this.rangeBand / 2 + 0.5; }, this);\n var y = _.bind(function (val) { return this.yScale(val) + 0.5; }, this);\n var h = options.chart.plotHeight;\n var classFn = function (d, i) { return 'series s-' + (i+1) + ' ' + d.name; };\n var stack = d3.layout.stack().values(function (d) { return d.data; });\n\n var startArea = d3.svg.area()\n .x(function(d) { return x(d.x); })\n .y0(function (d) { return h; })\n .y1(function(d) { return h; });\n\n var areaBase = options.area.areaBase != null ? options.area.areaBase : options.yAxis.min;\n var area = d3.svg.area()\n .x(function(d) { return x(d.x); })\n .y0(function (d) { return options.area.stacked ? y(d.y0 || areaBase || 0) : y(0); })\n .y1(function(d) { return y((options.area.stacked ? d.y0 : 0) + d.y); });\n\n if(options.area.smooth) {\n area.interpolate('cardinal');\n startArea.interpolate('cardinal');\n }\n\n renderSeries();\n\n if (options.tooltip && options.tooltip.enable)\n renderTooltipTrackers();\n\n function renderSeries() {\n data = options.area.preprocess(data);\n\n var series = layer.selectAll('g.series')\n .data(stack(data));\n\n series.enter()\n .append('svg:g')\n .attr('class', classFn)\n .append('path').datum(function (d) { return d.data; })\n .attr('class', 'area')\n .attr('d', startArea);\n\n series.exit().remove();\n\n if (options.chart.animations && options.chart.animations.enable) {\n series.select('.area')\n .datum(function (d) { return d.data; })\n .transition().duration(options.chart.animations.duration || duration)\n .attr('d', area);\n } else {\n series.select('.area')\n .datum(function (d) { return d.data; })\n .attr('d', area);\n }\n }\n\n function renderTooltipTrackers() {\n var trackerSize = 10;\n // add the tooltip trackers regardless\n var markers = layer.selectAll('.tooltip-trackers')\n .data(data, function (d) { return d.name; });\n\n markers.enter().append('g')\n .attr('class', 'tooltip-trackers');\n\n markers.exit().remove();\n\n var blocks = markers.selectAll('.tooltip-tracker')\n .data(function (d) {\n return d.data;\n }, function (d, i) {\n return [d.x,d.y,d.y0].join('&');\n });\n\n blocks.enter().append('rect')\n .attr('class', 'tooltip-tracker')\n .attr('opacity', 0)\n .attr('width', trackerSize * 2);\n\n blocks.attr('x', function(d) { return x(d.x) - trackerSize; })\n .attr('y', function(d) { return y((options.area.stacked ? d.y0 : 0) + d.y); })\n .attr('height', function(d) { return y(0) - y(d.y); });\n\n blocks.exit().remove();\n\n }\n }\n\n renderer.defaults = defaults;\n\n /**\n * Adds an area chart to the Contour instance.\n *\n * Area charts are stacked by default when the _data_ includes multiple series.\n *\n * This visualization requires `.cartesian()`.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .area([1,2,3,4])\n * .render();\n *\n * @name area(data, options)\n * @param {object|array} data The _data series_ to be rendered with this visualization. This can be in any of the supported formats.\n * @param {object} [options] Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n */\n Contour.export('area', renderer);\n\n})();\n","(function () {\n /*jshint eqnull:true*/\n var defaults = {\n bar: {\n barClass: null,\n style: null,\n stacked: false,\n groupPadding: 2, // two px between same group bars\n barWidth: function() { return this.rangeBand; },\n offset: function() { return 0; },\n preprocess: function(data) {\n return data;\n }\n }\n };\n\n function barRender(data, layer, options) {\n this.checkDependencies(['cartesian', 'horizontal']);\n var duration = options.chart.animations.duration != null ? options.chart.animations.duration : 400;\n var _this = this;\n var opt = options.bar;\n var rectClass = opt.barClass;\n var style = opt.style;\n var x = function (d) { return _this.xScale(d) - 0.5; };\n var y = function (d) { return _this.yScale(d) + 0.5; };\n var chartOffset = _.nw.getValue(opt.offset, 0, this);\n var rangeBand = _.nw.getValue(opt.barWidth, this.rangeBand, this);\n var stack = _.nw.stackLayout();\n var update = options.bar.stacked ? stacked : grouped;\n var enter = _.partialRight(update, true);\n var classFn = function (d, i) { return 'series s-' + (i+1) + ' ' + d.name; };\n\n data = options.bar.preprocess(data);\n var series = layer.selectAll('g.series')\n .data(stack(data));\n\n series.enter().append('svg:g')\n .attr('class', classFn);\n\n series.exit().remove();\n\n var bars = series.selectAll('.bar')\n .data(function (d) { return d.data; });\n\n var cssClass = 'bar' + (options.tooltip.enable ? ' tooltip-tracker' : '');\n bars.enter().append('rect')\n .attr('class', function (d, i, j) {\n if (!rectClass) return cssClass;\n\n return cssClass + ' ' + (typeof rectClass === 'function' ? rectClass.call(this, d, i, j) : rectClass);\n })\n .call(enter);\n\n if(options.chart.animations && options.chart.animations.enable) {\n bars\n .attr('style', style)\n .transition().duration(duration).call(update);\n bars.exit()\n .transition().duration(duration)\n .attr('width', y(0))\n .remove();\n } else {\n bars.attr('style', style).call(update);\n bars.exit().remove();\n }\n\n function stacked(bar, enter) {\n bar\n .attr('y', function (d) { return x(d.x) + chartOffset; })\n .attr('height', rangeBand);\n\n if (enter) {\n return bar\n .attr('x', function (d) { return y(0); })\n .attr('width', function (d) { return 0; });\n\n } else {\n return bar\n .attr('x', function (d) { return d.y >= 0 ? y(d.y0 || 0) : y(d.y + d.y0); })\n .attr('width', function (d) { return d.y >=0 ? y(d.y) - y(0) : y(0) - y(d.y); });\n }\n }\n\n function grouped(bar, enter) {\n var numSeries = data.length;\n var height = function () { return rangeBand / numSeries - options.bar.groupPadding + 0.5; };\n var offset = function (d, i) { return rangeBand / numSeries * i + 0.5; };\n\n bar.attr('y', function (d, i, j) { return x(d.x) + offset(d, j) + chartOffset; })\n .attr('x', y(0))\n .attr('height', height);\n\n if (enter) {\n return bar\n .attr('width', function (d) { return 0.5; });\n } else {\n return bar\n .attr('width', function (d) { return d.y >= 0 ? y(d.y) - y(0) : y(0) - y(d.y); })\n .attr('x', function (d) { return d.y < 0 ? y(d.y) : y(0); });\n }\n }\n }\n\n barRender.defaults = defaults;\n /**\n * Adds a bar chart (horizontal columns) to the Contour instance.\n *\n * You can use this visualization to render both stacked and grouped charts (controlled through the _options_).\n *\n * This visualization requires `.cartesian()` and `.horizontal()`.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .horizontal()\n * .bar([1,2,3,4])\n * .render();\n *\n * @name bar(data, options)\n * @param {object|array} data The _data series_ to be rendered with this visualization. This can be in any of the supported formats.\n * @param {object} [options] Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n */\n Contour.export('bar', barRender);\n\n})();\n","(function () {\n\n var defaults = {\n column : {\n // specifies a class string or function that will be added to each column\n columnClass: null,\n style: null,\n stacked: false,\n groupPadding: 1,\n columnWidth: function() { return this.rangeBand; },\n offset: function() { return 0; }\n }\n };\n\n function render(data, layer, options) {\n this.checkDependencies('cartesian');\n var duration = options.chart.animations.duration != null ? options.chart.animations.duration : 400;\n var opt = options.column;\n var h = options.chart.plotHeight;\n var rectClass = options.column.columnClass;\n var rectStyle = options.column.style;\n var _this = this;\n var x = function (v) { return Math.round(_this.xScale(v)) + 0.5; };\n var y = function (v) { return Math.round(_this.yScale(v)) - 0.5; };\n var dataKey = function (d) { return d.data; };\n var chartOffset = _.nw.getValue(opt.offset, 0, this);\n var rangeBand = _.nw.getValue(opt.columnWidth, this.rangeBand, this);\n var enter = _.partialRight((options.column.stacked ? stacked : grouped), true);\n var update = options.column.stacked ? stacked : grouped;\n var filteredData = _.map(data, function (series, j) {\n return {\n name: series.name,\n data: _.filter(series.data, function (d, i) {\n return i === 0 ? true : x(d.x) !== x(series.data[i-1].x);\n })\n };\n });\n\n var stack = _.nw.stackLayout();\n var series = layer.selectAll('g.series')\n .data(stack(filteredData));\n\n series.enter()\n .append('g')\n .attr('class', function (d, i) { return 'series s-' + (i+1) + ' ' + d.name; });\n\n series.exit()\n .remove();\n\n var cols = series.selectAll('.column')\n .data(dataKey, function (d) { return d.x || d; });\n\n var cssClass = 'column' + (options.tooltip.enable ? ' tooltip-tracker' : '');\n\n cols.enter()\n .append('rect')\n .attr('class', function (d, i, j) {\n if (!rectClass) return cssClass;\n\n return cssClass + ' ' + (typeof rectClass === 'function' ? rectClass.call(this, d, i, j) : rectClass);\n })\n .call(enter);\n\n if (options.chart.animations && options.chart.animations.enable) {\n cols.exit()\n .transition().duration(duration)\n .attr('y', h)\n .attr('height', function () { return 0.5; })\n .remove();\n cols.transition().duration(duration)\n .call(update);\n } else {\n cols.exit().remove();\n cols.call(update);\n }\n\n // for every update\n cols.attr('style', rectStyle);\n\n function stacked(col, enter) {\n var base = y(0);\n\n col.attr('x', function (d) { return x(d.x) + chartOffset; })\n .attr('width', function () { return rangeBand; });\n\n if (enter) {\n col.attr('y', function (d) { return d.y >= 0 ? base : base; })\n .attr('height', function (d) { return 0.5; });\n } else {\n col.attr('y', function (d) { return d.y >= 0 ? y(d.y) + y(d.y0) - base : y(d.y0) ; })\n .attr('height', function (d) { return d.y >=0 ? base - y(d.y) : y(d.y) - base; });\n }\n }\n\n function grouped(col, enter) {\n var width = rangeBand / data.length - opt.groupPadding + 0.5;\n var offset = function (d, i) { return rangeBand / data.length * i + 0.5; };\n var base = y(0);\n\n col.attr('x', function (d, i, j) { return x(d.x) + offset(d, j) + chartOffset; })\n .attr('width', width);\n\n if (enter) {\n col.attr('y', base)\n .attr('height', 0);\n } else {\n col.attr('y', function (d) { return d.y >= 0 ? y(d.y) : base; })\n .attr('height', function (d) { return d.y >= 0 ? base - y(d.y) : y(d.y) - base; });\n }\n }\n }\n\n render.defaults = defaults;\n\n /**\n * Adds a column chart (vertical columns) to the Contour instance.\n *\n * This visualization requires `.cartesian()`.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .column([1,2,3,4])\n * .render();\n *\n * @name column(data, options)\n * @param {object|array} data The _data series_ to be rendered with this visualization. This can be in any of the supported formats.\n * @param {object} [options] Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n */\n Contour.export('column', render);\n\n})();\n","(function () {\n\n Contour.export('coolNarwhal', function (data, layer) {\n layer.append('path')\n .attr('class', 'cool')\n .attr('opacity', 0)\n .attr('transform', 'scale(.5) translate(500 150)')\n .attr('d', 'M-220.02,76.509l-0.78,8.927c-0.956,10.949,1.389,20.422,6.188,30.383c10.203,21.173,63.095,84.05,93.72,115.075c20.145,20.406,19.487,23.018,21.549,40.122c2.487,20.621,24.897,66.462,40.838,71.269 c15.086,4.549,12.91-12.398,13.319-37.83c5.746,2.457,10.917,5.638,20.206,12.697c61.697,46.892,139.734,69.97,206.5,71.733c46.209,1.221,81.432-7.081,142.957-33.694c40.484-17.512,54.271-22.098,65.639-21.504c4.432,0.232,22.678,11.204,41.746,21.563c35.398,19.229,69.457,34.595,75.896,34.239c12.609-1.457-0.701-11.783-8.072-24.217c-7.049-11.892-15.414-29.572-18.844-42.134s-4.723-22.272-8.91-27.091c-2.143-2.463-12.812-6.786-21.189-8.146c-18.045-2.933-22.191-2.922-13.531-8.957c13.076-9.115,17.377-11.039,1.826-29.068c-6.383-7.402-11.336-20.003-13.709-39.542c-1.607-13.237,1.057-23.679-3.869-27.451s-17.271,12.341-20.846,19.334c-2.01,3.937-7.102,19.005-11.312,33.485c-13.795,47.427-29.865,65.742-62.693,71.447c-34.361,5.971-71.623-9.506-116.543-48.404c-13.164-11.399-29.533-25.26-39.254-36.913c-13.428-16.101-15.48-18.138-19.785-20.66c-16.166-9.472-54.98-31.694-103.525-63.815c-24.393-16.141-57.72-36.928-71.453-43.693c-27.236-13.417-68.416-28.952-90.731-46.771c-24.665-19.697-38.108-19.793-67.804-5.479c-21.429,10.328-23.941,15.298-26.52,15.726c-8.216-10.129-22.917-11.198-31.647-20.682c-9.529-10.35-28.027-14.098-37.824-24.957c-10.668-11.826-31.25-16.752-40.886-26.94c-11.339-11.989-29.387-16.096-40.838-26.637c-11.617-10.694-27.159-14.843-37.68-24.045c-10.383-9.082-23.187-12.538-31.408-19.163c-8.193-6.601-16.593-9.444-22.026-11.993c-5.433-2.549-7.398-2.522-7.658-1.927c-0.26,0.594,1.355,2.955,6.054,6.447c4.699,3.491,22.193,18.451,31.645,22.77c10.921,5.104,17.502,15.01,29.671,21.375c13.224,6.918,22.212,18.731,36.229,25.924c15.53,7.971,24.754,21.184,39.657,28.253c16.462,7.808,25.503,21.598,39.958,28.36c14.499,6.78,20.647,20.252,34.429,23.428C-238.033,58.207-227.932,70.443-220.02,76.509L-220.02,76.509z')\n .transition()\n .delay(300)\n .duration(2000)\n .attr('opacity', 1);\n });\n\n})();\n","(function () {\n\n var defaults = {\n legend: {\n vAlign: 'middle',\n hAlign: 'right',\n direction: 'vertical',\n formatter: function (d) {\n return d.name;\n },\n el: undefined\n }\n };\n\n function validAlignmentClasses(options) {\n var classes = [];\n if (['top', 'middle', 'bottom'].indexOf(options.legend.vAlign) !== -1) {\n classes.push(options.legend.vAlign);\n } else {\n classes.push('top');\n }\n\n if (['left', 'center', 'right'].indexOf(options.legend.hAlign) !== -1) {\n classes.push(options.legend.hAlign);\n } else {\n classes.push('right');\n }\n\n if (options.legend.direction === 'vertical') {\n classes.push('vertical');\n }\n\n return classes;\n }\n\n function Legend(data, layer, options) {\n var container;\n if (options.legend.el) {\n container = d3.select(options.legend.el).node();\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n } else {\n this.container.selectAll('.contour-legend').remove();\n }\n var em = _.nw.textBounds('series', '.contour-legend.contour-legend-entry');\n var count = data.length;\n var legendHeight = (em.height + 4) * count + 12; // legend has 1px border and 5px margin (12px) and each entry has ~2px margin\n var mid = (options.chart.plotHeight - legendHeight) / 2;\n var positioner = function (selection) {\n // adjust position of legend only when is horizontally centered\n // since we need to have all elements in the legend to calculate its width\n if (options.legend.hAlign !== 'center' || !selection.length) {\n return ;\n }\n\n // adjust the left\n var legendWidth = selection[0].parentNode.clientWidth;\n var left = (options.chart.plotWidth - legendWidth) / 2 + options.chart.internalPadding.left;\n\n d3.select(selection[0].parentNode)\n .style('left', left + 'px');\n };\n\n if (options.legend.el) {\n container = d3.select(options.legend.el);\n } else {\n var legend = this.container.selectAll('.contour-legend').data([null]);\n container = legend.enter().append('div');\n }\n\n container.attr('class', function () {\n return ['contour-legend'].concat(validAlignmentClasses(options)).join(' ');\n });\n\n container.attr('style', function () {\n var styles = [];\n\n if (options.legend.vAlign === 'top') {\n styles.push('top: 0');\n } else if (options.legend.vAlign === 'middle') {\n styles.push('top: ' + mid + 'px');\n } else {\n styles.push('bottom: ' + (options.chart.internalPadding.bottom + 5) + 'px');\n }\n\n if (options.legend.hAlign === 'left') {\n styles.push('left: ' + options.chart.plotLeft + 'px');\n } else if (options.legend.hAlign === 'center') {\n var bounds = _.nw.textBounds(this, '.contour-legend');\n\n styles.push('left: ' + ((options.chart.plotWidth - bounds.width) / 2 + options.chart.internalPadding.left) + 'px' );\n } else {\n styles.push('right: 10px');\n }\n\n return styles.join(';');\n });\n\n var entries = container.selectAll('.contour-legend-entry')\n .data(data);\n\n entries.enter()\n .append('div')\n .attr('class', function () {\n return 'contour-legend-entry';\n });\n\n entries.append('span')\n .attr('class', function (d, i) { return 'contour-legend-key series s-' + (i+1) + ' ' + _.nw.seriesNameToClass(d.name); });\n\n entries.append('span')\n .attr('class', 'series-name')\n .text(options.legend.formatter)\n .call(positioner);\n\n entries.exit()\n .remove();\n }\n\n Legend.defaults = defaults;\n\n /**\n * Adds a legend to the Contour instance. One entry is added to the legend for each series in the data.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .column(data)\n * .legend(data)\n * .render();\n *\n * @name legend(data, options)\n * @param {object|array} data The _data series_ for which to create a legend. This can be in any of the supported formats.\n * @param {object} [options] Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n */\n\n Contour.export('legend', Legend);\n\n})();\n","(function () {\n\n var defaults = {\n xAxis: {\n type: 'linear'\n },\n line: {\n stacked: false,\n smooth: false,\n animationDirection: 'left-to-right',\n // animationDirection: 'bottom-to-top',\n marker: {\n enable: true,\n size: 3,\n animationDelay: null\n },\n preprocess: _.nw.minMaxFilter(1000)\n }\n };\n\n var duration;\n var animationDirection;\n var animationsMap = {\n 'left-to-right': {\n enter: function (line) {\n var path = this;\n path.each(function () {\n var totalLength = this.getTotalLength();\n d3.select(this)\n .attr('stroke-dasharray', totalLength + ' ' + totalLength)\n .attr('stroke-dashoffset', totalLength)\n .transition().duration(duration).ease('linear')\n .attr('stroke-dashoffset', 0)\n .transition().duration(0)\n .attr('stroke-dasharray', undefined);\n });\n },\n\n update: function (line) {\n this.attr('d', function (d) { return line(d.data); });\n this.each(function () {\n var totalLength = this.getTotalLength();\n d3.select(this)\n .attr('stroke-dasharray', totalLength + ' ' + totalLength)\n .attr('stroke-dashoffset', totalLength)\n .transition().duration(duration).ease('linear')\n .attr('stroke-dashoffset', 0)\n .transition().duration(0)\n .attr('stroke-dasharray', undefined);\n });\n }\n },\n\n 'bottom-to-top': {\n enter: function (line) {\n this.transition().duration(duration)\n .attr('d', function (d) { return line(d.data); });\n },\n\n update: function (line) {\n this.transition().duration(duration)\n .attr('d', function (d) { return line(d.data); });\n }\n }\n };\n\n\n /* jshint eqnull: true */\n function render(rawData, layer, options, id) {\n this.checkDependencies('cartesian');\n\n var x = _.bind(function (d) { return this.xScale(d.x) + this.rangeBand / 2 + 0.5; }, this);\n var y = _.bind(function (d) { return this.yScale(d.y + (d.y0 || 0)) + 0.5; }, this);\n var shouldAnimate = options.chart.animations && options.chart.animations.enable;\n animationDirection = options.line.animationDirection || 'left-to-right';\n duration = options.chart.animations.duration != null ? options.chart.animations.duration : 400;\n // jshint eqnull:true\n var data = options.line.preprocess(_.nw.cleanNullValues()(rawData));\n\n data = options.line.stacked ? d3.layout.stack().values(function (d) { return d.data; })(data) : data;\n\n renderPaths();\n\n if (options.line.marker.enable)\n renderMarkers();\n\n if (options.tooltip && options.tooltip.enable)\n renderTooltipTrackers();\n\n function seriesClassName(extras) { return function (d, i) { return (extras||'') + ' s-' +(i+1) + ' ' + _.nw.seriesNameToClass(d.name); }; }\n\n function renderPaths() {\n var startLine = d3.svg.line()\n .x(function (d) { return x(d); })\n .y(function () { return y({x: 0, y: options.yAxis.min || 0}); });\n\n var line = d3.svg.line()\n .x(function (d) { return x(d); })\n .y(function (d) { return y(d); });\n\n if(options.line.smooth) line.interpolate('cardinal');\n\n var animFn = animationsMap[animationDirection];\n var series = layer.selectAll('g.series')\n .data(data, function (d) { return d.name; });\n\n // enter\n var el = series.enter().append('svg:g')\n .attr('class',seriesClassName('series'))\n .append('path')\n .attr('class', 'line');\n\n if (shouldAnimate) {\n var startLineFn = animationDirection === 'left-to-right' ? line : startLine;\n el.attr('d', function(d) { return startLineFn(d.data); })\n .call(_.partial(animFn.enter, line));\n } else {\n el.attr('d', function (d) { return line(d.data); });\n }\n\n // update\n el = series\n .attr('class', seriesClassName('series'))\n .select('.line');\n\n if (shouldAnimate) {\n el.call(_.partial(animFn.update, line));\n } else {\n el.attr('d', function (d) { return line(d.data); });\n }\n\n // remove\n if (shouldAnimate) {\n series.exit()\n .remove();\n } else {\n series.exit().remove();\n }\n }\n\n function renderMarkers() {\n var animationDelay = (options.line.marker.animationDelay == null) ? duration : options.line.marker.animationDelay;\n var markers = layer.selectAll('.line-chart-markers')\n .data(data, function (d) { return d.name; });\n\n markers.enter().append('g')\n .attr('class', seriesClassName('line-chart-markers markers'));\n\n markers.exit().remove();\n\n var dots = markers.selectAll('.dot')\n .data(function (d) { return d.data; }, function (d) { return d.x; });\n\n if (shouldAnimate) {\n dots.transition().delay(animationDelay).duration(duration)\n .attr('cx', x)\n .attr('cy', y)\n .attr('opacity', 1);\n } else {\n dots.attr('cx', x)\n .attr('cy', y)\n .attr('opacity', 1);\n }\n\n\n dots.enter().append('circle')\n .attr('class', 'dot')\n .attr('r', options.line.marker.size)\n .attr('opacity', 0)\n .attr('cx', x)\n .attr('cy', y)\n .transition().delay(animationDelay)\n .attr('opacity', 1);\n\n dots.exit().remove();\n\n }\n\n function renderTooltipTrackers() {\n var trackerSize = 10;\n var markers = layer.selectAll('.tooltip-trackers')\n .data(data, function (d) { return d.name; });\n\n markers.enter().append('g')\n .attr('class', seriesClassName('tooltip-trackers'));\n\n markers.exit().remove();\n\n var dots = markers.selectAll('.tooltip-tracker')\n .data(function (d) { return d.data; }, function (d) { return d.x; });\n\n dots.enter().append('circle')\n .attr({\n 'class': 'tooltip-tracker',\n 'r': trackerSize,\n 'opacity': 0\n });\n\n dots.attr({\n 'cx': x,\n 'cy': y\n });\n\n dots.exit().remove();\n }\n\n return this;\n }\n\n render.defaults = defaults;\n\n\n /**\n * Adds a line chart to the Contour instance.\n *\n * This visualization requires `.cartesian()`.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .line([1,2,3,4])\n * .render();\n *\n * @name line(data, options)\n * @param {object|array} data The _data series_ to be rendered with this visualization. This can be in any of the supported formats.\n * @param {object} [options] Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n */\n Contour.export('line', render);\n\n})();\n","Contour.export('nullVis', _.noop);\n","(function () {\n\n var defaults = {\n pie: {\n sliceClass: null,\n\n style: null,\n\n piePadding: {\n left: null,\n top: null,\n right: null,\n bottom: null\n },\n\n // inner and outer radius can be numbers of pixels if >= 1, percentage if > 0 && < 1 or functions\n\n // inner radius as function will recive the outerRadius as parameter\n // passing a value between 0 and 1 (non-inclusing), this value is interpreted as % of radius\n // ie. outerRadius: 100, innerRadius: .8 would give a inner radius or 80 pixles\n innerRadius: null,\n\n // outer radius as function will recieve the proposed maximum radius for a pie\n // passing a value between 0 and 1 (non-inclusing), this value is interpreted as % of width\n // the default behavior is 50% of the mininum between with and height of the container (adjusted for padding)\n outerRadius: null\n }\n };\n\n function normalizePadding(options) {\n if (_.isNumber(options.pie.piePadding)) {\n return {\n top: options.pie.piePadding,\n left: options.pie.piePadding,\n right: options.pie.piePadding,\n bottom: options.pie.piePadding\n };\n }\n\n return options.pie.piePadding;\n }\n\n function clampBounds(bounds, maxWidth, maxHeight) {\n return {\n top: _.nw.clamp(bounds.top, 0, maxHeight),\n bottom: _.nw.clamp(bounds.bottom, 0, maxHeight),\n left: _.nw.clamp(bounds.left, 0, maxWidth),\n right: _.nw.clamp(bounds.right, 0, maxWidth)\n };\n }\n\n function calcPadding(options) {\n var padding = normalizePadding(options);\n var w = options.chart.plotWidth;\n var h = options.chart.plotHeight;\n\n return clampBounds(padding, w, h);\n }\n\n function resolveValueUnits(value, ref) {\n // resolve (0,1) interval to a percentage of the reference value\n // otherwise as a pixel valie\n return value > 0 && value < 1 ? ref * value : value;\n }\n\n function resolvePaddingUnits(padding, w, h) {\n // if the value of padding is betweem 0 and 1 (non inclusing),\n // interpret it as a percentage, otherwise as a pixel value\n return {\n top: resolveValueUnits(padding.top, h) || 5,\n bottom: resolveValueUnits(padding.bottom, h) || 5,\n left: resolveValueUnits(padding.left, w) || 5,\n right: resolveValueUnits(padding.right, w) || 5\n };\n }\n\n function renderer(data, layer, options) {\n /*jshint eqnull:true */\n var duration = options.chart.animations.duration != null ? options.chart.animations.duration : 400;\n var shouldAnimate = options.chart.animations && options.chart.animations.enable;\n var w = options.chart.plotWidth, h = options.chart.plotHeight;\n var padding = calcPadding.call(this, options);\n var numSeries = data.length;\n var style = options.pie.style;\n var _this = this;\n var shouldCenterX = _.every([options.pie.piePadding.left, options.pie.piePadding.right], function (d) { return d == null; });\n var shouldCenterY = _.every([options.pie.piePadding.top, options.pie.piePadding.bottom], function (d) { return d == null; });\n var pixelPadding = resolvePaddingUnits(padding, w, h);\n // the reference size is the min between with and height of the container\n var referenceSize = Math.min(w, h);\n\n // for auto radius we need to take the min between the available with or height adjusted by padding and num series\n var totalPadding = pixelPadding.left + (pixelPadding.right + pixelPadding.left) * (numSeries - 1) + pixelPadding.right;\n var proposedRadius = Math.min(((w - totalPadding) / numSeries) / 2, (h - pixelPadding.top - pixelPadding.bottom) / 2);\n var radius = resolveValueUnits(_.nw.getValue(options.pie.outerRadius, proposedRadius, this, proposedRadius, referenceSize), referenceSize);\n // inner radius is a pixel value or % of the radius\n var innerRadius = resolveValueUnits(_.nw.getValue(options.pie.innerRadius, 0, this, radius), radius);\n var pieData = d3.layout.pie().value(function (d) { return d.y; }).sort(null);\n var totalWidth = totalPadding + radius * numSeries * 2;\n var outerPaddingLeft = shouldCenterX ? (w - totalWidth) / 2 : pixelPadding.left;\n var centerY = h / 2;\n\n var classFn = function (d, i, j) {\n var baseClass = 'series arc' + (options.tooltip.enable ? ' tooltip-tracker' : '') + ' s-' + (i+1) + ' ' + d.data.x;\n\n if (!options.pie.sliceClass) {\n return baseClass;\n }\n\n return baseClass + ' ' + (typeof options.pie.sliceClass === 'function' ? options.pie.sliceClass.call(_this, d, i, j) : options.pie.sliceClass);\n };\n\n var translatePie = function (d,i) {\n // calc the left side coord of the pie, including padding for the prevousous pies\n var offsetX = outerPaddingLeft + (radius * 2 * i + (pixelPadding.right + pixelPadding.left) * i);\n // calc the center of the pie starting from offsetX\n var posY = shouldCenterY ? centerY : radius + pixelPadding.top;\n\n return 'translate(' + (radius + offsetX) + ',' + (posY) + ')';\n };\n\n var pieGroup = layer.selectAll('g.pie-group')\n .data(data);\n\n pieGroup.enter().append('svg:g')\n .attr('class', 'pie-group')\n .attr('transform', translatePie)\n .call(renderSeries);\n\n pieGroup.exit().remove();\n\n if (shouldAnimate) {\n pieGroup\n .call(renderSeries)\n .transition().duration(duration/2)\n .attr('transform', translatePie);\n } else {\n pieGroup.call(renderSeries)\n .attr('transform', translatePie);\n }\n\n function renderSeries(group) {\n var arc = d3.svg.arc()\n .outerRadius(radius).innerRadius(innerRadius);\n\n var startArc = d3.svg.arc()\n .outerRadius(radius).innerRadius(innerRadius)\n .startAngle(0).endAngle(0);\n\n var pie = group.selectAll('path')\n .data(function (d) { return pieData(d.data); }, function (d) { return d.data.x; });\n\n pie.enter()\n .append('path')\n .attr('class', classFn)\n .attr('d', function (d) { return startArc(d); })\n .attr('style', style)\n .each(function (d) { this._current = { startAngle: d.startAngle, endAngle: d.startAngle }; });\n\n\n if (shouldAnimate) {\n pie.exit()\n .remove();\n\n pie.transition().duration(duration)\n .ease('cubic-in')\n .attrTween('d', arcTween);\n } else {\n pie.exit().remove();\n pie.attr('d', arc);\n }\n\n // Store the displayed angles in _current.\n // Then, interpolate from _current to the new angles.\n // During the transition, _current is updated in-place by d3.interpolate.\n // from http://bl.ocks.org/mbostock/1346410\n function arcTween(a) {\n var i = d3.interpolate(this._current, a);\n this._current = i(0);\n return function(t) {\n return arc(i(t));\n };\n }\n }\n }\n\n renderer.defaults = defaults;\n\n\n /**\n * Adds a pie chart to the Contour instance.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .pie([1,2,3,4])\n * .render();\n *\n * @name pie(data, options)\n * @param {object|array} data The _data series_ to be rendered with this visualization. This can be in any of the supported formats. The data elements are summed and then divided. In the example, `.pie([1,2,3,4])` makes four pie slices: 1/10, 2/10, 3/10, and 4/10.\n * @param {object} [options] Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n */\n Contour.export('pie', renderer);\n\n})();\n","(function () {\n\n var defaults = {\n xAxis: {\n type: 'linear'\n },\n scatter: {\n radius: 4,\n preprocess: function(data) {\n return data;\n }\n }\n };\n\n function ScatterPlot(data, layer, options) {\n this.checkDependencies('cartesian');\n var duration = options.chart.animations.duration != null ? options.chart.animations.duration : 400;\n var shouldAnimate = options.chart.animations && options.chart.animations.enable;\n var opt = options.scatter;\n var halfRangeBand = this.rangeBand / 2;\n var x = _.bind(function (d) { return this.xScale(d.x) + halfRangeBand; }, this);\n var y = _.bind(function (d) { return this.yScale(d.y); }, this);\n var h = options.chart.plotHeight;\n var classFn = function (d, i) { return d.name + ' series s-' + (i+1); };\n\n data = options.scatter.preprocess(data);\n \n var series = layer.selectAll('.series')\n .data(data);\n\n series.attr('class', classFn);\n\n series.enter().append('svg:g')\n .attr('class', classFn);\n\n series.exit().remove();\n\n var dots = series.selectAll('.dot')\n .data(function (d) { return d.data; }, function (d) {\n return options.scatter.dataKey ? d[options.scatter.dataKey] : d.x;\n });\n\n dots.enter().append('circle')\n .attr('class', 'dot tooltip-tracker')\n .attr('r', opt.radius)\n .attr('cx', x)\n .attr('cy', h);\n\n if (shouldAnimate) {\n dots.transition().duration(duration)\n .attr('r', opt.radius)\n .attr('cx', x)\n .attr('cy', y);\n } else {\n dots.attr('r', opt.radius)\n .attr('cx', x)\n .attr('cy', y);\n }\n\n\n dots.exit().remove();\n }\n\n ScatterPlot.defaults = defaults;\n\n /**\n * Adds a scatter plot to the Contour instance.\n *\n * This visualization requires `.cartesian()`.\n *\n * ### Example:\n *\n * new Contour({el: '.chart'})\n * .cartesian()\n * .scatter([1,2,3,4])\n * .render();\n *\n * @name scatter(data, options)\n * @param {object|array} data The _data series_ to be rendered with this visualization. This can be in any of the supported formats.\n * @param {object} [options] Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n */\n Contour.export('scatter', ScatterPlot);\n\n\n})();\n","(function () {\n var defaults = {\n tooltip: {\n enable: true\n }\n };\n\n /**\n * Adds a tooltip and legend combination for stacked (multiple) series visualizations in the Contour instance.\n * Requires a second display element (`
`) for the legend in the html.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .column(stackedColData)\n * .stackTooltip(stackedColData, {el: '.myChartLegend'})\n * .render();\n *\n * @name stackTooltip(data, options)\n * @param {object|array} data The _data series_ to be rendered with this visualization. This can be in any of the supported formats.\n * @param {object} options Configuration options particular to this visualization that override the defaults. Requires an `el` option with the selector of the container in which to render the tooltip.\n * @api public\n *\n * ### Notes:\n *\n * Each Contour instance can only include one `stackTooltip` visualization.\n */\n function stackTooltip(data, layer, options) {\n\n var valueFormatter = this.yAxis().tickFormat();\n var tooltip = d3.select(options.stackTooltip.el);\n\n tooltip.classed('stack-tooltip', true);\n\n // jshint eqnull:true\n var onMouseOver = function (d) {\n var isNull = function (p) {\n return !(p && p.y != null);\n };\n var mapFn = function (p, i) {\n var index = _.isNumber(d.x) ? d.x : options.xAxis.categories.indexOf(d.x);\n return !isNull(p.data[index]) ?\n { seriesName: p.name, value: p.data[index].y, cssClass: 's-' + (i+1) } :\n null;\n };\n var filtered = _.filter(_.map(data, mapFn), function (x) { return x; });\n var text = _.map(filtered, function (t) { return '' + t.seriesName + ': ' + valueFormatter(t.value) + ''; }).join(' / ');\n tooltip.html(text).style({display: 'block'});\n };\n\n var onMouseOut = function (// datum\n ) {\n tooltip.html('');\n };\n\n this.svg.selectAll('.tooltip-tracker')\n .on('mouseover.tooltip', onMouseOver.bind(this))\n .on('mouseout.tooltip', onMouseOut.bind(this));\n }\n\n stackTooltip.defaults = defaults;\n\n Contour.export('stackTooltip', stackTooltip);\n\n})();\n","(function () {\n var defaults = {\n tooltip: {\n enable: true,\n animate: true,\n opacity: 0.85,\n showTime: 300,\n hideTime: 500,\n distance: 5,\n formatter: undefined //defined in formatters array in getTooltipText()\n }\n };\n\n function render(data, layer, options) {\n\n var clearHideTimer = function () {\n clearTimeout(this.tooltip.hideTimer);\n };\n\n var changeOpacity = function (opacity, delay) {\n if(this.options.tooltip.animate) {\n this.tooltipElement\n .transition().duration(delay)\n .style('opacity', opacity);\n } else {\n this.tooltipElement.style('opacity', opacity);\n }\n };\n\n var positionTooltip = function (d) {\n var pointOrCentroid = function () {\n return d3.event.target.tagName === 'path' ? _.nw.getCentroid(d3.event.target) : d3.mouse(this.container.node());\n };\n var xScale = this.xScale;\n var yScale = this.yScale;\n var plotLeft = this.options.chart.plotLeft;\n var plotWidth = this.options.chart.plotWidth;\n var plotTop = this.options.chart.plotTop;\n var plotHeight = this.options.chart.plotHeight;\n var distance = this.options.tooltip.distance;\n var width = parseFloat(this.tooltipElement.node().offsetWidth);\n var height = parseFloat(this.tooltipElement.node().offsetHeight);\n var pointX = xScale ? xScale(d.x) : pointOrCentroid.call(this)[0];\n var pointY = yScale ? yScale(d.y) : pointOrCentroid.call(this)[1];\n var alignedRight;\n\n var clampPosition = function (pos) {\n // Check outside plot area (left)\n if (pos.x < plotLeft) {\n pos.x = plotLeft + distance;\n }\n\n // Check outside plot area (right)\n if (pos.x + width > plotLeft + plotWidth) {\n pos.x -= (pos.x + width) - (plotLeft + plotWidth);\n // Don't overlap point\n pos.y = plotTop + pointY - (height + distance);\n alignedRight = true;\n }\n\n // Check outside the plot area (top)\n if (pos.y < plotTop) {\n pos.y = plotTop + distance;\n\n // Don't overlap point\n if (alignedRight && pointY >= pos.y && pointY <= pos.y + height) {\n pos.y = pointY + plotTop + distance;\n }\n }\n\n // Check outside the plot area (bottom)\n if (pos.y + height > plotTop + plotHeight) {\n pos.y = Math.max(plotTop, plotTop + plotHeight - (height + distance));\n }\n\n return pos;\n };\n\n var positioner = {\n 'vertical': function verticalPositioner() {\n var pos = {\n x: plotLeft + pointX - (distance + width),\n y: plotTop + pointY - (distance + height)\n };\n\n return clampPosition(pos);\n },\n\n 'horizontal': function horizontalPositioner() {\n var pos = {\n x: plotLeft + pointY - (distance + width),\n y: plotTop + pointX - (distance + height)\n };\n\n return clampPosition(pos);\n }\n };\n\n return options.chart.rotatedFrame ? positioner.horizontal() : positioner.vertical();\n\n };\n\n var onMouseOver = function (d) {\n show.call(this, d);\n };\n\n var onMouseOut = function () {\n changeOpacity.call(this, 0, this.options.tooltip.hideTime);\n };\n\n var getTooltipText = function (d, allPoints) {\n function match() {\n var params = Array.prototype.slice.call(arguments);\n var list = params[0];\n var rest = params.slice(1);\n\n var response = _.map(list, function(fn) { return fn.apply(this, rest); }).concat([_.noop]);\n\n return _.first(_.filter(response));\n }\n\n var options = this.options.tooltip;\n var formatters = [\n function (d) { return options.formatter ? _.partial(options.formatter, d, allPoints) : null; },\n function (d) { return d.hasOwnProperty('x') ? _.partial(function (d) { return d.series + '
' + d.x + '
' + d.y; }, d) : null; },\n function (d) { return d.data && d.data.hasOwnProperty('x') ? _.partial(function (d) { return d.series + '
' + d.x + '
' + d.y; }, d.data) : null; },\n function (d) { return d.hasOwnProperty('value') ? _.partial(function (d) { return d.value; }, d) : null; },\n function () { return function () { return 'NA'; }; }\n ];\n\n\n return match(formatters, d)();\n };\n\n var show = function (d) {\n clearHideTimer.call(this);\n\n var dataPoints = findOriginalDataPoint(d);\n\n this.tooltipElement.select('.text').html(getTooltipText.call(this, d || dataPoints[0], dataPoints));\n\n var pos = positionTooltip.call(this, d);\n\n this.tooltipElement\n .style('top', pos.y + 'px')\n .style('left', pos.x + 'px');\n\n changeOpacity.call(this, this.options.tooltip.opacity, this.options.tooltip.showTime);\n };\n\n function findOriginalDataPoint(d) {\n var res = [];\n _.each(data, function (series, seriesIndex) {\n var name = series.name;\n _.each(series.data, function (point) {\n if (point.x === d.x && d.y === point.y) {\n res.push(_.extend(point, { series: name, seriesIndex:seriesIndex }));\n }\n });\n });\n\n return res;\n }\n\n this.tooltipElement = this.container\n .style('position', 'relative')\n .selectAll('.nw-tooltip').data([1]);\n\n this.tooltipElement\n .enter().append('div')\n .attr('class', 'nw-tooltip')\n .style('opacity', 0)\n .append('div')\n .attr('class', 'text');\n\n this.svg.selectAll('.tooltip-tracker')\n .on('mouseover.tooltip', onMouseOver.bind(this))\n .on('mouseout.tooltip', onMouseOut.bind(this));\n }\n\n render.defaults = defaults;\n\n\n /**\n * Adds a tooltip on hover to all other visualizations in the Contour instance.\n *\n * Although not strictly required, this visualization does not appear unless there are already one or more visualizations in this Contour instance for which to show the tooltips.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .line([2, 4, 3, 5, 7])\n * .tooltip()\n * .render();\n *\n * @name tooltip(data, options)\n * @param {object|array} data Ignored!\n * @param {object} options Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n * ### Notes:\n *\n * Each Contour instance can only include one `tooltip` visualization.\n */\n Contour.export('tooltip', render);\n\n\n})();\n\n\n","(function () {\n\n function normalizeDataSet(dataSet) {\n var all = _.flatten(_.pluck(dataSet, 'data'));\n var isLinear = all.length && _.isNumber(all[0].x);\n var normalizer = function (d, i) { return { x: i, y: d.y }; };\n\n return isLinear ? all : _.map(all, normalizer);\n }\n\n function ctor(raw, layer, options) {\n this.checkDependencies('cartesian');\n var data = normalizeDataSet(raw);\n var duration = options.chart.animations.duration != null ? options.chart.animations.duration : 400;\n var shouldAnimate = options.chart.animations && options.chart.animations.enable;\n var x = _.bind(function(d) { return this.xScale(d) + this.rangeBand / 2; }, this);\n var y = _.bind(function(d) { return this.yScale(d); }, this);\n var regression = _.nw.linearRegression(data);\n var domain = d3.extent(this.xScale.domain());\n var numericDomain = d3.extent(data, function(p) { return p.x; });\n var lineY = function (x) { return regression.intercept + regression.slope * x; };\n\n var line = layer.selectAll('.trend-line')\n .data([1]);\n\n if (isNaN(lineY(numericDomain[0])) || isNaN(lineY(numericDomain[1])) || isNaN(x(domain[0])) || isNaN(x(domain[1]))) {\n line.remove();\n } else {\n line.enter().append('line')\n .attr('class', 'trend-line')\n .attr('x1', x(domain[0]))\n .attr('y1', y(lineY(numericDomain[0])))\n .attr('x2', x(domain[0]))\n .attr('y2', y(lineY(numericDomain[0])));\n\n line.exit().remove();\n\n if (shouldAnimate) {\n line = line.transition().duration(duration);\n }\n\n line.attr('x1', x(domain[0]))\n .attr('y1', y(lineY(numericDomain[0])))\n .attr('x2', x(domain[1]))\n .attr('y2', y(lineY(numericDomain[1])));\n }\n }\n\n ctor.defaults = {};\n\n /**\n * Adds a trend line to the Contour instance, based on linear regression.\n *\n * This visualization requires `.cartesian()`.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .trendLine([2,4,3,5,7])\n * .render();\n *\n * @name trendLine(data, options)\n * @param {object|array} data The _data series_ to be rendered with this visualization. This can be in any of the supported formats. A linear regression is performed on the _data series_ and the resulting trend line is displayed.\n * @param {object} [options] Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n */\n Contour.export('trendLine', ctor);\n\n})();\n"]} \ No newline at end of file +{"version":3,"sources":["?","../src/scripts/header.js","../src/scripts/core/contour-utils.js","../src/scripts/core/contour.js","../src/scripts/core/axis/y-axis.js","../src/scripts/core/cartesian.js","../src/scripts/core/exportable.js","../src/scripts/version.js","../src/scripts/core/axis/axis-scale-factory.js","../src/scripts/core/axis/linear-scale-axis.js","../src/scripts/core/axis/log-y-axis.js","../src/scripts/core/axis/ordinal-scale-axis.js","../src/scripts/core/axis/smart-y-axis.js","../src/scripts/core/axis/time-scale-axis.js","../src/scripts/core/horizontal-frame.js","../src/scripts/core/visualization-container.js","../src/scripts/visualizations/area.js","../src/scripts/visualizations/bar.js","../src/scripts/visualizations/column.js","../src/scripts/visualizations/cool-narwhal.js","../src/scripts/visualizations/legend.js","../src/scripts/visualizations/line.js","../src/scripts/visualizations/null.js","../src/scripts/visualizations/pie.js","../src/scripts/visualizations/scatter.js","../src/scripts/visualizations/stack-tooltip.js","../src/scripts/visualizations/tooltip.js","../src/scripts/visualizations/trend-line.js"],"names":["exports","global","undefined","root","this","module","require","d3","_","Error","merge","multiplier","x","dig","nw","decDigits","Math","pow","maxMultiplier","a","b","max","addFloat","factor","aa","round","bb","subFloat","mulFloat","divFloat","noop","generalHelpers","getValue","src","deafult","ctx","args","Array","prototype","slice","call","arguments","apply","seriesNameToClass","name","dataFilters","cleanNullValues","series","map","s","extend","data","reduce","acum","datum","y","push","minMaxFilter","desiredLen","length","toReturn","index","increment","floor","hasValidPt","maxPt","minPt","maxIndex","min","intermediateIndex","intermediatePt","logging","warn","msg","console","log","numberHelpers","firstAndLast","ar","roundToNearest","number","multiple","ceil","roundTo","value","digits","trunc","str","abs","toString","parts","split","log10","LN10","clamp","val","l","h","clampLeft","low","clampRight","high","degToRad","deg","PI","radToDeg","rad","rotatePoint","point","cos","sin","translatePoint","delta","linearRegression","dataSrc","lr","n","sum_x","sum_y","sum_xy","sum_xx","sum_yy","i","slope","intercept","r2","sqrt","niceRound","axisHelpers","addAxis","axisCtor","axes","roundToNextTick","num","sign","mag","step","exp","toExponential","replace","raw","niceMinMax","ticks","startAtZero","tickValues","swap","origMax","isNumber","range","concat","exponent","defaultRounding","excelRoundUp","up","roundFn","v","nice","negativeMinAmount","intermediateMax","iMin","inter","roundToDigits","intermediateMin","interval","finalMin","finalMax","ticksValues","prevTick","j","newTick","defaultMinMax","minMax","foundSomethingRound","some","every","tick","extractScaleDomain","domain","zeroAnchor","dataMin","dataMax","niceTicks","calcXLabelsWidths","padding","compact","String","d","textBounds","width","doXLabelsFit","labelFormatter","options","tickWidths","availableWidthForLabels","chart","plotWidth","axisLabelsWidth","sum","getTicksThatFit","reduceTicksByMod","iter","filterMod","finalTicks","filter","stringHelpers","text","css","body","document","getElementsByTagName","wrapper","createElement","dummy","className","style","position","height","visibility","lineHeight","whiteSpace","innerHTML","appendChild","res","clientWidth","clientHeight","removeChild","dateHelpers","dateDiff","d1","d2","diff","getTime","arrayHelpers","array1","array2","sort","isCorrectDataFormat","dataArray","isArray","p","hasOwnProperty","isCorrectSeriesFormat","isArrayOfObjects","isObject","hasDataArrayPerSeries","hasSeriesNamePerSeries","datumInCorrectFormat","normalizeSeries","categories","hasCategories","sortFn","normal","set","hasX","categoryAt","correctDataFormat","correctSeriesFormat","stackLayout","stack","layout","values","outFn","y0s","y0","out","uniq","array","cache","result","len","el","key","acc","cur","maxTickValues","tickInteval","isSupportedDataFormat","domHelpers","selectDom","selector","select","getStyle","elem","styles","offsetParent","ownerDocument","defaultView","getComputedStyle","getCentroid","element","getOffsetParent","t","tagName","parentNode","parentBox","getBoundingClientRect","bbox","left","top","debuggingHelpers","warning","defaults","animations","enable","duration","defaultWidth","defaultAspect","margin","right","bottom","internalPadding","rotatedFrame","plotHeight","plotTop","plotLeft","xAxis","yAxis","tooltip","Contour","init","export","ctorName","renderer","sortSeries","each","shouldSort","isDate","sortFunc","opt","vis","ownData","lastData","VisualizationContainer","_visualizations","expose","functionalityConstructor","ctor","functionality","Object","create","omit","_exposed","_extraOptions","calculateWidth","outerWidth","parseInt","paddingLeft","paddingRight","calculateHeight","outerHeight","paddingTop","paddingBottom","containerHeight","calcWidth","ratio","aspect","calcMetrics","adjustPadding","adjustTitlePadding","composeOptions","allDefaults","mergeExtraOptions","mergeDefaults","baseRender","plotArea","render","renderVisualizations","resize","container","update","chartOpt","attr","svg","append","node","createVisualizationLayer","id","type","visualization","layer","parent","bind","checkDependencies","listOfDependencies","_this","missing","dep","indexOf","join","ensureDefaults","isString","setData","invokeMap","dataNormalizer","define","amd","YAxis","setRange","scale","rangeSize","axis","dMin","dMax","numTicks","format","labels","formatter","_scale","tickFormat","tickSize","innerTickSize","outerTickSize","tickPadding","linear","setDomain","_niceTheScale","gridlines","maxTicks","title","titlePadding","innerRangePadding","outerRangePadding","orient","linearDomain","smartAxis","verticalAlign","cartesian","maxTickSize","readOnlyProps","extraPadding","xDomain","yDomain","_getYScaledDomain","opts","absMin","extent","xOptions","yOptions","_getAdjustedBottomPadding","_getAdjustedTopPadding","_getAdjustedLeftPadding","_getAdjustedRightPadding","xLabels","xAxisText","xLabelBounds","regularXBounds","em","ang","rotation","xLabelHeightUsed","yDomainScaled","tmpScale","yLabels","yAxisText","yLabelBounds","titleBounds","computeXScale","xScale","xScaleGenerator","xScaleFactory","rangeBand","computeYScale","yScaleDomain","yScale","yScaleGenerator","yScaleFactory","setYDomain","redrawYAxis","renderGridlines","_animationDuration","computeScales","_xAxis","_yAxis","renderXAxis","_xAxisGroup","selectAll","enter","transition","postProcessAxis","renderYAxis","_yAxisGroup","_renderYAxisElement","alignmentOffset","middle","renderAxisLabels","adjustFactor","bounds","option","horizontal","vertical","getYTicks","smart","pop","getXTicks","gr","w","lines","exit","remove","offset","renderBackground","background","g","adjustDomain","extents","getExtents","_adjustXDomain","_adjustYDomain","getXDomain","dataVis","flatten","isCategoricalData","dataSrcCategories","sameCats","intersection","yMin","yMax","field","all","defaultParams","fileName","target","backgroundColor","browser","checked","queue","working","exportable","cssIgnoreDiff","cssText","parentRule","cssSharedSvg","font","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","direction","letterSpacing","textDecoration","unicodeBidi","wordSpacing","clip","cursor","display","overflow","opacity","addToQueue","checkBrowser","download","exportImage","place","getSvgDataUrl","dataUrlCreated","makeSvgUrl","makeImageUrl","encodeBase64DataUrl","svgXml","btoa","dataUrlToBlob","dataUrl","byteString","atob","unescape","mimeString","byteArray","Uint8Array","charCodeAt","Blob","XMLSerializer","serializeToString","svgDataUrl","canvas","context","getContext","canvg","renderImageCanvg","renderImageNative","imageRendered","imageDataUrl","toDataURL","createsObjectUrls","imageBlob","domUrl","URL","webkitURL","objectUrl","createObjectURL","revokeObjectURL","svgImg","Image","onload","fillStyle","fillRect","drawImage","onerror","ignoreMouse","ignoreAnimation","offsetX","offsetY","scaleWidth","scaleHeight","renderCallback","createSvgClone","svgNode","svgCloned","createIsolatedNode","nodeClone","destroyIsolatedNode","cloneNodes","cloneLegendDiv","applyStyles","sourceNode","targetNode","sourceStyle","targetStyle","prop","isFinite","newNode","cloneNode","childNodes","childNode","nodeLoaded","iframe","iframeWindow","contentWindow","iframeDocument","destroyIframe","open","write","close","applyDivStylesToSvg","nodeName","rx","borderTopLeftRadius","ry","fill","stroke","borderLeftColor","stroke-width","borderLeftWidth","color","containerDiv","empty","containerDivNode","containerSvg","offsetLeft","clientLeft","offsetTop","clientTop","rect","entriesDivs","entryDivNode","entryDiv","entryDivKeyNode","getEntryDivSubNode","swatch","offsetWidth","offsetHeight","entryDivSeriesNode","textContent","getProportionedBounds","original","specified","exporter","startWork","boundsClone","performExport","svgNodeClone","destroySvgClone","setAttribute","win","aDownloads","savesMsBlobs","url","blob","revokeUrl","exporters","href","click","navigator","msSaveOrOpenBlob","location","doc","setTimeout","finishWork","img","fn","shift","checkEncodesBase64","checkADownloads","checkSavesMsBlobs","checkCreatesObjectUrls","checkExportsSvg","encodesBase64","setupBase64Shim","exportsSvg","querySelector","getAttribute","sourceImg","e","svgExportChecked","xml","encodeURIComponent","setupCanvgShim","chars","InvalidCharacterError","message","input","block","charCode","idx","output","charAt","done","scripts","remaining","script","head","version","helpers","isTimeData","TimeScale","LinearScale","OrdinalScale","axisType","LogYAxis","SmartYAxis","_domain","_getAxisDomain","_setRange","formatLabel","getDate","labelsFit","optMin","optMax","__super","ticksHint","isCategorized","ordinal","optFormat","axisGroup","pos","lineCenter","anchor","text-anchor","ref","toFixed","_range","band","numCats","threshold","rangeType","rangePoints","_extractYTickValues","adjustedDomain","perTreshold","rawMax","nextTick","time","getOptimalTickFormat","axisDomain","spanDays","daysThreshold","_getAxisRange","rangeRound","size","frame","categoryLabels","xLabel","yLabel","lineHeightAdjustment","titleOneEm","_extent","maxs","mins","_stackedExtent","dataSets","ext","_xExtent","partialRight","_yExtent","VisInstanceContainer","setOptions","normalizeData","_updateDomain","setVisibility","visible","$","show","hide","isSupportedFormat","xExtent","yExtent","stacked","area","areaBase","preprocess","classFn","startArea","y1","smooth","interpolate","renderSeries","renderTooltipTrackers","trackerSize","markers","blocks","bar","barClass","groupPadding","barWidth","barRender","rectClass","chartOffset","grouped","bars","cssClass","numSeries","column","columnClass","columnWidth","rectStyle","dataKey","filteredData","cols","col","base","delay","legend","vAlign","hAlign","enabled","validAlignmentClasses","classes","Legend","firstChild","count","legendHeight","mid","positioner","selection","legendWidth","entries","line","animationDirection","marker","animationDelay","animationsMap","left-to-right","path","totalLength","getTotalLength","ease","bottom-to-top","rawData","shouldAnimate","renderPaths","renderMarkers","seriesClassName","extras","startLine","animFn","startLineFn","partial","dots","class","r","cx","cy","pie","sliceClass","piePadding","innerRadius","outerRadius","normalizePadding","clampBounds","maxWidth","maxHeight","calcPadding","resolveValueUnits","resolvePaddingUnits","shouldCenterX","shouldCenterY","pixelPadding","referenceSize","totalPadding","proposedRadius","radius","pieData","totalWidth","outerPaddingLeft","centerY","baseClass","translatePie","posY","pieGroup","group","arc","startArc","startAngle","endAngle","_current","attrTween","arcTween","scatter","ScatterPlot","halfRangeBand","stackTooltip","valueFormatter","classed","onMouseOver","isNull","mapFn","seriesName","filtered","html","onMouseOut","on","animate","showTime","hideTime","distance","clearHideTimer","clearTimeout","hideTimer","changeOpacity","tooltipElement","positionTooltip","pointOrCentroid","event","mouse","parseFloat","pointX","pointY","alignedRight","clampPosition","verticalPositioner","horizontalPositioner","getTooltipText","allPoints","match","params","list","rest","response","first","formatters","dataPoints","findOriginalDataPoint","seriesIndex","normalizeDataSet","dataSet","pluck","isLinear","normalizer","regression","numericDomain","lineY","isNaN"],"mappings":";;CAAC,SAASA,QAASC,SCAnB,SAAWC,WAEP,GAAIC,MAAOC,IAEX,UAAWC,UAAW,UAAYA,cAAiBA,QAAOL,UAAY,SAAU,CAC5E,SAAUM,WAAY,WAAY,CAC9BH,KAAKI,GAAKD,QAAQ,KAClBH,MAAKK,EAAIF,QAAQ,WAIzB,IAAIC,GAAI,KAAM,IAAIE,OAAM,mEACxB,KAAID,IAAMA,EAAEE,MAAO,KAAM,IAAID,OAAM,+ECZvC;;;AAGI,GAAIE,YAAa,SAAUC,GAAK,GAAIC,KAAML,EAAEM,GAAGC,UAAUH,EAAI,OAAOC,OAAQ,EAAI,EAAIG,KAAKC,IAAI,GAAIJ,KACjG,IAAIK,eAAgB,SAAUC,EAAEC,GAAK,MAAOJ,MAAKK,IAAIV,WAAWQ,GAAIR,WAAWS,IAC/E,IAAIE,UAAW,SAAUH,EAAEC,GAAK,GAAIG,QAASL,cAAcC,EAAEC,GAAII,GAAKR,KAAKS,MAAMN,EA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MAAOm7B,YAAWn0B,UAAYm0B,WAAWp0B,MAAQ/G,EAE5E,IAAIm0B,MAAOpd,MAAMgG,UAAU,eACtBxa,MAAM,GAEX,IAAI+4B,MAAMD,MAAMD,cAAc,MAAQE,MAAMD,MAAMD,cAAc,MAAQE,MAAMt7B,EAAEqK,OAAO,MAAQixB,MAAMt7B,EAAEqK,OAAO,KAAM,CAChH8pB,KAAK7V,aACF,CACH6V,KAAKnX,QAAQvG,OAAO,QACjBF,KAAK,QAAS,cACdA,KAAK,KAAMvW,EAAEqK,OAAO,KACpBkM,KAAK,KAAM5T,EAAE04B,MAAMD,cAAc,MACjC7kB,KAAK,KAAMvW,EAAEqK,OAAO,KACpBkM,KAAK,KAAM5T,EAAE04B,MAAMD,cAAc,KAEpCjH,MAAK9V,OAAOC,QAEZ,IAAIyW,cAAe,CACfZ,KAAOA,KAAKlX,aAAa7K,SAASA,UAGtC+hB,KAAK5d,KAAK,KAAMvW,EAAEqK,OAAO,KACtBkM,KAAK,KAAM5T,EAAE04B,MAAMD,cAAc,MACjC7kB,KAAK,KAAMvW,EAAEqK,OAAO,KACpBkM,KAAK,KAAM5T,EAAE04B,MAAMD,cAAc,OAI5ChnB,KAAKnC;;;;;;;;;;;;;;;;;;AAoBLiB,QAAQE,OAAO,YAAagB,S3BpEiB/U,QAAO,QAAUD,aAAgB,WAAW,MAAOI","file":"contour.min.js","sourcesContent":[null,"(function (undefined) {\n\n var root = this;\n\n if (typeof module === 'object' && module && typeof module.exports === 'object') {\n if(typeof require === 'function') {\n root.d3 = require('d3');\n root._ = require('lodash');\n }\n }\n\n if(!d3) throw new Error('You need to include d3.js before Contour. Go to http://d3js.org/');\n if(!_ || !_.merge) throw new Error('You need to include lodash.js before Contour. Go to http://lodash.com/');\n\n})();\n","(function () {\n // cheap trick to add decimals without hitting javascript issues\n // note that this fails for very large numbers\n var multiplier = function (x) { var dig = _.nw.decDigits(x); return dig === 0 ? 1 : Math.pow(10, dig); };\n var maxMultiplier = function (a,b) { return Math.max(multiplier(a), multiplier(b)); };\n var addFloat = function (a,b) { var factor = maxMultiplier(a,b), aa = Math.round(a * factor), bb = Math.round(b * factor); return (aa + bb) / factor; };\n var subFloat = function (a,b) { var factor = maxMultiplier(a,b), aa = Math.round(a * factor), bb = Math.round(b * factor); return (aa - bb) / factor; };\n var mulFloat = function (a,b) { var factor = maxMultiplier(a,b), aa = Math.round(a * factor), bb = Math.round(b * factor); return (aa * bb) / (factor*factor); };\n var divFloat = function (a,b) { var factor = maxMultiplier(a,b), aa = Math.round(a * factor), bb = Math.round(b * factor); return aa / bb; };\n\n var noop = function () {};\n\n var generalHelpers = {\n // the src is a function returns the function evaluated\n // otherwise returns src\n getValue: function (src, deafult, ctx, args) {\n args = Array.prototype.slice.call(arguments, 3);\n return !src ? deafult : typeof src === 'function' ? src.apply(ctx, args) : src;\n },\n\n seriesNameToClass: function (name) {\n return name || '';\n }\n };\n\n var dataFilters = {\n\n cleanNullValues: function () {\n return function (series) {\n return _.map(series, function (s) {\n return _.extend(s, {\n data: _.reduce(s.data, function (acum, datum) {\n if (datum.y != null) {\n acum.push(datum);\n }\n\n return acum;\n }, [])\n });\n });\n };\n },\n\n minMaxFilter: function (desiredLen) {\n return function(data) {\n if (data.length <= desiredLen)\n return data;\n\n var toReturn = [data[0]]; //always want the first\n var index = 1;\n var increment = Math.floor(data.length / desiredLen);\n\n while (index < data.length - 1) {\n var hasValidPt = false;\n var maxPt;\n var minPt;\n var maxIndex = Math.min(index + increment, data.length);\n\n for (var intermediateIndex = index; intermediateIndex < maxIndex; intermediateIndex++) {\n var intermediatePt = data[index];\n if (intermediatePt.y) {\n if (!hasValidPt || intermediatePt.y > maxPt.y)\n maxPt = intermediatePt;\n\n if (!hasValidPt || intermediatePt.y < minPt.y)\n minPt = intermediatePt;\n\n hasValidPt = true;\n }\n }\n\n if (hasValidPt) {\n if (minPt.x === maxPt.x) {\n toReturn.push(minPt);\n } else if (minPt.x < maxPt.x) {\n toReturn.push(minPt);\n toReturn.push(maxPt);\n } else if (minPt.x > maxPt.x) {\n toReturn.push(maxPt);\n toReturn.push(minPt);\n }\n }\n\n index += Math.max(1, Math.min(data.length - 1 - index, increment));\n }\n toReturn.push(data[data.length - 1]); //always want the last\n return toReturn;\n };\n }\n };\n\n var logging = {\n warn: function (msg) {\n if (console && console.log)\n console.log(msg);\n }\n };\n\n var numberHelpers = {\n firstAndLast: function (ar) {\n return [ar[0], ar[ar.length-1]];\n },\n\n roundToNearest: function (number, multiple) {\n return mulFloat(Math.ceil(divFloat(number, multiple)), multiple);\n },\n\n roundTo: function (value, digits) {\n return divFloat(Math.ceil(mulFloat(value, Math.pow(10, digits))), Math.pow(10, digits));\n },\n\n trunc: function (value) {\n return value - value % 1;\n },\n\n // only works for integers\n digits: function (value) {\n var str = Math.abs(value).toString();\n var parts = str.split('e');\n if (parts.length === 2) {\n return Math.max(0, parts[1]) + 1;\n }\n parts = str.split('.');\n return parts[0].length;\n },\n\n decDigits: function (value) {\n var str = Math.abs(value).toString();\n var parts = str.split('.');\n if (parts.length === 2) {\n return parts[1].length;\n }\n parts = str.split('e');\n if (parts.length === 2) {\n return -Math.min(0, parts[1]);\n }\n return 0;\n },\n\n log10: function (value) {\n return Math.log(value) / Math.LN10;\n },\n\n clamp: function (val, l, h) {\n return val > h ? h : val < l ? l : val;\n },\n\n clampLeft: function (val, low) {\n return val < low ? low : val;\n },\n\n clampRight: function (val, high) {\n return val > high ? high : val;\n },\n\n degToRad: function (deg) {\n return deg * Math.PI / 180;\n },\n\n radToDeg: function (rad) {\n return rad * 180 / Math.PI;\n },\n\n rotatePoint: function (point, rad) {\n return {\n x: point.x * Math.cos(rad) - point.y * Math.sin(rad),\n y: point.x * Math.sin(rad) + point.y * Math.cos(rad)\n };\n },\n\n translatePoint: function (point, delta) {\n return {\n x: point.x + delta.x,\n y: point.y + delta.y\n };\n },\n\n linearRegression: function (dataSrc) {\n var lr = {};\n var n = dataSrc.length;\n var sum_x = 0;\n var sum_y = 0;\n var sum_xy = 0;\n var sum_xx = 0;\n var sum_yy = 0;\n\n for (var i = 0; i < n; i++) {\n sum_x += dataSrc[i].x;\n sum_y += dataSrc[i].y;\n sum_xy += (dataSrc[i].x*dataSrc[i].y);\n sum_xx += (dataSrc[i].x*dataSrc[i].x);\n sum_yy += (dataSrc[i].y*dataSrc[i].y);\n }\n\n lr.slope = (n * sum_xy - sum_x * sum_y) / (n*sum_xx - sum_x * sum_x);\n lr.intercept = (sum_y - lr.slope * sum_x)/n;\n lr.r2 = Math.pow((n*sum_xy - sum_x*sum_y)/Math.sqrt((n*sum_xx-sum_x*sum_x)*(n*sum_yy-sum_y*sum_y)),2);\n\n return lr;\n },\n\n niceRound: function (val) {\n // for now just round(10% above the value)\n return Math.ceil(val + val * 0.10);\n\n // var digits = Math.floor(Math.log(val) / Math.LN10) + 1;\n // var fac = Math.pow(10, digits);\n\n // if(val < 1) return _.nw.roundToNearest(val, 1);\n\n // if(val < fac / 2) return _.nw.roundToNearest(val, fac / 2);\n\n // return _.nw.roundToNearest(val, fac);\n }\n };\n\n var axisHelpers = {\n addAxis: function (name, axisCtor) {\n _.nw.axes = _.nw.axes || {};\n _.nw.axes[name] = axisCtor;\n },\n\n roundToNextTick: function (num) {\n var abs = Math.abs(num);\n var sign = abs === num ? 1 : -1;\n var mag, step;\n if (abs >= 1) {\n mag = Math.floor(_.nw.log10(abs));\n step = mag <= 1 ? 2 : Math.pow(10, mag - 1);\n } else {\n\n var exp = abs.toExponential().replace(/\\.|e-\\d+$/g, '');\n mag = exp.length;\n step = mulFloat((mag === 1 ? 2 : 10), Math.pow(10, -mag));\n }\n\n var raw = _.nw.roundToNearest(abs, step);\n return sign * raw;\n },\n\n niceMinMax: function (min, max, ticks, startAtZero) {\n // return divFloat(Math.ceil(mulFloat(value, Math.pow(10, digits))), Math.pow(10, digits));\n\n // check for errors... min cannot be > max\n if (min > max) {\n return {\n min: min,\n max: min,\n tickValues: []\n };\n }\n\n var swap = max < 0 && min < 0;\n var origMax = max;\n if (swap) {\n max = -min;\n min = -origMax;\n }\n\n // 2 ticks seem to work for min max and passing 5 ticks to d3\n ticks = ticks == null ? 2 : Math.max(1, ticks);\n // if ticks is an array, use that as order of preferred ticks; otherwise return a\n // variable number of ticks in order to keep values round\n if (_.isNumber(ticks)) {\n // for 1, check [1]\n // for 2, check [2, 1]\n // for 3, check [3, 2]\n // for 4, check [4, 5, 3]\n // for 5, check [5, 6, 4, 3]\n // for 6, check [6, 7, 5, 4]\n // for 7, check [7, 8, 6, 5]\n // for 8, check [8, 9, 10, 7, 6]\n // for 9, check [9, 10, 11, 8, 7, 6]\n // for 10, check [10, 11, 12, 9, 8, 7]\n ticks = _.range(ticks, ticks * 1.28)\n .concat(_.range(ticks - 1, (ticks - 1) * 0.72, -1));\n }\n\n if (startAtZero == null) {\n startAtZero = min === 0 || origMax < 0;\n }\n\n var exponent;\n if (min === max) {\n if (max === 0) {\n exponent = -1.0;\n } else {\n exponent = numberHelpers.log10(Math.abs(max));\n }\n } else {\n if(startAtZero) {\n exponent = numberHelpers.log10(Math.abs(max)) - 0.5;\n } else {\n exponent = numberHelpers.log10(max-min) - 0.5;\n }\n }\n\n var defaultRounding = -(exponent >= 0 ? numberHelpers.trunc(exponent) : Math.floor(exponent));\n\n // var defaultRounding = -numberHelpers.trunc((min === max ?\n // max === 0 ? -1.0 : numberHelpers.log10(Math.abs(max)) :\n // startAtZero ? numberHelpers.log10(Math.abs(max)) : numberHelpers.log10(max-min)\n // ) - 0.5);\n\n var excelRoundUp = function (value, up) {\n up = up != null ? up : 0;\n var roundFn = function (v) { return v >= 0 ? Math.ceil(v) : Math.floor(v); };\n return divFloat(roundFn(value * Math.pow(10, up)), Math.pow(10, up));\n };\n\n var nice = function (ticks) {\n var negativeMinAmount = excelRoundUp(Math.max(0, -min) / ticks, defaultRounding - 1);\n\n var intermediateMax = min === max ? max === 0 ? 1 : excelRoundUp(max + negativeMinAmount, defaultRounding)\n : excelRoundUp(max + negativeMinAmount,defaultRounding);\n\n var iMin = 0;\n if (!startAtZero && min !== max) {\n var inter = min + negativeMinAmount;\n var dig = numberHelpers.digits(inter);\n var roundToDigits;\n if (inter > 0) {\n roundToDigits = -Math.floor(_.nw.log10(inter));\n } else {\n roundToDigits = (Math.max(1, Math.abs(dig-2)));\n }\n\n iMin = -numberHelpers.roundTo(-inter, roundToDigits);\n iMin = iMin === 0 ? 0 : iMin;\n // old version:\n // iMin = excelRound(min + negativeMinAmount, defaultRounding + (min < 0 ? 1 : 0))\n }\n\n var intermediateMin = iMin;\n\n var interval = excelRoundUp(divFloat(subFloat(intermediateMax, intermediateMin),ticks), defaultRounding);\n var finalMin = subFloat(intermediateMin, negativeMinAmount);\n var finalMax = addFloat(finalMin, mulFloat(ticks, interval));\n var ticksValues = [finalMin];\n var prevTick = finalMin;\n\n for (var j=1; j < ticks; j++) {\n var newTick = addFloat(prevTick, interval);\n\n ticksValues.push(newTick);\n prevTick = newTick;\n }\n\n // total ticks are going to be either ticks or ticks + 1\n if (Math.abs(prevTick - finalMax) > 1e-10) {\n ticksValues.push(finalMax);\n }\n\n return {\n min: swap ? -finalMax : finalMin,\n max: swap ? -finalMin : finalMax,\n tickValues: ticksValues.map(function (a) { return swap ? -a : a; })\n };\n };\n\n var defaultMinMax;\n var minMax;\n\n var foundSomethingRound = _.some(ticks, function (ticks) {\n minMax = nice(ticks);\n defaultMinMax = defaultMinMax || minMax;\n return _.every(minMax.tickValues, function (tick) {\n return tick === Math.round(tick);\n });\n });\n return foundSomethingRound ? minMax : defaultMinMax;\n },\n\n /*jshint eqnull:true */\n extractScaleDomain: function (domain, min, max, ticks, zeroAnchor) {\n var dataMin = min != null ? min : _.min(domain);\n var dataMax = max != null ? max : _.max(domain);\n ticks = ticks == null ? 5 : ticks;\n\n var niceMinMax = axisHelpers.niceMinMax(dataMin, dataMax, ticks, zeroAnchor);\n\n return [niceMinMax.min, niceMinMax.max];\n\n // // we want null || undefined for all this comparasons\n // // that == null gives us\n // if (min == null && max == null) {\n // return [niceMinMax.min, niceMinMax.max];\n // }\n\n // if (min == null) {\n // return [Math.min(niceMinMax.min, max), max];\n // }\n\n // if (max == null) {\n // return [min, Math.max(min, niceMinMax.max)];\n // }\n\n // return [min, max];\n },\n\n niceTicks: function (min, max, ticks, zeroAnchor) {\n ticks = ticks == null ? 5 : ticks;\n\n var niceMinMax = axisHelpers.niceMinMax(min, max, ticks, zeroAnchor);\n return niceMinMax.tickValues;\n },\n\n calcXLabelsWidths: function (ticks) {\n var padding = 8;\n return _.compact(ticks).map(String).map(function (d) {\n if (!d) {\n return padding * 2;\n }\n return _.nw.textBounds(d, '.x.axis text').width + (padding * 2);\n });\n },\n\n doXLabelsFit: function (ticks, labelFormatter, options) {\n var tickWidths = _.nw.calcXLabelsWidths(ticks.map(labelFormatter));\n var availableWidthForLabels = (options.chart.plotWidth + tickWidths[0] / 2 + tickWidths[ticks.length - 1] / 2);\n var axisLabelsWidth = _.nw.sum(tickWidths);\n return axisLabelsWidth <= availableWidthForLabels;\n },\n\n getTicksThatFit: function (ticks, labelFormatter, options) {\n // reduce the number of ticks incrementally by taking every 2nd, then every 3th, and so on\n // until we find a set of ticks that fits the available space\n function reduceTicksByMod() {\n var tickWidths = _.nw.calcXLabelsWidths(ticks.map(labelFormatter));\n var axisLabelsWidth = _.nw.sum(tickWidths);\n var availableWidthForLabels = (options.chart.plotWidth + tickWidths[0] / 2 + tickWidths[ticks.length - 1] / 2);\n var iter = 1;\n var filterMod = function (d, i) { return (i % iter) === 0; };\n var finalTicks = ticks;\n while(axisLabelsWidth > availableWidthForLabels && finalTicks.length !== 0) {\n iter++;\n finalTicks = _.filter(ticks, filterMod);\n axisLabelsWidth = _.nw.sum(_.nw.calcXLabelsWidths(finalTicks.map(labelFormatter)));\n }\n\n return finalTicks;\n }\n\n // possible alternative way using d3 ticks to calculate the number\n // that fits\n // function reduceTicksByD3() {\n // // while(axisLabelsWidth > availableWidthForLabels && ticks.length !== 1) {\n // // ticks = axis.scale().ticks(Math.floor(--numAutoTicks));\n // // axisLabelsWidth = sum(calcLabelsWidths(ticks.map(formatLabel)));\n // // }\n\n // // axis.ticks(ticks.length);\n // }\n\n return reduceTicksByMod();\n }\n };\n\n\n var stringHelpers = {\n // measure text inside a Contour chart container\n textBounds: function (text, css) {\n var body = document.getElementsByTagName('body')[0];\n var wrapper = document.createElement('span');\n var dummy = document.createElement('span');\n wrapper.className = 'contour-chart';\n dummy.style.position = 'absolute';\n dummy.style.width = 'auto';\n dummy.style.height = 'auto';\n dummy.style.visibility = 'hidden';\n dummy.style.lineHeight = '100%';\n dummy.style.whiteSpace = 'nowrap';\n\n dummy.innerHTML = text;\n dummy.className = css.replace(/\\./g, ' ');\n wrapper.appendChild(dummy);\n body.appendChild(wrapper);\n var res = { width: dummy.clientWidth, height: dummy.clientHeight };\n wrapper.removeChild(dummy);\n body.removeChild(wrapper);\n return res;\n }\n };\n\n var dateHelpers = {\n dateDiff: function(d1, d2) {\n var diff = d1.getTime() - d2.getTime();\n return diff / (24*60*60*1000);\n }\n };\n\n var arrayHelpers = {\n // concatenate and sort two arrays to the resulting array\n // is sorted ie. merge [2,4,6] and [1,3,5] = [1,2,3,4,5,6]\n merge: function (array1, array2) {\n if(typeof(array1) === 'number') array1 = [array1];\n if(typeof(array2) === 'number') array2 = [array2];\n if(!array1 || !array1.length) return array2;\n if(!array2 || !array2.length) return array1;\n\n return [].concat(array1, array2).sort(function (a,b) { return a-b; });\n },\n\n isCorrectDataFormat: function (dataArray) {\n return _.isArray(dataArray) && _.every(dataArray, function (p) { return p.hasOwnProperty('x') && p.hasOwnProperty('y'); });\n },\n\n isCorrectSeriesFormat: function (data) {\n var isArrayOfObjects = _.isArray(data) && _.isObject(data[0]);\n var hasDataArrayPerSeries = _.every(data, function (d) { return d.hasOwnProperty('data'); });\n var hasSeriesNamePerSeries = _.every(data, function (d) { return d.hasOwnProperty('name'); });\n var datumInCorrectFormat = isArrayOfObjects && hasDataArrayPerSeries && arrayHelpers.isCorrectDataFormat(data[0].data);\n\n return isArrayOfObjects && hasDataArrayPerSeries && hasSeriesNamePerSeries && datumInCorrectFormat;\n },\n\n /*jshint eqnull:true */\n // we are using != null to get null & undefined but not 0\n normalizeSeries: function (data, categories) {\n var hasCategories = !!(categories && _.isArray(categories));\n function sortFn(a, b) { return a.x - b.x; }\n function normal(set, name) {\n var d = {\n name: name,\n data: _.map(set, function (d, i) {\n var hasX = d != null && d.hasOwnProperty('x');\n var val = function (v) { return v != null ? v : null; };\n // make sure we return a valid category and not cast nulls as string\n var categoryAt = function (i) { return !hasCategories ? i : categories[i] == null ? null : categories[i] + ''; };\n return hasX ? _.extend(d, { x: d.x, y: val(d.y) }) : { x: categoryAt(i), y: val(d) };\n })\n };\n\n if (!hasCategories) {\n d.data.sort(sortFn);\n }\n\n return d;\n }\n\n var correctDataFormat = arrayHelpers.isCorrectDataFormat(data);\n var correctSeriesFormat = arrayHelpers.isCorrectSeriesFormat(data);\n\n // do not make a new copy, if the data is already in the correct format!\n if (correctSeriesFormat) {\n return data;\n }\n\n // do the next best thing if the data is a set of points in the correct format\n if (correctDataFormat) {\n if (!hasCategories) data.sort(sortFn);\n return [{ name: 'series 1', data: data }];\n }\n\n // for the rest of the cases we need to normalize to the full format of the series\n if (_.isArray(data)) {\n if ((_.isObject(data[0]) && data[0].hasOwnProperty('data')) || _.isArray(data[0])) {\n // this would be the shape for multiple series\n return _.map(data, function (d, i) { return normal(d.data ? d.data : d, d.name ? d.name : 'series ' + (i+1)); });\n } else {\n // this is just the shape [1,2,3,4] or [{x:0, y:1}, { x: 1, y:2}...]\n return [normal(data, 'series 1')];\n }\n }\n\n // nothing to do to the data if it's not in a supported format\n return data;\n },\n\n // returns a function to format the data into a 'stacked' d3 layout\n // passing in a series data will add a y0 to each data point\n // where the point should start relative to the reset of the series points\n // at that x value\n stackLayout: function () {\n var stack = d3.layout\n .stack()\n .values(function (d) { return d.data; });\n // prepare satck to handle different x values with different lengths\n var outFn = function() {\n var y0s = {};\n return function (d, y0, y) {\n d.y0 = y0s[d.x] != null ? y0s[d.x] : 0;\n d.y = y;\n y0s[d.x] = (y0s[d.x] || 0) + y;\n };\n };\n\n stack.out(outFn());\n\n return stack;\n },\n\n // return the uniq elements in the array\n // we are implementing our own version since this algorithm seems\n // to be a lot faster than what lodash uses\n uniq: function (array) {\n var cache = {}, result = [];\n var len = array.length;\n\n for (var j=0; j= len) return domain.slice();\n\n // return d3.scale.linear().domain(domain).ticks(max);\n\n var tickInteval = Math.ceil((len) / (max));\n var cur = 0;\n while (cur < len) {\n values.push(domain[cur]);\n cur += tickInteval;\n }\n\n return values;\n },\n\n isSupportedDataFormat: function (data) {\n // this covers all supported formats so far:\n // [ {data: [...] }, ... ]\n // [ [...], [...] ]\n return _.isArray(data) &&\n (_.isObject(data[0]) && data[0].hasOwnProperty('data') && _.isArray(data[0].data)) ||\n _.isArray(data[0]);\n }\n\n };\n\n var domHelpers = {\n selectDom: function (selector) {\n return d3.select(selector)[0][0];\n },\n\n getStyle: function (el, style) {\n if(!el) return undefined;\n var elem = typeof el === 'string' ? this.selectDom(el) : el;\n // we need a good way to check if the element is detached or not\n var styles = elem.offsetParent ? elem.ownerDocument.defaultView.getComputedStyle(elem, null) : elem.style;\n\n return style ? styles[style] : styles;\n },\n\n getCentroid: function (element) {\n var getOffsetParent = function () {\n if (element.offsetParent) {\n return element.offsetParent;\n }\n\n // we we don't have an offsetParent, we may be in firefox\n // let's just assume that the offset parent is the svg element\n var t = element;\n while(t && t.tagName !== 'svg') {\n t = t.parentNode;\n }\n\n return t;\n };\n\n var parentBox = getOffsetParent().getBoundingClientRect();\n var bbox = element.getBoundingClientRect();\n\n return [bbox.left - parentBox.left + bbox.width/2, bbox.top - parentBox.top + bbox.height/2];\n }\n };\n\n var debuggingHelpers = {\n warning: function (msg) {\n if(console && console.log) {\n console.log('WARNING: ' + msg);\n }\n }\n };\n\n _.nw = _.extend({}, _.nw, numberHelpers, arrayHelpers, stringHelpers, dateHelpers,\n axisHelpers, debuggingHelpers, domHelpers, generalHelpers, logging, dataFilters);\n\n if (!_.noop) {\n _.noop = noop;\n }\n\n})();\n","(function () {\n\n var root = this;\n\n var defaults = {\n\n chart: {\n animations: {\n enable: true,\n // duration of the animation in ms\n duration: 400,\n },\n // by default take the size of the parent container\n defaultWidth: 400,\n // height = width * ratio\n defaultAspect: 1 / 1.61803398875,\n // calculated at render time based on the options & container\n width: undefined,\n // if defined, height takes precedence over aspect\n height: undefined,\n // margin between the container and the chart (ie labels or axis title)\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n // padding between the chart area and the inner plot area */\n padding: {\n top: null,\n right: null,\n bottom: null,\n left: null\n },\n internalPadding: {\n bottom: 0,\n left: 0\n },\n // automatically false by default anyway; adding here to help generate docs\n rotatedFrame: false,\n // width in pixels of the plot area (area inside the axis if any). This gets calculated on render\n plotWidth: undefined,\n // height in pixels of the plot area (area inside the axis if any). This gets calculated on render\n plotHeight: undefined,\n // top edge in pixels (from the edge of the svg) of the plot area (area inside the axis if any). This gets calculated on render\n plotTop: undefined,\n // left edge in pixels (from the edge of the svg) of the plot area (area inside the axis if any). This gets calculated on render\n plotLeft: undefined,\n },\n\n xAxis: {\n },\n\n yAxis: {\n },\n\n tooltip: {\n }\n };\n\n /**\n * Creates a Contour instance, based on the core Contour visualizations object. This instance can contain a set of related visualizations.\n *\n * * Pass the constructor any configuration options in the *options* parameter. Make sure the `el` option contains the selector of the container in which the Contour instance will be rendered.\n * * Set the frame for this Contour instance (e.g. `.cartesian()`).\n * * Add one or more specific visualizations to this Contour instance (e.g. `.scatter()`, `.trend-line()`). Pass each visualization constructor the data it displays. Pass configuration options if desired.\n * * Invoke an action for this Contour instance (e.g. `.render()`).\n *\n * ### Example:\n *\n * new Contour({el: 'myChart'})\n * .cartesian()\n * .line([1,3,2,5])\n * .render()\n *\n *\n * @class Contour()\n * @param {object} options The global configuration options object\n *\n */\n function Contour (options) {\n this.init(options);\n\n return this;\n }\n\n /**\n * Adds a new kind of visualization to the core Contour object.\n * The *renderer* function is called when you add this visualization to instances of Contour.\n * See a sample in the [Contour Gallery](http://forio.com/contour/gallery.html#/chart/pie/pie-gauge).\n *\n * ### Example:\n *\n * Contour.export(\"exampleVisualization\", function(data, layer) {\n * //function body to create exampleVisualization\n * //for example using SVG and/or D3\n * });\n *\n * //to include the visualization into a specific Contour instance\n * new Contour(options)\n * .exampleVisualization(data)\n * .render()\n *\n * @param {String} ctorName Name of the visualization, used as a constructor name.\n * @param {Function} renderer Function called when this visualization is added to a Contour instance. This function receives the data that is passed in to the constructor.\n */\n Contour.export = function (ctorName, renderer) {\n\n if (typeof renderer !== 'function') throw new Error('Invalid render function for ' + ctorName + ' visualization');\n\n function sortSeries(data) {\n if(!data || !data.length) return [];\n\n if(data[0].data) {\n _.each(data, sortSeries);\n }\n\n var shouldSort = _.isObject(data[0]) && _.isDate(data[0].x);\n var sortFunc = function (a, b) { return a.x - b.x; };\n if(shouldSort) {\n data.sort(sortFunc);\n }\n\n return data;\n }\n\n Contour.prototype[ctorName] = function (data, options) {\n var categories = this.options ? this.options.xAxis ? this.options.xAxis.categories : undefined : undefined;\n var opt = _.extend({}, this.options[ctorName], options);\n var vis;\n var ownData = true;\n\n if (!data) {\n data = this.lastData || [];\n ownData = false;\n }\n\n sortSeries(data);\n vis = new Contour.VisualizationContainer(data, categories, opt, ctorName, renderer, this);\n vis.ownData = ownData;\n this._visualizations.push(vis);\n\n // lastData is used to pass the last specified dataset\n // to the next visualiaztion in the chain wihtout\n // the need to specify it again.... this allows you to do\n // new Contour().cartesian().line(dataset).lengend().tooltip().render()\n // and legend and tooltip will recieve dataset\n this.lastData = data;\n\n return this;\n };\n\n /* expose the renderer function so it can be reused\n * by other visualizations though the constructor function\n * ie. Contour.export('customLineChart', function (data, layer, options) {\n * // call the line chart directly\n * return this.line.renderer(data, layer, options);\n * });\n */\n Contour.prototype[ctorName].renderer = renderer;\n };\n\n\n /**\n * Exposes functionality to the core Contour object.\n * Use this to add *functionality* that will be available for any visualizations.\n *\n * ###Example:\n *\n * Contour.expose('example', function ctor(params) {\n * // params are the parameters passed into the constructor function\n * return {\n * // the init function, if provided, is called automatically upon instantiation of the functionality\n * // the options parameter has the global Contour options object\n * init: function (options) { ... },\n *\n * // when included in the instance, the function `.myFunction` is available in the visualizations\n * myFunction: function(data) { .... }\n * };\n * });\n *\n * Contour.export('visualizationThatUsesMyFunction', function(data, layer) {\n * //function body including call to this.myFunction(data)\n * });\n *\n * // to include the functionality into a specific instance\n * new Contour(options)\n * .example({ text: 'someText' })\n * .visualizationThatUsesMyFunction()\n * .render()\n *\n\n */\n Contour.expose = function (ctorName, functionalityConstructor) {\n var ctor = function () {\n var functionality = functionalityConstructor;\n if (typeof functionalityConstructor === 'function') {\n functionality = Object.create(functionalityConstructor);\n functionality = functionalityConstructor.apply(functionality, arguments);\n }\n\n // extend the --instance-- we don't want all charts to be overriden...\n _.extend(this, _.omit(functionality, 'init'));\n\n if(functionality.init) {\n functionality.init.call(this, this.options);\n }\n\n // keep a list of the included functionality into this instance\n // so we can match and check dependencies\n this._exposed.push(ctorName);\n\n return this;\n };\n\n Contour.prototype[ctorName] = ctor;\n\n return this;\n };\n\n Contour.prototype = _.extend(Contour.prototype, {\n _visualizations: undefined,\n\n _extraOptions: undefined,\n\n _exposed: undefined,\n\n // Initializes the instance of Contour\n init: function (options) {\n // for now, just store this options here...\n // the final set of options will be composed before rendering\n // after all components/visualizations have been added\n this.options = options || {};\n\n this._extraOptions = [];\n this._visualizations = [];\n this._exposed = [];\n\n return this;\n },\n\n calculateWidth: function () {\n\n // assume all in pixel units and border-box box-sizing\n var outerWidth = parseInt(_.nw.getStyle(this.options.el, 'width') || 0, 10);\n var paddingLeft = parseInt(_.nw.getStyle(this.options.el, 'padding-left') || 0, 10);\n var paddingRight = parseInt(_.nw.getStyle(this.options.el, 'padding-right') || 0, 10);\n\n var width = outerWidth - paddingRight - paddingLeft;\n\n return this.options.el ? (width || this.options.chart.defaultWidth) : this.options.chart.defaultWidth;\n },\n\n calculateHeight: function () {\n // assume all in pixel units and border-box box-sizing\n var outerHeight = parseInt(_.nw.getStyle(this.options.el, 'height') || 0, 10);\n var paddingTop = parseInt(_.nw.getStyle(this.options.el, 'padding-top') || 0, 10);\n var paddingBottom = parseInt(_.nw.getStyle(this.options.el, 'padding-bottom') || 0, 10);\n var height = outerHeight - paddingTop - paddingBottom;\n\n var containerHeight = this.options.el ? height : undefined;\n var calcWidth = this.options.chart.width;\n var ratio = this.options.chart.aspect || this.options.chart.defaultAspect;\n\n return !!containerHeight && containerHeight > 1 ? containerHeight : Math.round(calcWidth * ratio);\n },\n\n calcMetrics: function () {\n var options = this.options;\n\n this.adjustPadding();\n\n this.adjustTitlePadding();\n\n options.chart.width = options.chart.width || this.calculateWidth();\n options.chart.height = options.chart.height || this.calculateHeight();\n\n this.options = _.merge(options, {\n chart: {\n plotWidth: options.chart.width - options.chart.margin.left - options.chart.margin.right - options.chart.internalPadding.left - options.chart.padding.right,\n plotHeight: options.chart.height - options.chart.margin.top - options.chart.margin.bottom - options.chart.padding.top - options.chart.internalPadding.bottom,\n plotLeft: options.chart.margin.left + options.chart.internalPadding.left,\n plotTop: options.chart.margin.top + options.chart.padding.top\n }\n });\n\n if (this.options.chart.plotWidth <= 0 || this.options.chart.plotHeight <= 0) {\n console.warn('The chart has no space to render. Either the width/height is zero or you have too much padding\\nWidth: ' + options.chart.width +\n '\\nHeight: ' + options.chart.height +\n '\\npadding-left: ' + options.chart.padding.left +\n '\\npadding-right: ' + options.chart.padding.right +\n '\\npadding-top: ' + options.chart.padding.top +\n '\\npadding-bottom: ' + options.chart.padding.bottom);\n\n this.options.chart.plotWidth = this.options.chart.plotWidth < 0 ? 0 : this.options.chart.plotWidth;\n this.options.chart.plotHeight = this.options.chart.plotHeight < 0 ? 0 : this.options.chart.plotHeight;\n }\n },\n\n adjustPadding: function () {\n // overriden by components that need to adjust padding\n return this;\n },\n\n adjustTitlePadding: function () {\n // overriden by components that need to adjust padding\n return this;\n },\n\n composeOptions: function () {\n var allDefaults = _.merge({}, defaults);\n var mergeExtraOptions = function (opt) { _.merge(allDefaults, opt); };\n var mergeDefaults = function (vis) { _.merge(allDefaults, vis.renderer.defaults); };\n\n _.each(this._extraOptions, mergeExtraOptions);\n _.each(this._visualizations, mergeDefaults);\n\n // compose the final list of options right before start rendering\n this.options = _.merge(this.options, _.merge({}, allDefaults, this.options));\n },\n\n baseRender: function () {\n this.plotArea();\n\n return this;\n },\n\n /**\n * Renders this Contour instance and all its visualizations into the DOM.\n *\n * ### Example:\n *\n * new Contour({ el:'.myChart' })\n * .pie([1,2,3])\n * .render();\n *\n * @function render\n *\n */\n render: function () {\n this.composeOptions();\n\n this.calcMetrics();\n\n this.baseRender();\n\n this.renderVisualizations();\n\n return this;\n },\n\n /**\n * Clears this Contour instance and all its visualizations of any size information, so that on the next call to `render()` the instance is re-measured.\n *\n * The function takes two optional arguments `width` and `height`. If given a specific width/height the chart uses that sizing information on the next render.\n *\n * ### Example:\n *\n * var contour = new Contour({ el:'.myChart' })\n * .pie([1,2,3])\n * .render();\n *\n * var onResize = function(e) {\n * contour.resize().render();\n * }\n *\n * window.addEventListener('resize', onResize);\n *\n * @function resize\n * @param {Number} width (optional) The new width for the visualizations. If left blank, the width will be calcuated from options.el's parent.\n * @param {Number} height (optional) The new height for the visualizations. If left blank, the height will be calcuated from options.el's parent.\n */\n resize: function(width, height) {\n\n if (this.container)\n this.container.style('height', 0);\n\n delete this.options.chart.width;\n delete this.options.chart.height;\n delete this.options.chart.plotWidth;\n delete this.options.chart.plotHeight;\n delete this.options.chart.plotLeft;\n delete this.options.chart.plotTop;\n\n if (width)\n this.options.chart.width = width;\n\n if (height)\n this.options.chart.height = height;\n return this;\n },\n\n update: function () {\n this.calcMetrics();\n return this;\n },\n\n plotArea: function () {\n\n var chartOpt = this.options.chart;\n\n this.container = d3.select(this.options.el);\n // fix a flicker im web-kit when animating opacity and the chart is in an iframe\n this.container.attr('style', '-webkit-backface-visibility: hidden; position: relative');\n\n if(!this.svg) {\n this.svg = this.container\n .append('svg')\n .attr('viewBox', '0 0 ' + chartOpt.width + ' ' + chartOpt.height)\n .attr('preserveAspectRatio', 'xMinYMin')\n .attr('class', 'contour-chart')\n .attr('height', chartOpt.height)\n .append('g')\n .attr('transform', 'translate(' + chartOpt.margin.left + ',' + chartOpt.margin.top + ')');\n } else {\n this.svg\n .attr('transform', 'translate(' + chartOpt.margin.left + ',' + chartOpt.margin.top + ')');\n\n d3.select(this.svg.node().parentNode)\n .attr('viewBox', '0 0 ' + chartOpt.width + ' ' + chartOpt.height)\n .attr('height', chartOpt.height);\n }\n\n return this;\n },\n\n createVisualizationLayer: function (vis, id) {\n return this.svg.append('g')\n .attr('vis-id', id)\n .attr('vis-type', vis.type);\n },\n\n renderVisualizations: function () {\n\n _.each(this._visualizations, function (visualization, index) {\n var id = index + 1;\n var layer = visualization.layer || this.createVisualizationLayer(visualization, id);\n var opt = _.merge({}, this.options, visualization.options);\n\n layer.attr('transform', 'translate(' + this.options.chart.internalPadding.left + ',' + (this.options.chart.padding.top || 0) + ')');\n\n visualization.layer = layer;\n visualization.parent = this;\n visualization.render(layer, opt, this);\n }.bind(this));\n\n return this;\n },\n\n /**\n * Assert that all the dependencies are in the Contour instance.\n * For example, if a visualization requires Cartesian to be included in the instance,\n * it could call this.checkDependencies('Cartesian'), and the framework would\n * give a helpful error message if Cartesian was not included.\n *\n * @function checkDependencies\n * @param {string|array} list of dependencies (as specified in the instance constructor)\n *\n */\n checkDependencies: function (listOfDependencies) {\n listOfDependencies = _.isArray(listOfDependencies) ? listOfDependencies : [listOfDependencies];\n var _this = this;\n var missing = [];\n\n _.each(listOfDependencies, function (dep) {\n if (_this._exposed.indexOf(dep) === -1) {\n missing.push(dep);\n }\n });\n\n if (missing.length) {\n throw new Error('ERROR: Missing depeendencies in the Contour instance (ej. new Contour({}).cartesian())\\n The missing dependencies are: [' + missing.join(', ') + ']\\nGo to http://forio.com/contour/documentation.html#key_concepts for more information');\n }\n },\n\n ensureDefaults: function (options, renderer) {\n if (_.isString(renderer)) {\n renderer = this[renderer].renderer;\n }\n\n if (renderer.defaults) {\n var defaults = renderer.defaults;\n options = _.defaults(options || {}, defaults);\n this.options = _.defaults(this.options, defaults);\n }\n },\n\n /**\n * Sets the same data into all visualizations for a Contour instance. Useful for creating interactive\n * visualizations: call after getting the additional data from the user.\n *\n * ###Example:\n *\n * var data = [1,2,3,4,5];\n * var chart = new Contour({ el:'.myChart' })\n * .cartesian()\n * .scatter(data)\n * .trendLine(data);\n *\n * data.push(10);\n * chart.setData(data)\n * .render();\n *\n * @function setData\n *\n */\n setData: function (data) {\n _.invokeMap(this._visualizations, 'setData', data);\n\n return this;\n },\n\n /**\n * Returns a VisualizationContainer object for the visualization at a given index (0-based).\n *\n * ###Example:\n *\n * var chart = new Contour({ el:'.myChart' })\n * .pie([1,2,3])\n * .render();\n *\n * var myPie = chart.select(0);\n *\n * // do something with the visualization, for example updating its data set\n * myPie.setData([6,7,8,9]).render();\n *\n * @function select\n *\n */\n select: function (index) {\n return this._visualizations[index];\n },\n\n // place holder function for now\n data: function () {\n\n },\n\n dataNormalizer: _.nw.normalizeSeries,\n\n isSupportedDataFormat: _.nw.isSupportedDataFormat\n });\n\n // exports for commonJS and requireJS styles\n if (typeof module === 'object' && module && typeof module.exports === 'object') {\n module.exports = Contour;\n } else {\n root.Contour = Contour;\n if (typeof define === 'function' && define.amd) {\n define('contour', [], function () { return Contour; });\n }\n }\n\n})();\n","(function () {\n\n var YAxis = function (data, options, domain) {\n this.data = data;\n this.options = options;\n this.domain = domain;\n };\n\n function setRange(scale, options) {\n var rangeSize = options.chart.rotatedFrame ? options.chart.plotWidth : options.chart.plotHeight;\n var range = options.chart.rotatedFrame ? [0, rangeSize] : [rangeSize, 0];\n return scale.range(range);\n }\n\n YAxis.prototype = {\n axis: function () {\n /*jshint eqnull:true */\n var options = this.options.yAxis;\n var domain = this.domain;\n var dMin = options.min != null ? options.min : options.zeroAnchor ? Math.min(0, domain[0]) : domain[0];\n var dMax = options.max != null ? options.max : domain[1];\n var tickValues = options.tickValues || _.nw.niceTicks(dMin, dMax, options.ticks);\n var numTicks = this.numTicks(domain, options.min, options.max);\n var format = options.labels.formatter || d3.format(options.labels.format);\n\n return d3.svg.axis()\n .scale(this._scale)\n .tickFormat(format)\n .tickSize(options.innerTickSize, options.outerTickSize)\n .tickPadding(options.tickPadding)\n .ticks(numTicks)\n .tickValues(tickValues);\n },\n\n scale: function (domain) {\n if(!this._scale) {\n this._scale = d3.scale.linear();\n this.setDomain(domain);\n }\n\n setRange(this._scale, this.options);\n return this._scale;\n },\n\n setDomain: function (domain) {\n this._scale.domain(domain);\n this._niceTheScale();\n return this._scale;\n },\n\n update: function (domain, dataSrc) {\n this.data = dataSrc;\n this.setDomain(domain);\n this.scale();\n },\n\n /*jshint eqnull:true*/\n numTicks: function () {\n return this.options.yAxis.ticks != null ? this.options.yAxis.ticks : undefined;\n },\n\n _niceTheScale: function () {\n // nothing to do for the regular y-axis\n }\n };\n\n _.nw.addAxis('YAxis', YAxis);\n\n})();\n","(function () {\n /*jshint eqnull:true */\n var defaults = {\n chart: {\n gridlines: 'none',\n padding: {\n top: 6,\n right: 5,\n // this get's defined based on the axis & title\n bottom: undefined,\n // this get's defined based on the axis & title\n left: undefined\n }\n },\n\n xAxis: {\n // type of axis {ordinal|linear|time}\n type: null, // default is linear in line.js (needs to be null here so overrides work)\n categories: undefined,\n max: undefined,\n min: undefined,\n innerTickSize: 6,\n outerTickSize: 0,\n tickPadding: 6,\n maxTicks: undefined,\n ticks: undefined,\n tickValues: undefined,\n title: undefined,\n titlePadding: 4,\n // padding between ranges (ie. columns) expressed in percentage of rangeBand width\n innerRangePadding: 0.1,\n // padding between all ranges (ie. columns) and the axis (left & right) expressed in percentage of rangeBand width\n outerRangePadding: 0.1,\n firstAndLast: false,\n orient: 'bottom',\n labels: {\n format: undefined,\n formatter: undefined\n },\n linearDomain: false, // specify if a time domain should be treated linearly or ....\n },\n\n yAxis: {\n // @param: {linear|smart|log}\n // type: 'smart',\n min: undefined,\n max: undefined,\n zeroAnchor: true,\n smartAxis: false,\n innerTickSize: 6,\n outerTickSize: 6,\n tickPadding: 4,\n tickValues: undefined,\n ticks: undefined,\n title: undefined,\n titlePadding: 4,\n orient: 'left',\n labels: {\n // top, middle, bottom\n verticalAlign: 'middle',\n format: 's', // d3 formats\n formatter: undefined // a function that formats each value ie. function (datum) { return 'x: ' + datum.x + ', y:' + datum.y }\n }\n }\n };\n\n\n /**\n * Provides a Cartesian frame to the Contour instance.\n *\n * This is required for all visualizations displayed in a Cartesian frame, for example line charts, bar charts, area charts, etc. It is not required otherwise; for instance, pie charts do not use a Cartesian frame.\n *\n * ###Example:\n *\n * new Contour(options)\n * .cartesian();\n *\n * @name cartesian\n */\n var cartesian = function () {\n var maxTickSize = function (options) { return Math.max(options.outerTickSize || 0, options.innerTickSize || 0); };\n return {\n dataSrc: [],\n\n init: function (options) {\n\n // readonly properties (ie. user cannot modify)\n var readOnlyProps = {\n chart: {\n rotatedFrame: false,\n internalPadding: {\n bottom: undefined,\n left: undefined\n }\n }\n };\n\n this.options = options || {};\n\n _.merge(this.options, readOnlyProps);\n\n var extraPadding = {};\n if (!this.options.xAxis || !this.options.xAxis.firstAndLast) {\n extraPadding = { chart : { padding: { right: 15 }}};\n }\n\n this._extraOptions.push(_.merge({}, defaults, extraPadding));\n\n return this;\n },\n\n xDomain: [],\n yDomain: [],\n\n _getYScaledDomain: function (domain, options) {\n var opts = this.options.yAxis;\n var absMin = opts.zeroAnchor && domain && domain[0] > 0 ? 0 : undefined;\n var min = opts.min != null ? opts.min : absMin;\n\n if (opts.tickValues) {\n if (opts.min != null && opts.max != null) {\n return [opts.min, opts.max];\n } else if (opts.min != null) {\n return [opts.min, d3.max(opts.zeroAnchor ? [0].concat(opts.tickValues) : opts.tickValues)];\n } else if (opts.max != null) {\n return [d3.min(opts.zeroAnchor ? [0].concat(opts.tickValues) : opts.tickValues), opts.max];\n } else {\n return d3.extent(opts.zeroAnchor || opts.min != null ? [min].concat(opts.tickValues) : opts.tickValues);\n }\n } else if (opts.smartAxis) {\n return d3.extent(opts.zeroAnchor || opts.min != null ? [min].concat(domain) : domain);\n }\n\n return _.nw.extractScaleDomain(domain, min, opts.max, opts.ticks);\n },\n\n /*jshint eqnull:true */\n adjustPadding: function () {\n var xOptions = this.options.xAxis;\n var yOptions = this.options.yAxis;\n // bottom padding calculations\n if (this.options.chart.padding.bottom == null) {\n this.options.chart.internalPadding.bottom = this._getAdjustedBottomPadding(xOptions);\n } else {\n this.options.chart.internalPadding.bottom = this.options.chart.padding.bottom || 0;\n }\n\n this.options.chart.padding.top = this.options.chart.internalPadding.top = this._getAdjustedTopPadding(xOptions);\n\n // left padding calculations\n if (this.options.chart.padding.left == null) {\n this.options.chart.internalPadding.left = this._getAdjustedLeftPadding(yOptions);\n } else {\n this.options.chart.internalPadding.left = this.options.chart.padding.left;\n }\n\n this.options.chart.padding.right = this.options.chart.internalPadding.right = this._getAdjustedRightPadding(yOptions);\n },\n\n _getAdjustedTopPadding: function (options) {\n return this.options.chart.padding.top;\n },\n\n _getAdjustedBottomPadding: function (options) {\n if (options.ticks !== 0) {\n var xLabels = this.xDomain;\n var xAxisText = xLabels.join('
');\n var xLabelBounds = _.nw.textBounds(xAxisText, '.x.axis');\n var regularXBounds = _.nw.textBounds('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890', '.x.axis');\n var em = regularXBounds.height;\n var ang = options.labels && options.labels.rotation ? options.labels.rotation % 360 : 0;\n var xLabelHeightUsed = ang === 0 ? regularXBounds.height : Math.ceil(Math.abs(xLabelBounds.width * Math.sin(_.nw.degToRad(ang))) + em / 5) ;\n return maxTickSize(options) + (options.tickPadding || 0) +\n xLabelHeightUsed;\n } else {\n return maxTickSize(options) + (options.tickPadding || 0);\n }\n },\n\n _getAdjustedLeftPadding: function (options) {\n var yDomainScaled = this._getYScaledDomain(this.yDomain, this.options);\n var tmpScale = d3.scale.linear().domain(yDomainScaled);\n var yLabels = tmpScale.ticks(options.ticks);\n\n var format = options.labels.formatter || d3.format(options.labels.format || ',.0f');\n var yAxisText = _.map(yLabels, format).join('
');\n var yLabelBounds = _.nw.textBounds(yAxisText, '.y.axis');\n return maxTickSize(this.options.yAxis) + (this.options.yAxis.tickPadding || 0) +\n yLabelBounds.width;\n },\n\n _getAdjustedRightPadding: function (options) {\n return this.options.chart.padding.right;\n },\n\n adjustTitlePadding: function () {\n var titleBounds;\n if (this.options.xAxis.title || this.options.yAxis.title) {\n if(this.options.xAxis.title) {\n titleBounds = _.nw.textBounds(this.options.xAxis.title, '.x.axis-title');\n this.options.chart.internalPadding.bottom += titleBounds.height + this.options.xAxis.titlePadding;\n }\n\n if(this.options.yAxis.title) {\n titleBounds = _.nw.textBounds(this.options.yAxis.title, '.y.axis-title');\n this.options.chart.internalPadding.left += titleBounds.height + this.options.yAxis.titlePadding;\n }\n }\n },\n\n computeXScale: function () {\n if (!this.xDomain) throw new Error('You are trying to render without setting data (xDomain).');\n\n if(!this.xScale) {\n this.xScaleGenerator = _.nw.xScaleFactory(this.dataSrc, this.options);\n this.xScale = this.xScaleGenerator.scale(this.xDomain);\n this.rangeBand = this.xScaleGenerator.rangeBand();\n } else {\n this.xScaleGenerator.update(this.xDomain, this.dataSrc);\n this.rangeBand = this.xScaleGenerator.rangeBand();\n }\n },\n\n computeYScale: function () {\n if (!this.yDomain) throw new Error('You are trying to render without setting data (yDomain).');\n\n var yScaleDomain = this._getYScaledDomain(this.yDomain, this.options);\n\n if(!this.yScale) {\n this.yScaleGenerator = _.nw.yScaleFactory(this.dataSrc, this.options, this.options.yAxis.type, this.yDomain);\n this.yScale = this.yScaleGenerator.scale(yScaleDomain);\n } else {\n this.yScaleGenerator.update(yScaleDomain, this.dataSrc);\n }\n },\n\n /**\n * Provides a scaling function based on the xAxis values.\n *\n * ###Example:\n *\n * var scaledValue = this.xScale(100);\n *\n * @function xScale\n * @param {Number|String} value The value to be scaled.\n * @return {Number} The scaled value according to the current xAxis settings.\n */\n xScale: undefined,\n\n /**\n * Provides a scaling function based on the yAxis values.\n *\n * ###Example:\n *\n * var scaledValue = this.yScale(100);\n *\n * @function yScale\n * @param {Number} value The value to be scaled.\n * @return {Number} The scaled value according to the current yAxis settings.\n */\n yScale: undefined,\n\n /**\n * Modifies the domain for the yAxis.\n *\n * ###Example:\n *\n * this.setYDomain([100, 200]);\n *\n * @function setYDomain\n * @param {Array} domain The domain array representing the min and max values visible on the yAxis. */\n setYDomain: function (domain) {\n this.yScaleGenerator.setDomain(domain);\n },\n\n /**\n * Redraws the yAxis with the new settings and domain.\n *\n * ###Example:\n *\n * this.redrawYAxis();\n *\n * @function redrawYAxis\n */\n redrawYAxis: function () {\n this.svg.select('.y.axis').call(this.yAxis());\n this.renderGridlines();\n },\n\n _animationDuration: function () {\n var opt = this.options.chart.animations;\n return opt && opt.enable ?\n opt.duration != null ? opt.duration : 400 :\n 0;\n },\n\n computeScales: function () {\n this.computeXScale();\n this.computeYScale();\n\n return this;\n },\n\n _xAxis: undefined,\n xAxis: function () {\n if (!this._xAxis) {\n this._xAxis = this.xScaleGenerator.axis().orient(this.options.xAxis.orient);\n }\n return this._xAxis;\n },\n\n _yAxis: undefined,\n yAxis: function () {\n if(!this._yAxis) {\n this._yAxis = this.yScaleGenerator.axis().orient(this.options.yAxis.orient);\n }\n return this._yAxis;\n },\n\n renderXAxis: function () {\n var xAxis = this.xAxis();\n var y = this.options.chart.plotHeight + this.options.chart.padding.top;\n var x = this.options.chart.internalPadding.left;\n\n this._xAxisGroup = this.svg.selectAll('.x.axis')\n .data([1]);\n\n if (!this._xAxisGroup.node()) {\n this._xAxisGroup.enter()\n .append('g')\n .attr('transform', 'translate(' + x + ',' + y + ')')\n .attr('class', 'x axis');\n } else {\n d3.select(this._xAxisGroup.node())\n .attr('transform', 'translate(' + x + ',' + y + ')');\n }\n\n\n this._xAxisGroup\n .transition().duration(this._animationDuration())\n .call(xAxis);\n\n this.xScaleGenerator.postProcessAxis(this._xAxisGroup);\n\n return this;\n },\n\n renderYAxis: function () {\n var x = this.options.chart.internalPadding.left;\n var y = this.options.chart.padding.top;\n\n this._yAxisGroup = this.svg.selectAll('.y.axis')\n .data([1]);\n\n if (!this._yAxisGroup.node()) {\n this._yAxisGroup\n .enter().append('g')\n .attr('transform', 'translate(' + x + ',' + y + ')')\n .attr('class', 'y axis');\n } else {\n d3.select(this._yAxisGroup.node())\n .attr('transform', 'translate(' + x + ',' + y + ')');\n }\n\n this._renderYAxisElement();\n\n return this;\n },\n\n _renderYAxisElement: function () {\n var options = this.options.yAxis;\n var alignmentOffset = { bottom: '.8em', middle: '.35em', top: '0' };\n\n this._yAxisGroup\n .transition().duration(this._animationDuration())\n .call(this.yAxis())\n .selectAll('.tick text')\n .attr('dy', alignmentOffset[options.labels.verticalAlign]);\n },\n\n renderAxisLabels: function () {\n var adjustFactor = 40/46.609; // this factor is to account for the difference between the actual svg size and what we get from the DOM\n var bounds, x, y;\n var el;\n\n if (this.options.xAxis.title) {\n bounds = _.nw.textBounds(this.options.xAxis.title, '.x.axis-title');\n y = this.options.chart.internalPadding.bottom;\n x = 0;\n el = this._xAxisGroup.selectAll('.x.axis-title').data([1]);\n if (!el.node()) {\n el.enter().append('text')\n .attr('class', 'x axis-title');\n }\n\n d3.select(el.node())\n .attr('x', x)\n .attr('y', y)\n .attr('alignment-baseline', 'after-edge')\n .attr('dx', (this.options.chart.plotWidth - bounds.width) / 2)\n .text(this.options.xAxis.title);\n }\n\n if (this.options.yAxis.title) {\n bounds = _.nw.textBounds(this.options.yAxis.title, '.y.axis-title');\n y = -this.options.chart.internalPadding.left + bounds.height * adjustFactor;\n x = 0;\n el = this._yAxisGroup.selectAll('.y.axis-title').data([1]);\n if (!el.node()) {\n el.enter().append('text')\n .attr('class', 'y axis-title');\n }\n\n d3.select(el.node())\n .attr('class', 'y axis-title')\n .attr('transform', 'rotate(-90)')\n .attr('x', x)\n .attr('y', y)\n .attr('dx', -(this.options.chart.plotHeight + bounds.width) / 2)\n .attr('dy', 0)\n .text(this.options.yAxis.title);\n }\n\n return this;\n },\n\n renderGridlines: function () {\n var option = this.options.chart.gridlines;\n var horizontal = option === 'horizontal' || option === 'both';\n var vertical = option === 'vertical' || option === 'both';\n\n function getYTicks(axis, smart) {\n var tickValues = axis.tickValues();\n\n if(!tickValues) {\n var numTicks = axis.ticks()[0];\n return axis.scale().ticks(numTicks).slice(1);\n }\n\n if (smart) {\n tickValues.pop();\n }\n\n return tickValues.slice(1);\n }\n\n function getXTicks(axis) {\n return axis.tickValues() || (axis.scale().ticks ? axis.scale().ticks().slice(1) : axis.scale().domain());\n }\n\n var ticks, gr;\n var x = this.xScale;\n var y = this.yScale;\n\n if(horizontal) {\n ticks = getYTicks(this.yAxis(), this.options.yAxis.smartAxis);\n var w = this.options.chart.plotWidth;\n\n // remove previous lines (TODO: we need a better way)\n // this._yAxisGroup.select('g.grid-lines').remove();\n gr = this._yAxisGroup\n .selectAll('.grid-lines')\n .data([ticks]);\n\n gr.enter().append('svg:g')\n .attr('class', 'grid-lines');\n\n var lines = gr.selectAll('.grid-line')\n .data(function (d) { return d; });\n\n lines.transition().duration(this._animationDuration())\n .attr('x1', 0)\n .attr('x2', function () {\n return w;\n })\n .attr('y1', y)\n .attr('y2', y);\n\n lines.enter().append('line')\n .attr('class', 'grid-line')\n .attr('x1', 0)\n .attr('x2', function () {\n return w;\n })\n .attr('y1', y)\n .attr('y2', y);\n\n lines.exit().remove();\n }\n\n if(vertical) {\n // remove previous lines (TODO: we need a better way)\n this._xAxisGroup.select('g.grid-lines').remove();\n gr = this._xAxisGroup.append('svg:g').attr('class', 'grid-lines');\n ticks = getXTicks(this.xAxis());\n var offset = this.rangeBand / 2;\n var h = this.options.chart.plotHeight;\n\n gr.selectAll('.grid-line')\n .data(ticks)\n .enter().append('line')\n .attr('class', 'grid-line')\n .attr('x1', function (d) { return x(d) + offset; })\n .attr('x2', function (d) { return x(d) + offset; })\n .attr('y1', -h)\n .attr('y2', 0);\n }\n\n return this;\n },\n\n renderBackground: function () {\n var options = this.options.chart;\n this.background = this.background || this.createVisualizationLayer('background', 0);\n var g = this.background.selectAll('.plot-area-background').data([null]);\n\n g.enter().append('rect')\n .attr('class', 'plot-area-background')\n .attr('x', options.internalPadding.left)\n .attr('y', options.internalPadding.top)\n .attr('width', options.plotWidth)\n .attr('height', options.plotHeight);\n\n g.exit().remove();\n\n return this;\n },\n\n render: function () {\n\n this.composeOptions();\n this.adjustDomain();\n this.calcMetrics();\n this.computeScales();\n this.baseRender();\n\n this\n .renderBackground()\n .renderXAxis()\n .renderYAxis()\n .renderGridlines()\n .renderAxisLabels()\n .renderVisualizations();\n\n return this;\n },\n\n datum: function (d, index) {\n if(_.isObject(d) && _.isArray(d.data))\n return _.map(d.data, _.bind(this.datum, this));\n\n return {\n y: _.isObject(d) ? d.y : d,\n x: _.isObject(d) ? d.x : this.options.xAxis.categories ? this.options.xAxis.categories[index] : index\n };\n },\n\n adjustDomain: function () {\n var extents = this.getExtents();\n this._adjustXDomain(extents);\n this._adjustYDomain(extents);\n\n this._yAxis = null;\n this._xAxis = null;\n this.yScale = null;\n },\n\n _adjustXDomain: function (extents) {\n this.xDomain = this.getXDomain();\n var dataVis = _.filter(this._visualizations, function (v) { return _.nw.isSupportedDataFormat(v.data); });\n this.dataSrc = _.flatten(\n _.map(dataVis, function (v) {\n return _.flatten(_.map(v.data, _.bind(this.datum, this)));\n }.bind(this))\n );\n\n // _.every() on empty array returns true, so we guard against it\n var isCategoricalData = this.dataSrc.length && _.every(this.dataSrc, function (d) { return +d.x !== d.x; });\n var dataSrcCategories = _.uniq(_.map(this.dataSrc, 'x'));\n var sameCats = this.options.xAxis.categories ?\n this.options.xAxis.categories.length === dataSrcCategories.length && _.intersection(this.options.xAxis.categories, dataSrcCategories).length === dataSrcCategories.length :\n false;\n\n if (isCategoricalData && !(this.options.xAxis.categories && sameCats)) {\n this.options.xAxis.categories = dataSrcCategories;\n }\n },\n\n _adjustYDomain: function (extents) {\n this.yDomain = extents.length ? extents : [0, 10];\n this.yMin = this.yDomain[0];\n this.yMax = this.yDomain[this.yDomain.length - 1];\n },\n\n getExtents: function (axis) {\n var field = axis && axis === 'x' ? 'xExtent' : 'yExtent';\n var dataVis = _.filter(this._visualizations, function (v) { return _.nw.isSupportedDataFormat(v.data); });\n var all = _.flatten(_.map(dataVis, field));\n return all.length ? d3.extent(all) : [];\n },\n\n getXDomain: function () {\n var dataVis = _.filter(this._visualizations, function (v) { return _.nw.isSupportedDataFormat(v.data); });\n var all = _.nw.uniq(_.flatten(_.map(dataVis, 'xDomain')));\n\n return all;\n }\n\n };\n };\n\n Contour.expose('cartesian', cartesian);\n\n})();\n","(function () {\n\n var root = this;\n\n var defaultParams = {\n type: 'image/png', // the mime type of the image; see http://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support for browser support\n fileName: 'contour.png', // the fileName for the `download()`\n target: undefined, // a selector for the container in which to `place()` the image; for example '#image'\n backgroundColor: '#fff', // the fill color of the image, or `null` for transparent background\n width: undefined, // the width of the exported image; if `height` is falsy then the height will be scaled proportionally\n height: undefined // the height of the exported image; if `width` is falsy then the width will be scaled proportionally\n };\n\n // browser capabilities\n var browser = {\n checked: false // true after browser capabilities have been checked\n };\n\n // queue of operations to perform synchronously\n var queue = [];\n // true if working on something\n var working = false;\n\n\n /**\n * Saves a visualization as an image.\n * You can either trigger a download of the image or place the image within a container.\n *\n * ###Example:\n *\n * var chart = new Contour(...)\n * ...\n * .exportable()\n * .render();\n *\n * document.getElementById('save').onclick = function () {\n * chart.download({\n * fileName: 'myContourChart.png'\n * });\n *\n * ###External dependencies:\n *\n * IE9-11 and Safari won't safely export a canvas to which an SVG has been\n * rendered. To get around this limitation in those browsers, we use CanVG\n * (\"canned veggies\"), an implementation of SVG written in JavaScript to\n * render the SVG directly to the canvas. During initialization of the\n * 'exportable' plugin, CanVG is automatically downloaded from\n * http://canvg.googlecode.com/svn/trunk/ if the browser fails the test\n * SVG export.\n *\n * @name exportable\n */\n var exportable = function () {\n // CSS properties to ignore for diff\n var cssIgnoreDiff = {\n cssText: 1,\n parentRule: 1\n };\n // CSS properties shared between HTML and SVG\n var cssSharedSvg = {\n font: 1,\n fontFamily: 1,\n fontSize: 1,\n fontSizeAdjust: 1,\n fontStretch: 1,\n fontStyle: 1,\n fontVariant: 1,\n fontWeight: 1,\n direction: 1,\n letterSpacing: 1,\n textDecoration: 1,\n unicodeBidi: 1,\n wordSpacing: 1,\n clip: 1,\n cursor: 1,\n display: 1,\n overflow: 1,\n visibility: 1,\n opacity: 1\n };\n\n\n // interface\n\n return {\n init: function () {\n // check browser capabilities and set up necessary shims\n // only do this once per page load\n if (!browser.checked) {\n addToQueue(checkBrowser);\n }\n\n return this;\n },\n\n /**\n * Saves a visualization as an image, triggering a download.\n *\n * ###Browser variations:\n *\n * - Chrome saves the image.\n * - Firefox and IE10-11 display a prompt, then save the image.\n * - IE9 and Safari open the image in a new tab, enabling the user to manually save the image.\n *\n * ###Example:\n *\n * var chart = new Contour(...)\n * ...\n * .exportable()\n * .render();\n *\n * document.getElementById('save').onclick = function () {\n * chart.download({\n * fileName: 'contour.png',\n * width: 640\n * });\n *\n * @name download\n * @param {object} options Configuration options specific to downloading the image.\n * @param {string} options.type Specifies the mime type of the image. See http://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support for browser support. Default: 'image/png'.\n * @param {string} options.fileName Specifies the file name for the download. Default: 'contour.png'.\n * @param {string} options.backgroundColor Specifies the fill color of the image. Use `null` for transparent background. Default: '#fff'.\n * @param {int} options.width Specifies the width of the exported image. If `height` is falsy then the height is scaled proportionally. Default: `undefined`, which means don't do any scaling.\n * @param {int} options.height Specifies the height of the exported image. If `width` is falsy then the width is scaled proportionally. Default: `undefined`, which means don't do any scaling.\n */\n download: function (options) {\n var container = this.container;\n\n addToQueue(function () {\n exportImage(container, options, 'download');\n });\n\n return this;\n },\n\n /**\n * Saves a visualization as an image, placing it within a container.\n *\n * ###Example:\n *\n * var chart = new Contour(...)\n * ...\n * .exportable()\n * .render();\n * document.getElementById('save').onclick = function () {\n * chart.place({\n * target: '#image'\n * });\n *\n * @name place\n * @param {object} options Configuration options specific to placing the image in a container.\n * @param {string} options.type Specifies the mime type of the image. See http://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support for browser support. Default: 'image/png'.\n * @param {string} options.target Specifies a selector for the container. For example: '#image' will append the image into `
`.\n * @param {string} options.backgroundColor Specifies the fill color of the image. Use `null` for transparent background. Default: '#fff'.\n * @param {int} options.width Specifies the width of the exported image. If `height` is falsy then the height is scaled proportionally. Default: `undefined`, which means don't do any scaling.\n * @param {int} options.height specifies the height of the exported image. If `width` is falsy then the width is scaled proportionally. Default: `undefined`, which means don't do any scaling.\n */\n place: function (options) {\n var container = this.container;\n\n addToQueue(function () {\n exportImage(container, options, 'place');\n });\n\n return this;\n }\n };\n\n\n // SVG to canvas export function\n // adapted from https://github.com/sampumon/SVG.toDataURL\n // which based on http://svgopen.org/2010/papers/62-From_SVG_to_Canvas_and_Back/#svg_to_canvas\n function getSvgDataUrl(svg, options, dataUrlCreated) {\n switch (options.type) {\n case 'image/svg+xml':\n return makeSvgUrl();\n\n default: // 'image/png' or 'image/jpeg'\n return makeImageUrl();\n }\n\n\n function encodeBase64DataUrl(svgXml) {\n // https://developer.mozilla.org/en/DOM/window.btoa\n return 'data:image/svg+xml;base64,' + btoa(svgXml);\n }\n\n // convert base64/URLEncoded data component to raw binary data held in a string\n function dataUrlToBlob(dataUrl) {\n /*jshint nonstandard:true*/\n var byteString;\n if (dataUrl.split(',')[0].indexOf('base64') >= 0) {\n byteString = atob(dataUrl.split(',')[1]);\n } else {\n byteString = unescape(dataUrl.split(',')[1]);\n }\n\n // separate out the mime component\n var mimeString = dataUrl.split(',')[0].split(':')[1].split(';')[0];\n\n // write the bytes of the string to a typed array\n var byteArray = new Uint8Array(byteString.length);\n for (var i = 0; i < byteString.length; i++) {\n byteArray[i] = byteString.charCodeAt(i);\n }\n\n return new Blob([byteArray], {\n type: mimeString\n });\n }\n\n function makeSvgUrl() {\n var svgXml = (new XMLSerializer()).serializeToString(svg);\n var svgDataUrl = encodeBase64DataUrl(svgXml);\n\n dataUrlCreated(svgDataUrl, null, function () {});\n }\n\n function makeImageUrl() {\n var canvas = document.createElement('canvas');\n var context = canvas.getContext('2d');\n\n var svgXml = (new XMLSerializer()).serializeToString(svg);\n\n if (root.canvg) {\n // use Canvg renderer for image export\n renderImageCanvg();\n } else {\n // use native renderer for image export (this might fail)\n renderImageNative();\n }\n\n function imageRendered() {\n var imageDataUrl = canvas.toDataURL(options.type);\n\n if (browser.createsObjectUrls) {\n var imageBlob = dataUrlToBlob(imageDataUrl);\n\n var domUrl = root.URL || root.webkitURL;\n var objectUrl = domUrl.createObjectURL(imageBlob);\n\n dataUrlCreated(objectUrl, imageBlob, function () {\n domUrl.revokeObjectURL(objectUrl);\n });\n } else {\n dataUrlCreated(imageDataUrl, null, function () {});\n }\n }\n\n function renderImageNative() {\n var svgImg = new Image();\n svgImg.src = encodeBase64DataUrl(svgXml);\n\n svgImg.onload = function () {\n canvas.width = svgImg.width;\n canvas.height = svgImg.height;\n\n if (options.backgroundColor) {\n context.fillStyle = options.backgroundColor;\n context.fillRect(0, 0, svgImg.width, svgImg.height);\n }\n\n context.drawImage(svgImg, 0, 0);\n\n imageRendered();\n };\n\n svgImg.onerror = function () {\n throw new Error('Cannot export image');\n };\n }\n\n function renderImageCanvg() {\n // note that Canvg gets the SVG element dimensions incorrectly if not specified as attributes\n // also this Canvg call is synchronous and blocks\n canvg(canvas, svgXml, {\n ignoreMouse: true,\n ignoreAnimation: true,\n offsetX: undefined,\n offsetY: undefined,\n scaleWidth: undefined,\n scaleHeight: undefined,\n renderCallback: imageRendered\n });\n }\n }\n }\n\n\n // clone SVG in isolation with styles directly applied\n function createSvgClone(svgNode, svgCloned) {\n createIsolatedNode(function (nodeClone, destroyIsolatedNode) {\n // clone nodes and apply styles directly to each node\n cloneNodes(svgNode, nodeClone);\n\n // clone legend DIV as SVG\n cloneLegendDiv(svgNode, nodeClone);\n\n svgCloned(d3.select(nodeClone).select('svg').node(), destroyIsolatedNode);\n });\n\n\n // compare computed styles at this node and apply the differences directly\n function applyStyles(sourceNode, targetNode) {\n var sourceStyle = root.getComputedStyle(sourceNode);\n var targetStyle = root.getComputedStyle(targetNode);\n\n for (var prop in sourceStyle) {\n if (!cssIgnoreDiff[prop] && !isFinite(prop)) {\n // note that checking for sourceStyle.hasOwnProperty(prop) eliminates all valid style properties in Firefox\n if (targetStyle[prop] !== sourceStyle[prop]) {\n targetNode.style[prop] = sourceStyle[prop];\n }\n }\n }\n }\n\n // clone nodes and apply styles directly to each node\n function cloneNodes(sourceNode, targetNode) {\n var newNode = sourceNode.cloneNode(false);\n targetNode.appendChild(newNode);\n\n if (!sourceNode.tagName) return; // skip inner text\n\n // compare computed styles at this node and apply the differences directly\n applyStyles(sourceNode, newNode);\n\n _.each(sourceNode.childNodes, function (childNode) {\n // clone each child node and apply styles\n cloneNodes(childNode, newNode);\n });\n }\n\n function createIsolatedNode(nodeLoaded) {\n var iframe = document.body.appendChild(document.createElement('iframe'));\n iframe.style.visibility = 'hidden';\n var iframeWindow = iframe.contentWindow;\n var iframeDocument = iframeWindow.document;\n\n iframe.onload = function () {\n var nodeClone = iframeDocument.createElement('div');\n iframeDocument.body.appendChild(nodeClone);\n\n var destroyIframe = function () {\n // destroy clone\n iframeDocument.body.removeChild(nodeClone);\n document.body.removeChild(iframe);\n };\n\n nodeLoaded(nodeClone, destroyIframe);\n };\n\n iframeDocument.open();\n iframeDocument.write('');\n iframeDocument.write('');\n iframeDocument.close();\n }\n\n function applyDivStylesToSvg(sourceNode, target) {\n var targetNode = target.node();\n var sourceStyle = root.getComputedStyle(sourceNode);\n var targetStyle = root.getComputedStyle(targetNode);\n\n for (var prop in sourceStyle) {\n if (cssSharedSvg[prop]) {\n // note that checking for sourceStyle.hasOwnProperty(prop) eliminates all valid style properties in Firefox\n if (targetStyle[prop] !== sourceStyle[prop]) {\n targetNode.style[prop] = sourceStyle[prop];\n }\n }\n }\n\n // translate DIV styles to SVG attributes and styles\n switch (targetNode.nodeName) {\n case 'rect':\n target.attr({\n 'rx': sourceStyle.borderTopLeftRadius,\n 'ry': sourceStyle.borderTopLeftRadius\n });\n target.style({\n 'fill': sourceStyle.backgroundColor,\n 'stroke': sourceStyle.borderLeftColor,\n 'stroke-width': sourceStyle.borderLeftWidth\n });\n break;\n case 'text':\n target.style({\n 'fill': sourceStyle.color\n });\n break;\n }\n }\n\n function cloneLegendDiv(sourceNode, targetNode) {\n var containerDiv = d3.select(sourceNode.parentNode).select('div.contour-legend');\n if (containerDiv.empty()) return;\n\n var containerDivNode = containerDiv.node();\n\n var containerSvg = d3.select(targetNode).select('svg').append('g')\n .attr('transform', 'translate(' + (containerDivNode.offsetLeft + containerDivNode.clientLeft) +\n ',' + (containerDivNode.offsetTop + containerDivNode.clientTop) + ')');\n applyDivStylesToSvg(containerDivNode, containerSvg);\n\n var rect = containerSvg.append('rect')\n .attr('width', containerDivNode.clientWidth)\n .attr('height', containerDivNode.clientHeight);\n applyDivStylesToSvg(containerDivNode, rect);\n\n var entriesDivs = containerDiv.selectAll('.contour-legend-entry');\n\n _.each(entriesDivs[0], function (entryDivNode) {\n var entryDiv = d3.select(entryDivNode);\n\n var enter = containerSvg.append('g');\n applyDivStylesToSvg(entryDivNode, enter);\n\n var entryDivKeyNode = getEntryDivSubNode('.contour-legend-key');\n var swatch = enter.append('rect')\n .attr('x', entryDivKeyNode.offsetLeft)\n .attr('y', entryDivKeyNode.offsetTop)\n .attr('width', entryDivKeyNode.offsetWidth - 2)\n .attr('height', entryDivKeyNode.offsetHeight - 2);\n applyDivStylesToSvg(entryDivKeyNode, swatch);\n\n var entryDivSeriesNode = getEntryDivSubNode('.series-name');\n var text = enter.append('text')\n .attr('x', entryDivSeriesNode.offsetLeft + 1)\n .attr('y', entryDivSeriesNode.offsetTop + entryDivSeriesNode.offsetHeight - entryDivSeriesNode.offsetParent.clientTop - 2)\n .text(entryDivSeriesNode.textContent);\n applyDivStylesToSvg(entryDivSeriesNode, text);\n\n function getEntryDivSubNode(selector) {\n return entryDiv.select(selector).node();\n }\n });\n }\n }\n\n\n function getProportionedBounds(original, specified) {\n if (specified.width && specified.height) {\n return specified;\n } else if (specified.width) {\n return {\n width: specified.width,\n height: specified.width * original.height / original.width\n };\n } else if (specified.height) {\n return {\n width: specified.height * original.width / original.height,\n height: specified.height\n };\n } else {\n return original;\n }\n }\n\n\n function exportImage(container, options, exporter) {\n startWork();\n\n // merge configuration options with defaults\n options = options || {};\n _.defaults(options, defaultParams);\n\n var svgNode = container.select('svg').node();\n // get bounds from original SVG, and proportion them based on specified options\n var bounds = svgNode.getBoundingClientRect();\n var boundsClone = getProportionedBounds(bounds, options);\n\n // clone SVG in isolation with styles directly applied\n createSvgClone(svgNode, performExport);\n\n function performExport(svgNodeClone, destroySvgClone) {\n svgNodeClone.setAttribute('width', boundsClone.width);\n svgNodeClone.setAttribute('height', boundsClone.height);\n\n // Safari can only open a new tab with the image\n // the tab must be opened before `getSvgDataUrl()` to avoid getting blocked due to asynchronous callbacks\n var win;\n if (exporter === 'download' && !(browser.aDownloads || browser.savesMsBlobs)) {\n win = root.open();\n }\n\n getSvgDataUrl(svgNodeClone, options, function (url, blob, revokeUrl) {\n destroySvgClone();\n\n // exporter functions\n var exporters = {\n 'download': function () {\n if (browser.aDownloads) {\n // make a link to download and click it\n var a = document.createElement('a');\n a.download = options.fileName;\n a.href = url;\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n } else if (browser.savesMsBlobs && blob) {\n // IE10-11 support a method to save/open a blob\n navigator.msSaveOrOpenBlob(blob, options.fileName);\n } else {\n // Safari and IE9 can only open a new tab with the image\n if (!win) {\n // in case `blob` was falsy or the `open()` above returned undefined, `win` will be undefined, so attempt here (and this might return undefined as well)\n win = root.open();\n }\n if (win) {\n if (browser.createsObjectUrls) {\n // Safari can set the url of the newly-opened tab to the object URL of the blob\n win.location = url;\n } else {\n // for IE9, create a document with the image\n var doc = win.document;\n doc.write('');\n doc.write('');\n doc.write('');\n doc.write('');\n }\n }\n }\n // wait for download to start\n setTimeout(function () {\n revokeUrl();\n finishWork();\n }, 1);\n },\n 'place': function () {\n var img = document.createElement('img');\n img.onload = function () {\n revokeUrl();\n finishWork();\n };\n img.src = url;\n d3.select(options.target).node().appendChild(img);\n }\n };\n // call exporter function\n exporters[exporter]();\n });\n }\n }\n };\n\n\n // queue functions\n\n // queue will wait until any asynchronous tasks are complete prior to calling the next fn()\n function addToQueue(fn) {\n if (working) {\n queue.push(fn);\n } else {\n fn();\n }\n }\n\n // call before starting an asynchronous task\n function startWork() {\n working = true;\n }\n\n // call after finishing an asynchronous task\n function finishWork() {\n working = false;\n\n var fn = queue.shift();\n if (fn) {\n fn();\n }\n }\n\n\n // check browser capabilities and set up necessary shims\n function checkBrowser() {\n startWork();\n browser.checked = true;\n\n checkEncodesBase64();\n checkADownloads();\n checkSavesMsBlobs();\n checkCreatesObjectUrls();\n checkExportsSvg(finishWork);\n\n\n function checkEncodesBase64() {\n browser.encodesBase64 = !!root.btoa;\n\n // setup shim for IE9\n if (!browser.encodesBase64) {\n setupBase64Shim();\n }\n }\n\n function checkADownloads() {\n browser.aDownloads = document.createElement('a').download !== undefined;\n }\n\n function checkSavesMsBlobs() {\n browser.savesMsBlobs = !!navigator.msSaveOrOpenBlob;\n }\n\n function checkCreatesObjectUrls() {\n var domUrl = root.URL || root.webkitURL;\n browser.createsObjectUrls = domUrl && domUrl.createObjectURL;\n }\n\n function checkExportsSvg() {\n startWork();\n\n browser.exportsSvg = false;\n\n var iframe = document.body.appendChild(document.createElement('iframe'));\n iframe.style.visibility = 'hidden';\n var doc = iframe.contentWindow.document;\n\n iframe.onload = function () {\n try {\n var svg = doc.querySelector('svg');\n var img = doc.querySelector('img');\n var canvas = doc.querySelector('canvas');\n var context = canvas.getContext('2d');\n canvas.width = img.getAttribute('width') * 1;\n canvas.height = img.getAttribute('height') * 1;\n var sourceImg = new Image();\n sourceImg.width = canvas.width;\n sourceImg.height = canvas.height;\n sourceImg.onload = function () {\n try {\n context.drawImage(sourceImg, 0, 0, img.width, img.height);\n img.src = canvas.toDataURL();\n\n browser.exportsSvg = true; // yay\n } catch (e) {}\n\n svgExportChecked();\n };\n var xml = (new XMLSerializer()).serializeToString(svg);\n sourceImg.src = 'data:image/svg+xml,' + encodeURIComponent(xml);\n } catch (e) {\n svgExportChecked();\n }\n };\n\n doc.open();\n doc.write('');\n doc.write('');\n doc.write('');\n doc.write('');\n doc.write('');\n doc.write('');\n doc.close();\n\n\n function svgExportChecked() {\n document.body.removeChild(iframe);\n\n // load Canvg SVG renderer for browsers that can't safely export SVG\n if (browser.exportsSvg) {\n finishWork();\n } else {\n setupCanvgShim(finishWork);\n }\n }\n }\n\n // base64 shim, for IE9\n function setupBase64Shim() {\n var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n\n function InvalidCharacterError(message) {\n this.message = message;\n }\n InvalidCharacterError.prototype = new Error();\n InvalidCharacterError.prototype.name = 'InvalidCharacterError';\n\n // base64 encoder\n // from https://gist.github.com/999166\n root.btoa = function (input) {\n var str = String(input);\n for (\n // initialize result and counter\n var block, charCode, idx = 0, map = chars, output = '';\n // if the next str index does not exist:\n // change the mapping table to \"=\"\n // check if d has no fractional digits\n str.charAt(idx | 0) || (map = '=', idx % 1);\n // \"8 - idx % 1 * 8\" generates the sequence 2, 4, 6, 8\n output += map.charAt(63 & block >> 8 - idx % 1 * 8)\n ) {\n charCode = str.charCodeAt(idx += 3 / 4);\n if (charCode > 0xFF) {\n throw new InvalidCharacterError('\"btoa\" failed: The string to be encoded contains characters outside of the Latin1 range.');\n }\n block = block << 8 | charCode;\n }\n return output;\n };\n }\n\n // Canvg shim, for IE9-11 and Safari\n function setupCanvgShim(done) {\n var scripts = [\n 'rgbcolor.js',\n 'StackBlur.js',\n 'canvg.js'\n ];\n var remaining = scripts.length;\n _.each(scripts, function (src) {\n var script = document.createElement('script');\n script.type = 'text/javascript';\n script.onload = function () {\n remaining--;\n if (remaining === 0) done();\n };\n script.src = '//canvg.googlecode.com/svn/trunk/' + src;\n document.head.appendChild(script);\n });\n }\n }\n\n\n Contour.expose('exportable', exportable);\n\n})();\n","Contour.version = '1.0.1';","(function () {\n\n var helpers = {\n xScaleFactory: function (data, options) {\n // if we have dates in the x field of the data points\n // we need a time scale, otherwise is an oridinal\n // two ways to shape the data for time scale:\n // [{ x: date, y: 1}, {x: date, y: 2}]\n // [{ data: [ x: date, y: 1]}, {data: [x: date, y: 100]}]\n // if we get no data, we return an ordinal scale\n var isTimeData = options.xAxis.type === 'time' || (_.isArray(data) && data.length > 0 && data[0].data ?\n data[0].data[0].x && _.isDate(data[0].data[0].x) :\n _.isArray(data) && data.length > 0 && data[0].x && _.isDate(data[0].x));\n\n\n if (isTimeData && options.xAxis.type !== 'ordinal') {\n return new _.nw.axes.TimeScale(data, options);\n }\n\n if (!options.xAxis.categories && options.xAxis.type === 'linear') {\n return new _.nw.axes.LinearScale(data, options);\n }\n\n return new _.nw.axes.OrdinalScale(data, options);\n },\n\n yScaleFactory: function (data, options, axisType, domain) {\n var map = {\n 'log': _.nw.axes.LogYAxis,\n 'smart': _.nw.axes.SmartYAxis,\n 'linear': _.nw.axes.YAxis\n };\n\n if (!axisType) {\n axisType = 'linear';\n }\n\n if (axisType === 'linear' && options.yAxis.smartAxis) {\n axisType = 'smart';\n }\n\n if (map[axisType]) {\n return new map[axisType](data, options, domain);\n }\n\n // try by namespace\n if (_.nw.axes[axisType]) {\n return new _.nw.axes[axisType](data, options, domain);\n }\n\n throw new Error('Unknown axis type: \"' + axisType + '\"');\n }\n\n };\n\n _.nw = _.extend({}, _.nw, helpers);\n\n})();\n","(function () {\n\n function LinearScale(data, options) {\n this.options = options;\n this.data = data;\n\n this.init();\n }\n\n LinearScale.prototype = {\n init: function () {\n delete this._scale;\n },\n\n /*jshint eqnull:true*/\n scale: function (domain) {\n this._domain = domain ? this._getAxisDomain(domain) : this._getAxisDomain(this.data);\n this._scale = this._scale || d3.scale.linear();\n this._scale.domain(this._domain);\n\n if (this.options.xAxis.min == null && this.options.xAxis.max == null) {\n this._scale.nice();\n }\n\n this._setRange();\n\n return this._scale;\n },\n\n axis: function () {\n var options = this.options.xAxis;\n var formatLabel = options.labels.formatter || d3.format(options.labels.format || 'g');\n var axis = d3.svg.axis()\n .scale(this._scale)\n .tickSize(options.innerTickSize, options.outerTickSize)\n .tickPadding(options.tickPadding)\n .tickFormat(function (d) {\n return _.isDate(d) ? d.getDate() : formatLabel(d);\n });\n\n var ticks = axis.scale().ticks();\n var labelsFit = _.nw.doXLabelsFit(ticks, formatLabel, this.options);\n\n if (options.firstAndLast) {\n // show only first and last tick\n axis.tickValues(_.nw.firstAndLast(this._domain));\n } else if (options.tickValues) {\n axis.tickValues(options.tickValues);\n } else if (options.ticks != null) {\n axis.ticks(options.ticks);\n } else if (!labelsFit) {\n var finalTicks = _.nw.getTicksThatFit(ticks, formatLabel, this.options);\n axis.tickValues(finalTicks);\n axis.ticks(finalTicks.length);\n\n }\n\n return axis;\n },\n\n update: function (domain, dataSrc) {\n this.data = dataSrc;\n this.scale(domain);\n },\n\n rangeBand: function () {\n return 1;\n },\n\n postProcessAxis: function () {\n return this;\n },\n\n _setRange: function () {\n var rangeSize = !!this.options.chart.rotatedFrame ? this.options.chart.plotHeight : this.options.chart.plotWidth;\n var range = !!this.options.chart.rotatedFrame ? [rangeSize, 0] : [0, rangeSize];\n return this._scale.range(range);\n },\n\n _getAxisDomain: function (domain) {\n /*jshint eqnull: true*/\n var optMin = this.options.xAxis.min;\n var optMax = this.options.xAxis.max;\n var extents = d3.extent(domain);\n\n if (optMin == null && optMax == null) {\n return extents;\n }\n\n if (optMin == null) {\n return [Math.min(extents[0], optMax), optMax];\n }\n\n if (optMax == null) {\n return [optMin, Math.max(extents[1], optMin)];\n }\n\n // options are invalid, use the extents\n if (optMin > optMax) {\n return extents;\n }\n\n return [optMin, optMax];\n }\n };\n\n _.nw.addAxis('LinearScale', LinearScale );\n\n})();\n","(function () {\n\n var LogYAxis = function (data, options) {\n this.data = data;\n this.options = options;\n };\n\n function setRange(scale, options) {\n var rangeSize = options.chart.rotatedFrame ? options.chart.plotWidth : options.chart.plotHeight;\n var range = options.chart.rotatedFrame ? [0, rangeSize] : [rangeSize, 0];\n return scale.range(range);\n }\n\n var __super = _.nw.axes.YAxis.prototype;\n LogYAxis.prototype = _.extend({}, __super, {\n axis: function () {\n var options = this.options.yAxis;\n var domain = this._scale.domain();\n var ticksHint = Math.ceil(Math.log(domain[1]) / Math.log(10));\n var format = options.labels.formatter || d3.format(options.labels.format || ',.0f');\n\n var axis = d3.svg.axis()\n .scale(this._scale)\n .tickSize(options.innerTickSize, options.outerTickSize)\n .tickPadding(options.tickPadding);\n if(options.labels.formatter) {\n axis.tickFormat(options.labels.formatter);\n } else {\n axis.ticks(options.ticks || ticksHint, format);\n }\n\n\n return axis;\n },\n\n scale: function (domain) {\n if(!this._scale) {\n if(domain[0] <= 0.1) domain[0] = 0.1; //throw new Error('Log scales don\\'t support 0 or negative values');\n\n this._scale = d3.scale.log();\n this.setDomain(domain).clamp(true);\n\n }\n\n setRange(this._scale, this.options);\n\n return this._scale;\n },\n\n update: function (domain, dataSrc) {\n this.data = dataSrc;\n if(domain[0] <= 0.1) domain[0] = 0.1; //throw new Error('Log scales don\\'t support 0 or negative values');\n this.setDomain(domain).clamp(true);\n this.scale();\n },\n });\n\n _.nw.addAxis('LogYAxis', LogYAxis );\n\n})();\n","(function () {\n\n // implements the following interface\n /*\n {\n scale: returns the d3 scale for the type\n\n axis: returns the d3 axis\n\n range: returns the d3 range for the type\n\n postProcessAxis:\n }\n */\n\n function OrdinalScale(data, options) {\n this.options = options;\n this.data = data;\n\n this.init();\n }\n\n OrdinalScale.prototype = {\n init: function () {\n this.isCategorized = true;\n delete this._scale;\n },\n\n scale: function (domain) {\n if(!this._scale) {\n this._scale = new d3.scale.ordinal();\n }\n\n this.setDomain(domain || this.data);\n\n return this._scale;\n },\n\n /* jshint eqnull:true */\n axis: function () {\n var options = this.options.xAxis;\n var optFormat = (options.labels.format ? d3.format(options.labels.format) : 0);\n var formatLabel = options.labels.formatter || d3.format(options.labels.format || 'g');\n\n var tickFormat = options.labels.formatter || (!this.isCategorized ? optFormat : 0) || function (d) { return _.isDate(d) ? d.getDate() : d; };\n var axis = d3.svg.axis()\n .scale(this._scale)\n .innerTickSize(options.innerTickSize)\n .outerTickSize(options.outerTickSize)\n .tickPadding(options.tickPadding)\n .tickFormat(tickFormat);\n\n var ticks = this.isCategorized && options.categories ? options.categories : _.range(this._domain.length) || [];\n var labelsFit = _.nw.doXLabelsFit(ticks, formatLabel, this.options);\n\n if (options.firstAndLast) {\n // show only first and last tick\n axis.tickValues(_.nw.firstAndLast(this._domain));\n } else if (options.maxTicks) {\n axis.tickValues(_.nw.maxTickValues(options.maxTicks, this._domain));\n } else if (options.tickValues) {\n axis.tickValues(options.tickValues);\n } else if (options.ticks != null) {\n axis.ticks(options.ticks);\n if (options.ticks === 0) {\n axis.tickValues([]);\n }\n } else if (!labelsFit) {\n var finalTicks = _.nw.getTicksThatFit(ticks, formatLabel, this.options);\n axis.tickValues(finalTicks);\n axis.ticks(finalTicks.length);\n } else {\n axis.tickValues(options.categories);\n }\n\n return axis;\n },\n\n /* jshint eqnull:true */\n postProcessAxis: function (axisGroup) {\n var options = this.options.xAxis;\n if (!options.labels || options.labels.rotation == null) return;\n\n var deg = options.labels.rotation;\n var rad = _.nw.degToRad(deg);\n var sign = deg > 0 ? 1 : deg < 0 ? -1 : 0;\n var pos = deg < 0 ? -1 : 1;\n var lineHeight = 0.71;\n var lineCenter = lineHeight / 2; // center of text line is at .31em\n var cos = Math.cos(rad);\n var sin = Math.sin(rad);\n var anchor = options.labels.rotation < 0 ? 'end' : options.labels.rotation > 0 ? 'start' : 'middle';\n\n axisGroup.selectAll('.tick text')\n .style({'text-anchor': anchor})\n .attr('transform', function (d, i, j) {\n var x = d3.select(this).attr('x') || 0;\n var y = d3.select(this).attr('y') || 0;\n return 'rotate(' + options.labels.rotation + ' ' + x + ',' + y + ')';\n })\n .attr('dy', function (d, i, j) {\n var ref = deg === 0 ? lineHeight : lineCenter;\n var num = ((cos * ref) + (sin * ref * pos));\n return (num).toFixed(4) + 'em';\n // return (sign * ((cos * lineCenter) + (sin * lineCenter))).toFixed(4) + 'em';\n })\n .attr('dx', function (d, i, j) {\n // var num = ((sin * lineCenter * pos));\n // return -num.toFixed(4) + 'em';\n return -(sin * lineCenter - 0.31 * sign).toFixed(4) + 'em';\n\n });\n },\n\n update: function (domain, data) {\n this.data = data;\n this.scale(domain);\n },\n\n setDomain: function (domain) {\n this._domain = domain;\n this._scale.domain(domain);\n this._range();\n },\n\n rangeBand: function () {\n var band = this._scale.rangeBand();\n if (!band) _.nw.warn('rangeBand is 0, you may have too many points in in the domain for the size of the chart (ie. chartWidth = ' + this.options.chart.plotWidth + 'px and ' + (this._domain.length) + ' X-axis points (plus paddings) means less than 1 pixel per band and there\\'re no half pixels');\n\n return this._scale.rangeBand();\n },\n\n _range: function () {\n var range = this.options.chart.rotatedFrame ? [this.options.chart.plotHeight, 0] : [0, this.options.chart.plotWidth];\n var numCats = (this._domain || []).length;\n var threshold = 30;\n var rangeType = numCats <= threshold ? 'rangeRoundBands' : 'rangeBands';\n\n return this.isCategorized ?\n // this._scale.rangeBands(range, this.options.xAxis.innerRangePadding, this.options.xAxis.outerRangePadding) :\n this._scale[rangeType](range, this.options.xAxis.innerRangePadding, this.options.xAxis.outerRangePadding) :\n this._scale.rangePoints(range);\n }\n };\n\n _.nw.addAxis('OrdinalScale', OrdinalScale );\n\n})();\n","(function () {\n\n var SmartYAxis = function (data, options, domain) {\n this.data = data;\n this.options = options;\n this.yMax = domain[0];\n this.yMin = domain[1];\n this.dataMax = d3.max(_.map(data, 'y'));\n };\n\n /* jshint eqnull: true */\n function _extractYTickValues(domain, min, max, yMin, yMax, dataMax) {\n var adjustedDomain = _.uniq(_.nw.merge(_.nw.merge(domain, yMax), dataMax));\n // we want to be able to remove parameters with default values\n // so to remove the default yAxis.min: 0, you pass yAxis.min: null\n // and for that we need to to a truly comparison here (to get null or undefined)\n if (min == null && max == null)\n return adjustedDomain;\n\n if (min == null) {\n return max > yMin ? _.nw.merge([max], adjustedDomain) : [max];\n }\n\n if (max == null) {\n if (min >= yMax) return [min];\n adjustedDomain[0] = min;\n\n return adjustedDomain;\n }\n\n return _.nw.merge([min, max], yMax);\n }\n\n var __super = _.nw.axes.YAxis.prototype;\n SmartYAxis.prototype = _.extend({}, __super, {\n axis: function () {\n var options = this.options.yAxis;\n this.domain = this._scale.domain();\n var tickValues = _extractYTickValues(this.domain, options.min, options.max, this.yMin, this.yMax, this.dataMax);\n var numTicks = this.numTicks();\n var axis = __super.axis.call(this);\n return axis.ticks(numTicks)\n .tickValues(tickValues);\n },\n\n numTicks: function () {\n return 3;\n },\n\n setDomain: function (domain) {\n var extent = d3.extent(domain);\n this.yMin = extent[0];\n this.yMax = extent[1];\n this._scale.domain(domain);\n\n this._niceTheScale();\n },\n\n _niceTheScale: function () {\n var perTreshold = 0.05;\n var domain = this._scale.domain();\n var min = this.options.yAxis.min || domain[0];\n var rawMax = this.options.yAxis.max || this.dataMax;\n var nextTick = _.nw.roundToNextTick(rawMax);\n\n var max = Math.abs(nextTick - rawMax) < rawMax * perTreshold ? _.nw.roundToNextTick(rawMax + rawMax * perTreshold) : nextTick;\n // var max = nextTick === rawMax ? _.nw.roundToNextTick(rawMax + Math.pow(10, -_.nw.decDigits(rawMax) - 1)) : nextTick;\n var nice = [min, max];\n this._scale.domain(nice);\n }\n });\n\n _.nw.addAxis('SmartYAxis', SmartYAxis );\n})();\n","(function () {\n\n // implements the following interface\n /*\n {\n scale: returns the d3 scale for the type\n\n range: returns the d3 range for the type\n }\n */\n\n function dateDiff(d1, d2) {\n if (!d1 || !d2) return 0;\n var diff = d1.getTime() - d2.getTime();\n return diff / (24*60*60*1000);\n }\n\n\n function TimeScale(data, options) {\n this.options = options;\n this.data = data;\n\n this.init();\n }\n\n TimeScale.prototype = {\n init: function () {\n delete this._scale;\n },\n\n scale: function (domain) {\n\n if(!this._scale) {\n this._scale = new d3.time.scale();\n this.setDomain(domain);\n }\n\n this.range();\n\n return this._scale;\n },\n\n\n /* jshint eqnull:true */\n axis: function () {\n var options = this.options.xAxis;\n var tickFormat = this.getOptimalTickFormat();\n\n var axis = d3.svg.axis()\n .scale(this._scale)\n .tickFormat(tickFormat)\n .tickSize(options.innerTickSize, options.outerTickSize)\n .tickPadding(options.tickPadding)\n .tickValues(this._domain);\n\n if (this.options.xAxis.tickValues != null) {\n axis.tickValues(this.options.xAxis.tickValues);\n } else if (this.options.xAxis.maxTicks != null && this.options.xAxis.maxTicks < this._domain.length) {\n // override the tickValues with custom array based on number of ticks\n // we don't use D3 ticks() because you cannot force it to show a specific number of ticks\n axis.tickValues(_.nw.maxTickValues(options.maxTicks, this._domain));\n\n } else if (this.options.xAxis.firstAndLast) {\n // show only first and last tick\n axis.tickValues(_.nw.firstAndLast(this._domain));\n }\n\n return axis;\n },\n\n update: function (domain, data) {\n this.data = data;\n this.setDomain(domain);\n this.scale();\n },\n\n setDomain: function (domain) {\n this._domain = domain;\n var axisDomain = this._getAxisDomain(this._domain);\n this._scale.domain(axisDomain);\n },\n\n postProcessAxis: function (axisGroup) {\n if (!this.options.xAxis.firstAndLast) return;\n var labels = axisGroup.selectAll('.tick text')[0];\n d3.select(labels[0]).style({'text-anchor': 'start'});\n d3.select(labels[labels.length - 1]).style({'text-anchor': 'end'});\n },\n\n rangeBand: function () {\n return 4;\n },\n\n getOptimalTickFormat: function () {\n if (this.options.xAxis.labels.formatter) return this.options.xAxis.labels.formatter;\n if (this.options.xAxis.labels.format) return d3.time.format(this.options.xAxis.labels.format);\n\n var spanDays = Math.abs(dateDiff(this._domain[this._domain.length-1], this._domain[0]));\n var daysThreshold = this.options.xAxis.maxTicks || 1;\n if (spanDays < daysThreshold) return d3.time.format('%H:%M');\n if (spanDays < 365) return d3.time.format('%d %b');\n\n return d3.time.format('%Y');\n },\n\n range: function () {\n var range = this._getAxisRange(this._domain);\n return this._scale.rangeRound(range, 0.1);\n },\n\n\n _getAxisDomain: function (domain) {\n if(this.options.xAxis.linearDomain) {\n return domain;\n }\n\n return d3.extent(domain);\n },\n\n _getAxisRange: function (domain) {\n var size = this.options.chart.rotatedFrame ? this.options.chart.plotHeight : this.options.chart.plotWidth;\n\n if(this.options.xAxis.linearDomain) {\n return _.range(0, size, size / (domain.length - 1)).concat([size]);\n }\n\n return [0, size];\n }\n };\n\n _.nw.addAxis('TimeScale', TimeScale );\n})();\n","(function () {\n\n var defaults = {\n chart: {\n rotatedFrame: true,\n },\n\n xAxis: {\n orient: 'left'\n },\n\n yAxis: {\n orient: 'bottom'\n }\n };\n\n var frame = {\n\n init: function () {\n _.merge(this.options, defaults);\n },\n\n adjustPadding: function () {\n var categoryLabels = this.options.xAxis.categories || _.map(this.dataSrc, 'x');\n var text = categoryLabels.join('
');\n var xLabel = _.nw.textBounds(text, '.x.axis');\n var yLabel = _.nw.textBounds('ABC', '.y.axis');\n var maxTickSize = function (options) { return Math.max(options.outerTickSize, options.innerTickSize); };\n\n this.options.chart.internalPadding.left = this.options.chart.padding.left || maxTickSize(this.options.xAxis) + this.options.xAxis.tickPadding + xLabel.width;\n this.options.chart.internalPadding.bottom = this.options.chart.padding.bottom || maxTickSize(this.options.yAxis) + this.options.yAxis.tickPadding + yLabel.height;\n },\n\n adjustTitlePadding: function () {\n var titleBounds;\n if (this.options.xAxis.title || this.options.yAxis.title) {\n if(this.options.xAxis.title) {\n titleBounds = _.nw.textBounds(this.options.xAxis.title, '.x.axis-title');\n this.options.chart.internalPadding.left += titleBounds.height + this.options.xAxis.titlePadding;\n }\n\n if(this.options.yAxis.title) {\n titleBounds = _.nw.textBounds(this.options.yAxis.title, '.y.axis-title');\n this.options.chart.internalPadding.bottom += titleBounds.height + this.options.yAxis.titlePadding;\n }\n }\n },\n\n renderYAxis: function () {\n var yAxis = this.yAxis();\n var x = this.options.chart.internalPadding.left;\n var y = this.options.chart.padding.top + this.options.chart.plotHeight;\n\n this._yAxisGroup = this.svg.selectAll('.y.axis')\n .data([1]);\n\n this._yAxisGroup.enter().append('g')\n .attr('class', 'y axis')\n .attr('transform', 'translate(' + x+ ',' + y + ')');\n\n this._yAxisGroup.exit().remove();\n\n this._yAxisGroup\n .transition().duration(this._animationDuration())\n .attr('transform', 'translate(' + x+ ',' + y + ')')\n .call(yAxis);\n\n return this;\n },\n\n renderXAxis: function () {\n var x = this.options.chart.internalPadding.left;\n var y = this.options.chart.padding.top;\n var xAxis = this.xAxis();\n\n this._xAxisGroup = this.svg.selectAll('.x.axis')\n .data([1]);\n\n this._xAxisGroup.enter().append('g')\n .attr('class', 'x axis')\n .attr('transform', 'translate(' + x + ',' + y + ')');\n\n this._xAxisGroup.exit().remove();\n\n this._xAxisGroup\n .transition().duration(this._animationDuration())\n .attr('transform', 'translate(' + x + ',' + y + ')')\n .call(xAxis);\n\n this.xScaleGenerator.postProcessAxis(this._xAxisGroup);\n\n return this;\n },\n\n renderAxisLabels: function () {\n var lineHeightAdjustment = this.titleOneEm * 0.25; // add 25% of font-size for a complete line-height\n var adjustFactor = 40/46.609;\n var el;\n var bounds, anchor, rotation, tickSize, x, y;\n\n if (this.options.xAxis.title) {\n bounds = _.nw.textBounds(this.options.xAxis.title, '.x.axis-title');\n x = this.options.chart.rotatedFrame ? -bounds.height : this.options.chart.plotWidth;\n y = this.options.chart.rotatedFrame ? -this.options.chart.internalPadding.left : this.options.chart.internalPadding.bottom - lineHeightAdjustment;\n\n rotation = this.options.chart.rotatedFrame ? '-90' : '0';\n el = this._xAxisGroup.selectAll('.x.axis-title').data([null]);\n\n el.enter().append('text')\n .attr('class', 'x axis-title');\n\n el.attr('x', 0)\n .attr('y', y)\n .attr('transform', ['rotate(', rotation, ')'].join(''))\n .attr('dy', bounds.height * adjustFactor)\n .attr('dx', -(this.options.chart.plotHeight + bounds.width) / 2)\n .text(this.options.xAxis.title);\n\n el.exit().remove();\n }\n\n if (this.options.yAxis.title) {\n bounds = _.nw.textBounds(this.options.yAxis.title, '.y.axis-title');\n tickSize = Math.max(this.options.yAxis.innerTickSize, this.options.yAxis.outerTickSize);\n anchor = this.options.chart.rotatedFrame ? 'end' : 'middle';\n x = this.options.chart.rotatedFrame ? this.options.chart.plotWidth : 0;\n y = this.options.chart.rotatedFrame ?\n this.options.chart.internalPadding.bottom:\n -this.options.chart.internalPadding.left + this.titleOneEm - lineHeightAdjustment;\n\n rotation = this.options.chart.rotatedFrame ? '0' : '-90';\n\n el = this._yAxisGroup.selectAll('.y.axis-title').data([null]);\n\n el.enter().append('text')\n .attr('class', 'y axis-title');\n\n el.attr('y', y)\n .attr('x', x)\n .attr('dx', -(this.options.chart.plotWidth + bounds.width) / 2)\n .attr('dy', -4) // just because\n .attr('transform', ['rotate(', rotation, ')'].join(''))\n .text(this.options.yAxis.title);\n\n el.exit().remove();\n }\n\n return this;\n }\n };\n\n /**\n * Sets the visualization frame so that the xAxis is vertical and the yAxis is horizontal.\n *\n * This visualization requires `.cartesian()`.\n *\n * This visualization is a prerequiste for rendering bar charts (`.bar()`).\n *\n * ###Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .horizontal()\n * .bar([1, 2, 3, 4, 5, 4, 3, 2, 1])\n * .render()\n *\n * @function horiztonal\n */\n\n Contour.expose('horizontal', frame);\n\n})();\n","(function () {\n\n var _extent = function (series, field) {\n var maxs = [], mins = [];\n _.each(series, function (d) {\n if(!d.data.length) return;\n var values = _.map(d.data, field);\n maxs.push(d3.max(values));\n mins.push(d3.min(values));\n });\n\n //\n if(!mins.length || !maxs.length) return [];\n\n return [_.min(mins), _.max(maxs)];\n };\n\n\n /*jshint eqnull:true */\n var _stackedExtent = function (data) {\n var stack = _.nw.stackLayout();\n var dataSets = stack(data);\n var ext = [];\n _.each(dataSets, function (set) {\n _.each(set.data, function (d, i) {\n var cur = ext[i] || 0;\n ext[i] = cur + d.y;\n });\n });\n\n return [_.min(ext), _.max(ext)];\n };\n\n var _xExtent = _.partialRight(_extent, 'x');\n var _yExtent = _.partialRight(_extent, 'y');\n\n function VisInstanceContainer(data, categories, options, type, renderer, context) {\n this.type = type;\n this.renderer = renderer;\n this.ctx = context;\n this.categories = categories;\n\n this.init(data, options);\n }\n\n VisInstanceContainer.prototype = {\n\n init: function (data, options) {\n // set the options first and then the data\n this.setOptions(options);\n this.setData(data);\n },\n\n render: function (layer, options) {\n this.renderer.call(this.ctx, this.data, layer, options);\n\n return this.ctx;\n },\n\n setData: function (data) {\n var normalizeData = (this.ctx || {}).dataNormalizer || _.nw.normalizeSeries;\n this.data = normalizeData(data, this.categories);\n this._updateDomain();\n\n return this.ctx;\n },\n\n setOptions: function (options) {\n var opt = {};\n opt[this.type] = options || {};\n this.options = {};\n this.options = _.merge({}, (this.renderer || {}).defaults || {}, opt);\n\n return this.ctx;\n },\n\n setVisibility: function (visible) {\n var node = this.layer.node();\n\n visible ? $(node).show() : $(node).hide();\n },\n\n _updateDomain: function () {\n if(!this.options[this.type]) throw new Error('Set the options before calling setData or _updateDomain');\n\n var isSupportedFormat = (this.ctx || {}).isSupportedDataFormat || _.nw.isSupportedDataFormat;\n\n if (isSupportedFormat(this.data)) {\n this.xDomain = _.flatten(_.map(this.data, function (set) { return _.map(set.data, 'x'); }));\n this.xExtent = _xExtent(this.data, 'x');\n this.yExtent = this.options[this.type].stacked ? _stackedExtent(this.data) : _yExtent(this.data);\n }\n }\n\n };\n\n Contour.VisualizationContainer = VisInstanceContainer;\n\n})();\n","(function () {\n\n var defaults = {\n xAxis: {\n type: 'linear'\n },\n area: {\n stacked: true,\n areaBase: undefined,\n preprocess: _.nw.minMaxFilter(1000)\n }\n };\n\n /* jshint eqnull:true */\n function renderer(data, layer, options) {\n this.checkDependencies('cartesian');\n var duration = options.chart.animations.duration != null ? options.chart.animations.duration : 400;\n var x = _.bind(function (val) { return this.xScale(val) + this.rangeBand / 2 + 0.5; }, this);\n var y = _.bind(function (val) { return this.yScale(val) + 0.5; }, this);\n var h = options.chart.plotHeight;\n var classFn = function (d, i) { return 'series s-' + (i+1) + ' ' + d.name; };\n var stack = d3.layout.stack().values(function (d) { return d.data; });\n\n var startArea = d3.svg.area()\n .x(function(d) { return x(d.x); })\n .y0(function (d) { return h; })\n .y1(function(d) { return h; });\n\n var areaBase = options.area.areaBase != null ? options.area.areaBase : options.yAxis.min;\n var area = d3.svg.area()\n .x(function(d) { return x(d.x); })\n .y0(function (d) { return options.area.stacked ? y(d.y0 || areaBase || 0) : y(0); })\n .y1(function(d) { return y((options.area.stacked ? d.y0 : 0) + d.y); });\n\n if(options.area.smooth) {\n area.interpolate('cardinal');\n startArea.interpolate('cardinal');\n }\n\n renderSeries();\n\n if (options.tooltip && options.tooltip.enable)\n renderTooltipTrackers();\n\n function renderSeries() {\n data = options.area.preprocess(data);\n\n var series = layer.selectAll('g.series')\n .data(stack(data));\n\n series.enter()\n .append('svg:g')\n .attr('class', classFn)\n .append('path').datum(function (d) { return d.data; })\n .attr('class', 'area')\n .attr('d', startArea);\n\n series.exit().remove();\n\n if (options.chart.animations && options.chart.animations.enable) {\n series.select('.area')\n .datum(function (d) { return d.data; })\n .transition().duration(options.chart.animations.duration || duration)\n .attr('d', area);\n } else {\n series.select('.area')\n .datum(function (d) { return d.data; })\n .attr('d', area);\n }\n }\n\n function renderTooltipTrackers() {\n var trackerSize = 10;\n // add the tooltip trackers regardless\n var markers = layer.selectAll('.tooltip-trackers')\n .data(data, function (d) { return d.name; });\n\n markers.enter().append('g')\n .attr('class', 'tooltip-trackers');\n\n markers.exit().remove();\n\n var blocks = markers.selectAll('.tooltip-tracker')\n .data(function (d) {\n return d.data;\n }, function (d, i) {\n return [d.x,d.y,d.y0].join('&');\n });\n\n blocks.enter().append('rect')\n .attr('class', 'tooltip-tracker')\n .attr('opacity', 0)\n .attr('width', trackerSize * 2);\n\n blocks.attr('x', function(d) { return x(d.x) - trackerSize; })\n .attr('y', function(d) { return y((options.area.stacked ? d.y0 : 0) + d.y); })\n .attr('height', function(d) { return y(0) - y(d.y); });\n\n blocks.exit().remove();\n\n }\n }\n\n renderer.defaults = defaults;\n\n /**\n * Adds an area chart to the Contour instance.\n *\n * Area charts are stacked by default when the _data_ includes multiple series.\n *\n * This visualization requires `.cartesian()`.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .area([1,2,3,4])\n * .render();\n *\n * @name area(data, options)\n * @param {object|array} data The _data series_ to be rendered with this visualization. This can be in any of the supported formats.\n * @param {object} [options] Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n */\n Contour.export('area', renderer);\n\n})();\n","(function () {\n /*jshint eqnull:true*/\n var defaults = {\n bar: {\n barClass: null,\n style: null,\n stacked: false,\n groupPadding: 2, // two px between same group bars\n barWidth: function() { return this.rangeBand; },\n offset: function() { return 0; },\n preprocess: function(data) {\n return data;\n }\n }\n };\n\n function barRender(data, layer, options) {\n this.checkDependencies(['cartesian', 'horizontal']);\n var duration = options.chart.animations.duration != null ? options.chart.animations.duration : 400;\n var _this = this;\n var opt = options.bar;\n var rectClass = opt.barClass;\n var style = opt.style;\n var x = function (d) { return _this.xScale(d) - 0.5; };\n var y = function (d) { return _this.yScale(d) + 0.5; };\n var chartOffset = _.nw.getValue(opt.offset, 0, this);\n var rangeBand = _.nw.getValue(opt.barWidth, this.rangeBand, this);\n var stack = _.nw.stackLayout();\n var update = options.bar.stacked ? stacked : grouped;\n var enter = _.partialRight(update, true);\n var classFn = function (d, i) { return 'series s-' + (i+1) + ' ' + d.name; };\n\n data = options.bar.preprocess(data);\n var series = layer.selectAll('g.series')\n .data(stack(data));\n\n series.enter().append('svg:g')\n .attr('class', classFn);\n\n series.exit().remove();\n\n var bars = series.selectAll('.bar')\n .data(function (d) { return d.data; });\n\n var cssClass = 'bar' + (options.tooltip.enable ? ' tooltip-tracker' : '');\n bars.enter().append('rect')\n .attr('class', function (d, i, j) {\n if (!rectClass) return cssClass;\n\n return cssClass + ' ' + (typeof rectClass === 'function' ? rectClass.call(this, d, i, j) : rectClass);\n })\n .call(enter);\n\n if(options.chart.animations && options.chart.animations.enable) {\n bars\n .attr('style', style)\n .transition().duration(duration).call(update);\n bars.exit()\n .transition().duration(duration)\n .attr('width', y(0))\n .remove();\n } else {\n bars.attr('style', style).call(update);\n bars.exit().remove();\n }\n\n function stacked(bar, enter) {\n bar\n .attr('y', function (d) { return x(d.x) + chartOffset; })\n .attr('height', rangeBand);\n\n if (enter) {\n return bar\n .attr('x', function (d) { return y(0); })\n .attr('width', function (d) { return 0; });\n\n } else {\n return bar\n .attr('x', function (d) { return d.y >= 0 ? y(d.y0 || 0) : y(d.y + d.y0); })\n .attr('width', function (d) { return d.y >=0 ? y(d.y) - y(0) : y(0) - y(d.y); });\n }\n }\n\n function grouped(bar, enter) {\n var numSeries = data.length;\n var height = function () { return rangeBand / numSeries - options.bar.groupPadding + 0.5; };\n var offset = function (d, i) { return rangeBand / numSeries * i + 0.5; };\n\n bar.attr('y', function (d, i, j) { return x(d.x) + offset(d, j) + chartOffset; })\n .attr('x', y(0))\n .attr('height', height);\n\n if (enter) {\n return bar\n .attr('width', function (d) { return 0.5; });\n } else {\n return bar\n .attr('width', function (d) { return d.y >= 0 ? y(d.y) - y(0) : y(0) - y(d.y); })\n .attr('x', function (d) { return d.y < 0 ? y(d.y) : y(0); });\n }\n }\n }\n\n barRender.defaults = defaults;\n /**\n * Adds a bar chart (horizontal columns) to the Contour instance.\n *\n * You can use this visualization to render both stacked and grouped charts (controlled through the _options_).\n *\n * This visualization requires `.cartesian()` and `.horizontal()`.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .horizontal()\n * .bar([1,2,3,4])\n * .render();\n *\n * @name bar(data, options)\n * @param {object|array} data The _data series_ to be rendered with this visualization. This can be in any of the supported formats.\n * @param {object} [options] Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n */\n Contour.export('bar', barRender);\n\n})();\n","(function () {\n\n var defaults = {\n column : {\n // specifies a class string or function that will be added to each column\n columnClass: null,\n style: null,\n stacked: false,\n groupPadding: 1,\n columnWidth: function() { return this.rangeBand; },\n offset: function() { return 0; }\n }\n };\n\n function render(data, layer, options) {\n this.checkDependencies('cartesian');\n var duration = options.chart.animations.duration != null ? options.chart.animations.duration : 400;\n var opt = options.column;\n var h = options.chart.plotHeight;\n var rectClass = options.column.columnClass;\n var rectStyle = options.column.style;\n var _this = this;\n var x = function (v) { return Math.round(_this.xScale(v)) + 0.5; };\n var y = function (v) { return Math.round(_this.yScale(v)) - 0.5; };\n var dataKey = function (d) { return d.data; };\n var chartOffset = _.nw.getValue(opt.offset, 0, this);\n var rangeBand = _.nw.getValue(opt.columnWidth, this.rangeBand, this);\n var enter = _.partialRight((options.column.stacked ? stacked : grouped), true);\n var update = options.column.stacked ? stacked : grouped;\n var filteredData = _.map(data, function (series, j) {\n return {\n name: series.name,\n data: _.filter(series.data, function (d, i) {\n return i === 0 ? true : x(d.x) !== x(series.data[i-1].x);\n })\n };\n });\n\n var stack = _.nw.stackLayout();\n var series = layer.selectAll('g.series')\n .data(stack(filteredData));\n\n series.enter()\n .append('g')\n .attr('class', function (d, i) { return 'series s-' + (i+1) + ' ' + d.name; });\n\n series.exit()\n .remove();\n\n var cols = series.selectAll('.column')\n .data(dataKey, function (d) { return d.x || d; });\n\n var cssClass = 'column' + (options.tooltip.enable ? ' tooltip-tracker' : '');\n\n cols.enter()\n .append('rect')\n .attr('class', function (d, i, j) {\n if (!rectClass) return cssClass;\n\n return cssClass + ' ' + (typeof rectClass === 'function' ? rectClass.call(this, d, i, j) : rectClass);\n })\n .call(enter);\n\n if (options.chart.animations && options.chart.animations.enable) {\n cols.exit()\n .transition().duration(duration)\n .attr('y', h)\n .attr('height', function () { return 0.5; })\n .remove();\n cols.transition().duration(duration)\n .call(update);\n } else {\n cols.exit().remove();\n cols.call(update);\n }\n\n // for every update\n cols.attr('style', rectStyle);\n\n function stacked(col, enter) {\n var base = y(0);\n\n col.attr('x', function (d) { return x(d.x) + chartOffset; })\n .attr('width', function () { return rangeBand; });\n\n if (enter) {\n col.attr('y', function (d) { return d.y >= 0 ? base : base; })\n .attr('height', function (d) { return 0.5; });\n } else {\n col.attr('y', function (d) { return d.y >= 0 ? y(d.y) + y(d.y0) - base : y(d.y0) ; })\n .attr('height', function (d) { return d.y >=0 ? base - y(d.y) : y(d.y) - base; });\n }\n }\n\n function grouped(col, enter) {\n var width = rangeBand / data.length - opt.groupPadding + 0.5;\n var offset = function (d, i) { return rangeBand / data.length * i + 0.5; };\n var base = y(0);\n\n col.attr('x', function (d, i, j) { return x(d.x) + offset(d, j) + chartOffset; })\n .attr('width', width);\n\n if (enter) {\n col.attr('y', base)\n .attr('height', 0);\n } else {\n col.attr('y', function (d) { return d.y >= 0 ? y(d.y) : base; })\n .attr('height', function (d) { return d.y >= 0 ? base - y(d.y) : y(d.y) - base; });\n }\n }\n }\n\n render.defaults = defaults;\n\n /**\n * Adds a column chart (vertical columns) to the Contour instance.\n *\n * This visualization requires `.cartesian()`.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .column([1,2,3,4])\n * .render();\n *\n * @name column(data, options)\n * @param {object|array} data The _data series_ to be rendered with this visualization. This can be in any of the supported formats.\n * @param {object} [options] Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n */\n Contour.export('column', render);\n\n})();\n","(function () {\n\n Contour.export('coolNarwhal', function (data, layer) {\n layer.append('path')\n .attr('class', 'cool')\n .attr('opacity', 0)\n .attr('transform', 'scale(.5) translate(500 150)')\n .attr('d', 'M-220.02,76.509l-0.78,8.927c-0.956,10.949,1.389,20.422,6.188,30.383c10.203,21.173,63.095,84.05,93.72,115.075c20.145,20.406,19.487,23.018,21.549,40.122c2.487,20.621,24.897,66.462,40.838,71.269 c15.086,4.549,12.91-12.398,13.319-37.83c5.746,2.457,10.917,5.638,20.206,12.697c61.697,46.892,139.734,69.97,206.5,71.733c46.209,1.221,81.432-7.081,142.957-33.694c40.484-17.512,54.271-22.098,65.639-21.504c4.432,0.232,22.678,11.204,41.746,21.563c35.398,19.229,69.457,34.595,75.896,34.239c12.609-1.457-0.701-11.783-8.072-24.217c-7.049-11.892-15.414-29.572-18.844-42.134s-4.723-22.272-8.91-27.091c-2.143-2.463-12.812-6.786-21.189-8.146c-18.045-2.933-22.191-2.922-13.531-8.957c13.076-9.115,17.377-11.039,1.826-29.068c-6.383-7.402-11.336-20.003-13.709-39.542c-1.607-13.237,1.057-23.679-3.869-27.451s-17.271,12.341-20.846,19.334c-2.01,3.937-7.102,19.005-11.312,33.485c-13.795,47.427-29.865,65.742-62.693,71.447c-34.361,5.971-71.623-9.506-116.543-48.404c-13.164-11.399-29.533-25.26-39.254-36.913c-13.428-16.101-15.48-18.138-19.785-20.66c-16.166-9.472-54.98-31.694-103.525-63.815c-24.393-16.141-57.72-36.928-71.453-43.693c-27.236-13.417-68.416-28.952-90.731-46.771c-24.665-19.697-38.108-19.793-67.804-5.479c-21.429,10.328-23.941,15.298-26.52,15.726c-8.216-10.129-22.917-11.198-31.647-20.682c-9.529-10.35-28.027-14.098-37.824-24.957c-10.668-11.826-31.25-16.752-40.886-26.94c-11.339-11.989-29.387-16.096-40.838-26.637c-11.617-10.694-27.159-14.843-37.68-24.045c-10.383-9.082-23.187-12.538-31.408-19.163c-8.193-6.601-16.593-9.444-22.026-11.993c-5.433-2.549-7.398-2.522-7.658-1.927c-0.26,0.594,1.355,2.955,6.054,6.447c4.699,3.491,22.193,18.451,31.645,22.77c10.921,5.104,17.502,15.01,29.671,21.375c13.224,6.918,22.212,18.731,36.229,25.924c15.53,7.971,24.754,21.184,39.657,28.253c16.462,7.808,25.503,21.598,39.958,28.36c14.499,6.78,20.647,20.252,34.429,23.428C-238.033,58.207-227.932,70.443-220.02,76.509L-220.02,76.509z')\n .transition()\n .delay(300)\n .duration(2000)\n .attr('opacity', 1);\n });\n\n})();\n","(function () {\n\n var defaults = {\n legend: {\n vAlign: 'middle',\n hAlign: 'right',\n direction: 'vertical',\n enabled: true,\n formatter: function (d) {\n return d.name;\n },\n el: undefined\n }\n };\n\n function validAlignmentClasses(options) {\n var classes = [];\n if (['top', 'middle', 'bottom'].indexOf(options.legend.vAlign) !== -1) {\n classes.push(options.legend.vAlign);\n } else {\n classes.push('top');\n }\n\n if (['left', 'center', 'right'].indexOf(options.legend.hAlign) !== -1) {\n classes.push(options.legend.hAlign);\n } else {\n classes.push('right');\n }\n\n if (options.legend.direction === 'vertical') {\n classes.push('vertical');\n }\n\n return classes;\n }\n\n function Legend(data, layer, options) {\n if (options.legend.enabled === false) {\n return;\n }\n var container;\n if (options.legend.el) {\n container = d3.select(options.legend.el).node();\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n } else {\n this.container.selectAll('.contour-legend').remove();\n }\n var em = _.nw.textBounds('series', '.contour-legend.contour-legend-entry');\n var count = data.length;\n var legendHeight = (em.height + 4) * count + 12; // legend has 1px border and 5px margin (12px) and each entry has ~2px margin\n var mid = (options.chart.plotHeight - legendHeight) / 2;\n var positioner = function (selection) {\n // adjust position of legend only when is horizontally centered\n // since we need to have all elements in the legend to calculate its width\n if (options.legend.hAlign !== 'center' || !selection.length) {\n return ;\n }\n\n // adjust the left\n var legendWidth = selection[0].parentNode.clientWidth;\n var left = (options.chart.plotWidth - legendWidth) / 2 + options.chart.internalPadding.left;\n\n d3.select(selection[0].parentNode)\n .style('left', left + 'px');\n };\n\n if (options.legend.el) {\n container = d3.select(options.legend.el);\n } else {\n var legend = this.container.selectAll('.contour-legend').data([null]);\n container = legend.enter().append('div');\n }\n\n container.attr('class', function () {\n return ['contour-legend'].concat(validAlignmentClasses(options)).join(' ');\n });\n\n container.attr('style', function () {\n var styles = [];\n\n if (options.legend.vAlign === 'top') {\n styles.push('top: 0');\n } else if (options.legend.vAlign === 'middle') {\n styles.push('top: ' + mid + 'px');\n } else {\n styles.push('bottom: ' + (options.chart.internalPadding.bottom + 5) + 'px');\n }\n\n if (options.legend.hAlign === 'left') {\n styles.push('left: ' + options.chart.plotLeft + 'px');\n } else if (options.legend.hAlign === 'center') {\n var bounds = _.nw.textBounds(this, '.contour-legend');\n\n styles.push('left: ' + ((options.chart.plotWidth - bounds.width) / 2 + options.chart.internalPadding.left) + 'px' );\n } else {\n styles.push('right: 10px');\n }\n\n return styles.join(';');\n });\n\n var entries = container.selectAll('.contour-legend-entry')\n .data(data);\n\n entries.enter()\n .append('div')\n .attr('class', function () {\n return 'contour-legend-entry';\n });\n\n entries.append('span')\n .attr('class', function (d, i) { return 'contour-legend-key series s-' + (i+1) + ' ' + _.nw.seriesNameToClass(d.name); });\n\n entries.append('span')\n .attr('class', 'series-name')\n .text(options.legend.formatter)\n .call(positioner);\n\n entries.exit()\n .remove();\n }\n\n Legend.defaults = defaults;\n\n /**\n * Adds a legend to the Contour instance. One entry is added to the legend for each series in the data.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .column(data)\n * .legend(data)\n * .render();\n *\n * @name legend(data, options)\n * @param {object|array} data The _data series_ for which to create a legend. This can be in any of the supported formats.\n * @param {object} [options] Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n */\n\n Contour.export('legend', Legend);\n\n})();\n","(function () {\n\n var defaults = {\n xAxis: {\n type: 'linear'\n },\n line: {\n stacked: false,\n smooth: false,\n animationDirection: 'left-to-right',\n // animationDirection: 'bottom-to-top',\n marker: {\n enable: true,\n size: 3,\n animationDelay: null\n },\n preprocess: _.nw.minMaxFilter(1000)\n }\n };\n\n var duration;\n var animationDirection;\n var animationsMap = {\n 'left-to-right': {\n enter: function (line) {\n var path = this;\n path.each(function () {\n var totalLength = this.getTotalLength();\n d3.select(this)\n .attr('stroke-dasharray', totalLength + ' ' + totalLength)\n .attr('stroke-dashoffset', totalLength)\n .transition().duration(duration).ease('linear')\n .attr('stroke-dashoffset', 0)\n .transition().duration(0)\n .attr('stroke-dasharray', undefined);\n });\n },\n\n update: function (line) {\n this.attr('d', function (d) { return line(d.data); });\n this.each(function () {\n var totalLength = this.getTotalLength();\n d3.select(this)\n .attr('stroke-dasharray', totalLength + ' ' + totalLength)\n .attr('stroke-dashoffset', totalLength)\n .transition().duration(duration).ease('linear')\n .attr('stroke-dashoffset', 0)\n .transition().duration(0)\n .attr('stroke-dasharray', undefined);\n });\n }\n },\n\n 'bottom-to-top': {\n enter: function (line) {\n this.transition().duration(duration)\n .attr('d', function (d) { return line(d.data); });\n },\n\n update: function (line) {\n this.transition().duration(duration)\n .attr('d', function (d) { return line(d.data); });\n }\n }\n };\n\n\n /* jshint eqnull: true */\n function render(rawData, layer, options, id) {\n this.checkDependencies('cartesian');\n\n var x = _.bind(function (d) { return this.xScale(d.x) + this.rangeBand / 2 + 0.5; }, this);\n var y = _.bind(function (d) { return this.yScale(d.y + (d.y0 || 0)) + 0.5; }, this);\n var shouldAnimate = options.chart.animations && options.chart.animations.enable;\n animationDirection = options.line.animationDirection || 'left-to-right';\n duration = options.chart.animations.duration != null ? options.chart.animations.duration : 400;\n // jshint eqnull:true\n var data = options.line.preprocess(_.nw.cleanNullValues()(rawData));\n\n data = options.line.stacked ? d3.layout.stack().values(function (d) { return d.data; })(data) : data;\n\n renderPaths();\n\n if (options.line.marker.enable)\n renderMarkers();\n\n if (options.tooltip && options.tooltip.enable)\n renderTooltipTrackers();\n\n function seriesClassName(extras) { return function (d, i) { return (extras||'') + ' s-' +(i+1) + ' ' + _.nw.seriesNameToClass(d.name); }; }\n\n function renderPaths() {\n var startLine = d3.svg.line()\n .x(function (d) { return x(d); })\n .y(function () { return y({x: 0, y: options.yAxis.min || 0}); });\n\n var line = d3.svg.line()\n .x(function (d) { return x(d); })\n .y(function (d) { return y(d); });\n\n if(options.line.smooth) line.interpolate('cardinal');\n\n var animFn = animationsMap[animationDirection];\n var series = layer.selectAll('g.series')\n .data(data, function (d) { return d.name; });\n\n // enter\n var el = series.enter().append('svg:g')\n .attr('class',seriesClassName('series'))\n .append('path')\n .attr('class', 'line');\n\n if (shouldAnimate) {\n var startLineFn = animationDirection === 'left-to-right' ? line : startLine;\n el.attr('d', function(d) { return startLineFn(d.data); })\n .call(_.partial(animFn.enter, line));\n } else {\n el.attr('d', function (d) { return line(d.data); });\n }\n\n // update\n el = series\n .attr('class', seriesClassName('series'))\n .select('.line');\n\n if (shouldAnimate) {\n el.call(_.partial(animFn.update, line));\n } else {\n el.attr('d', function (d) { return line(d.data); });\n }\n\n // remove\n if (shouldAnimate) {\n series.exit()\n .remove();\n } else {\n series.exit().remove();\n }\n }\n\n function renderMarkers() {\n var animationDelay = (options.line.marker.animationDelay == null) ? duration : options.line.marker.animationDelay;\n var markers = layer.selectAll('.line-chart-markers')\n .data(data, function (d) { return d.name; });\n\n markers.enter().append('g')\n .attr('class', seriesClassName('line-chart-markers markers'));\n\n markers.exit().remove();\n\n var dots = markers.selectAll('.dot')\n .data(function (d) { return d.data; }, function (d) { return d.x; });\n\n if (shouldAnimate) {\n dots.transition().delay(animationDelay).duration(duration)\n .attr('cx', x)\n .attr('cy', y)\n .attr('opacity', 1);\n } else {\n dots.attr('cx', x)\n .attr('cy', y)\n .attr('opacity', 1);\n }\n\n\n dots.enter().append('circle')\n .attr('class', 'dot')\n .attr('r', options.line.marker.size)\n .attr('opacity', 0)\n .attr('cx', x)\n .attr('cy', y)\n .transition().delay(animationDelay)\n .attr('opacity', 1);\n\n dots.exit().remove();\n\n }\n\n function renderTooltipTrackers() {\n var trackerSize = 10;\n var markers = layer.selectAll('.tooltip-trackers')\n .data(data, function (d) { return d.name; });\n\n markers.enter().append('g')\n .attr('class', seriesClassName('tooltip-trackers'));\n\n markers.exit().remove();\n\n var dots = markers.selectAll('.tooltip-tracker')\n .data(function (d) { return d.data; }, function (d) { return d.x; });\n\n dots.enter().append('circle')\n .attr({\n 'class': 'tooltip-tracker',\n 'r': trackerSize,\n 'opacity': 0\n });\n\n dots.attr({\n 'cx': x,\n 'cy': y\n });\n\n dots.exit().remove();\n }\n\n return this;\n }\n\n render.defaults = defaults;\n\n\n /**\n * Adds a line chart to the Contour instance.\n *\n * This visualization requires `.cartesian()`.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .line([1,2,3,4])\n * .render();\n *\n * @name line(data, options)\n * @param {object|array} data The _data series_ to be rendered with this visualization. This can be in any of the supported formats.\n * @param {object} [options] Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n */\n Contour.export('line', render);\n\n})();\n","Contour.export('nullVis', _.noop);\n","(function () {\n\n var defaults = {\n pie: {\n sliceClass: null,\n\n style: null,\n\n piePadding: {\n left: null,\n top: null,\n right: null,\n bottom: null\n },\n\n // inner and outer radius can be numbers of pixels if >= 1, percentage if > 0 && < 1 or functions\n\n // inner radius as function will recive the outerRadius as parameter\n // passing a value between 0 and 1 (non-inclusing), this value is interpreted as % of radius\n // ie. outerRadius: 100, innerRadius: .8 would give a inner radius or 80 pixles\n innerRadius: null,\n\n // outer radius as function will recieve the proposed maximum radius for a pie\n // passing a value between 0 and 1 (non-inclusing), this value is interpreted as % of width\n // the default behavior is 50% of the mininum between with and height of the container (adjusted for padding)\n outerRadius: null\n }\n };\n\n function normalizePadding(options) {\n if (_.isNumber(options.pie.piePadding)) {\n return {\n top: options.pie.piePadding,\n left: options.pie.piePadding,\n right: options.pie.piePadding,\n bottom: options.pie.piePadding\n };\n }\n\n return options.pie.piePadding;\n }\n\n function clampBounds(bounds, maxWidth, maxHeight) {\n return {\n top: _.nw.clamp(bounds.top, 0, maxHeight),\n bottom: _.nw.clamp(bounds.bottom, 0, maxHeight),\n left: _.nw.clamp(bounds.left, 0, maxWidth),\n right: _.nw.clamp(bounds.right, 0, maxWidth)\n };\n }\n\n function calcPadding(options) {\n var padding = normalizePadding(options);\n var w = options.chart.plotWidth;\n var h = options.chart.plotHeight;\n\n return clampBounds(padding, w, h);\n }\n\n function resolveValueUnits(value, ref) {\n // resolve (0,1) interval to a percentage of the reference value\n // otherwise as a pixel valie\n return value > 0 && value < 1 ? ref * value : value;\n }\n\n function resolvePaddingUnits(padding, w, h) {\n // if the value of padding is betweem 0 and 1 (non inclusing),\n // interpret it as a percentage, otherwise as a pixel value\n return {\n top: resolveValueUnits(padding.top, h) || 5,\n bottom: resolveValueUnits(padding.bottom, h) || 5,\n left: resolveValueUnits(padding.left, w) || 5,\n right: resolveValueUnits(padding.right, w) || 5\n };\n }\n\n function renderer(data, layer, options) {\n /*jshint eqnull:true */\n var duration = options.chart.animations.duration != null ? options.chart.animations.duration : 400;\n var shouldAnimate = options.chart.animations && options.chart.animations.enable;\n var w = options.chart.plotWidth, h = options.chart.plotHeight;\n var padding = calcPadding.call(this, options);\n var numSeries = data.length;\n var style = options.pie.style;\n var _this = this;\n var shouldCenterX = _.every([options.pie.piePadding.left, options.pie.piePadding.right], function (d) { return d == null; });\n var shouldCenterY = _.every([options.pie.piePadding.top, options.pie.piePadding.bottom], function (d) { return d == null; });\n var pixelPadding = resolvePaddingUnits(padding, w, h);\n // the reference size is the min between with and height of the container\n var referenceSize = Math.min(w, h);\n\n // for auto radius we need to take the min between the available with or height adjusted by padding and num series\n var totalPadding = pixelPadding.left + (pixelPadding.right + pixelPadding.left) * (numSeries - 1) + pixelPadding.right;\n var proposedRadius = Math.min(((w - totalPadding) / numSeries) / 2, (h - pixelPadding.top - pixelPadding.bottom) / 2);\n var radius = resolveValueUnits(_.nw.getValue(options.pie.outerRadius, proposedRadius, this, proposedRadius, referenceSize), referenceSize);\n // inner radius is a pixel value or % of the radius\n var innerRadius = resolveValueUnits(_.nw.getValue(options.pie.innerRadius, 0, this, radius), radius);\n var pieData = d3.layout.pie().value(function (d) { return d.y; }).sort(null);\n var totalWidth = totalPadding + radius * numSeries * 2;\n var outerPaddingLeft = shouldCenterX ? (w - totalWidth) / 2 : pixelPadding.left;\n var centerY = h / 2;\n\n var classFn = function (d, i, j) {\n var baseClass = 'series arc' + (options.tooltip.enable ? ' tooltip-tracker' : '') + ' s-' + (i+1) + ' ' + d.data.x;\n\n if (!options.pie.sliceClass) {\n return baseClass;\n }\n\n return baseClass + ' ' + (typeof options.pie.sliceClass === 'function' ? options.pie.sliceClass.call(_this, d, i, j) : options.pie.sliceClass);\n };\n\n var translatePie = function (d,i) {\n // calc the left side coord of the pie, including padding for the prevousous pies\n var offsetX = outerPaddingLeft + (radius * 2 * i + (pixelPadding.right + pixelPadding.left) * i);\n // calc the center of the pie starting from offsetX\n var posY = shouldCenterY ? centerY : radius + pixelPadding.top;\n\n return 'translate(' + (radius + offsetX) + ',' + (posY) + ')';\n };\n\n var pieGroup = layer.selectAll('g.pie-group')\n .data(data);\n\n pieGroup.enter().append('svg:g')\n .attr('class', 'pie-group')\n .attr('transform', translatePie)\n .call(renderSeries);\n\n pieGroup.exit().remove();\n\n if (shouldAnimate) {\n pieGroup\n .call(renderSeries)\n .transition().duration(duration/2)\n .attr('transform', translatePie);\n } else {\n pieGroup.call(renderSeries)\n .attr('transform', translatePie);\n }\n\n function renderSeries(group) {\n var arc = d3.svg.arc()\n .outerRadius(radius).innerRadius(innerRadius);\n\n var startArc = d3.svg.arc()\n .outerRadius(radius).innerRadius(innerRadius)\n .startAngle(0).endAngle(0);\n\n var pie = group.selectAll('path')\n .data(function (d) { return pieData(d.data); }, function (d) { return d.data.x; });\n\n pie.enter()\n .append('path')\n .attr('class', classFn)\n .attr('d', function (d) { return startArc(d); })\n .attr('style', style)\n .each(function (d) { this._current = { startAngle: d.startAngle, endAngle: d.startAngle }; });\n\n\n if (shouldAnimate) {\n pie.exit()\n .remove();\n\n pie.transition().duration(duration)\n .ease('cubic-in')\n .attrTween('d', arcTween);\n } else {\n pie.exit().remove();\n pie.attr('d', arc);\n }\n\n // Store the displayed angles in _current.\n // Then, interpolate from _current to the new angles.\n // During the transition, _current is updated in-place by d3.interpolate.\n // from http://bl.ocks.org/mbostock/1346410\n function arcTween(a) {\n var i = d3.interpolate(this._current, a);\n this._current = i(0);\n return function(t) {\n return arc(i(t));\n };\n }\n }\n }\n\n renderer.defaults = defaults;\n\n\n /**\n * Adds a pie chart to the Contour instance.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .pie([1,2,3,4])\n * .render();\n *\n * @name pie(data, options)\n * @param {object|array} data The _data series_ to be rendered with this visualization. This can be in any of the supported formats. The data elements are summed and then divided. In the example, `.pie([1,2,3,4])` makes four pie slices: 1/10, 2/10, 3/10, and 4/10.\n * @param {object} [options] Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n */\n Contour.export('pie', renderer);\n\n})();\n","(function () {\n\n var defaults = {\n xAxis: {\n type: 'linear'\n },\n scatter: {\n radius: 4,\n preprocess: function(data) {\n return data;\n }\n }\n };\n\n function ScatterPlot(data, layer, options) {\n this.checkDependencies('cartesian');\n var duration = options.chart.animations.duration != null ? options.chart.animations.duration : 400;\n var shouldAnimate = options.chart.animations && options.chart.animations.enable;\n var opt = options.scatter;\n var halfRangeBand = this.rangeBand / 2;\n var x = _.bind(function (d) { return this.xScale(d.x) + halfRangeBand; }, this);\n var y = _.bind(function (d) { return this.yScale(d.y); }, this);\n var h = options.chart.plotHeight;\n var classFn = function (d, i) { return d.name + ' series s-' + (i+1); };\n\n data = options.scatter.preprocess(data);\n \n var series = layer.selectAll('.series')\n .data(data);\n\n series.attr('class', classFn);\n\n series.enter().append('svg:g')\n .attr('class', classFn);\n\n series.exit().remove();\n\n var dots = series.selectAll('.dot')\n .data(function (d) { return d.data; }, function (d) {\n return options.scatter.dataKey ? d[options.scatter.dataKey] : d.x;\n });\n\n dots.enter().append('circle')\n .attr('class', 'dot tooltip-tracker')\n .attr('r', opt.radius)\n .attr('cx', x)\n .attr('cy', h);\n\n if (shouldAnimate) {\n dots.transition().duration(duration)\n .attr('r', opt.radius)\n .attr('cx', x)\n .attr('cy', y);\n } else {\n dots.attr('r', opt.radius)\n .attr('cx', x)\n .attr('cy', y);\n }\n\n\n dots.exit().remove();\n }\n\n ScatterPlot.defaults = defaults;\n\n /**\n * Adds a scatter plot to the Contour instance.\n *\n * This visualization requires `.cartesian()`.\n *\n * ### Example:\n *\n * new Contour({el: '.chart'})\n * .cartesian()\n * .scatter([1,2,3,4])\n * .render();\n *\n * @name scatter(data, options)\n * @param {object|array} data The _data series_ to be rendered with this visualization. This can be in any of the supported formats.\n * @param {object} [options] Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n */\n Contour.export('scatter', ScatterPlot);\n\n\n})();\n","(function () {\n var defaults = {\n tooltip: {\n enable: true\n }\n };\n\n /**\n * Adds a tooltip and legend combination for stacked (multiple) series visualizations in the Contour instance.\n * Requires a second display element (`
`) for the legend in the html.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .column(stackedColData)\n * .stackTooltip(stackedColData, {el: '.myChartLegend'})\n * .render();\n *\n * @name stackTooltip(data, options)\n * @param {object|array} data The _data series_ to be rendered with this visualization. This can be in any of the supported formats.\n * @param {object} options Configuration options particular to this visualization that override the defaults. Requires an `el` option with the selector of the container in which to render the tooltip.\n * @api public\n *\n * ### Notes:\n *\n * Each Contour instance can only include one `stackTooltip` visualization.\n */\n function stackTooltip(data, layer, options) {\n\n var valueFormatter = this.yAxis().tickFormat();\n var tooltip = d3.select(options.stackTooltip.el);\n\n tooltip.classed('stack-tooltip', true);\n\n // jshint eqnull:true\n var onMouseOver = function (d) {\n var isNull = function (p) {\n return !(p && p.y != null);\n };\n var mapFn = function (p, i) {\n var index = _.isNumber(d.x) ? d.x : options.xAxis.categories.indexOf(d.x);\n return !isNull(p.data[index]) ?\n { seriesName: p.name, value: p.data[index].y, cssClass: 's-' + (i+1) } :\n null;\n };\n var filtered = _.filter(_.map(data, mapFn), function (x) { return x; });\n var text = _.map(filtered, function (t) { return '' + t.seriesName + ': ' + valueFormatter(t.value) + ''; }).join(' / ');\n tooltip.html(text).style({display: 'block'});\n };\n\n var onMouseOut = function (// datum\n ) {\n tooltip.html('');\n };\n\n this.svg.selectAll('.tooltip-tracker')\n .on('mouseover.tooltip', onMouseOver.bind(this))\n .on('mouseout.tooltip', onMouseOut.bind(this));\n }\n\n stackTooltip.defaults = defaults;\n\n Contour.export('stackTooltip', stackTooltip);\n\n})();\n","(function () {\n var defaults = {\n tooltip: {\n enable: true,\n animate: true,\n opacity: 0.85,\n showTime: 300,\n hideTime: 500,\n distance: 5,\n formatter: undefined //defined in formatters array in getTooltipText()\n }\n };\n\n function render(data, layer, options) {\n\n var clearHideTimer = function () {\n clearTimeout(this.tooltip.hideTimer);\n };\n\n var changeOpacity = function (opacity, delay) {\n if(this.options.tooltip.animate) {\n this.tooltipElement\n .transition().duration(delay)\n .style('opacity', opacity);\n } else {\n this.tooltipElement.style('opacity', opacity);\n }\n };\n\n var positionTooltip = function (d) {\n var pointOrCentroid = function () {\n return d3.event.target.tagName === 'path' ? _.nw.getCentroid(d3.event.target) : d3.mouse(this.container.node());\n };\n var xScale = this.xScale;\n var yScale = this.yScale;\n var plotLeft = this.options.chart.plotLeft;\n var plotWidth = this.options.chart.plotWidth;\n var plotTop = this.options.chart.plotTop;\n var plotHeight = this.options.chart.plotHeight;\n var distance = this.options.tooltip.distance;\n var width = parseFloat(this.tooltipElement.node().offsetWidth);\n var height = parseFloat(this.tooltipElement.node().offsetHeight);\n var pointX = xScale ? xScale(d.x) : pointOrCentroid.call(this)[0];\n var pointY = yScale ? yScale(d.y) : pointOrCentroid.call(this)[1];\n var alignedRight;\n\n var clampPosition = function (pos) {\n // Check outside plot area (left)\n if (pos.x < plotLeft) {\n pos.x = plotLeft + distance;\n }\n\n // Check outside plot area (right)\n if (pos.x + width > plotLeft + plotWidth) {\n pos.x -= (pos.x + width) - (plotLeft + plotWidth);\n // Don't overlap point\n pos.y = plotTop + pointY - (height + distance);\n alignedRight = true;\n }\n\n // Check outside the plot area (top)\n if (pos.y < plotTop) {\n pos.y = plotTop + distance;\n\n // Don't overlap point\n if (alignedRight && pointY >= pos.y && pointY <= pos.y + height) {\n pos.y = pointY + plotTop + distance;\n }\n }\n\n // Check outside the plot area (bottom)\n if (pos.y + height > plotTop + plotHeight) {\n pos.y = Math.max(plotTop, plotTop + plotHeight - (height + distance));\n }\n\n return pos;\n };\n\n var positioner = {\n 'vertical': function verticalPositioner() {\n var pos = {\n x: plotLeft + pointX - (distance + width),\n y: plotTop + pointY - (distance + height)\n };\n\n return clampPosition(pos);\n },\n\n 'horizontal': function horizontalPositioner() {\n var pos = {\n x: plotLeft + pointY - (distance + width),\n y: plotTop + pointX - (distance + height)\n };\n\n return clampPosition(pos);\n }\n };\n\n return options.chart.rotatedFrame ? positioner.horizontal() : positioner.vertical();\n\n };\n\n var onMouseOver = function (d) {\n show.call(this, d);\n };\n\n var onMouseOut = function () {\n changeOpacity.call(this, 0, this.options.tooltip.hideTime);\n };\n\n var getTooltipText = function (d, allPoints) {\n function match() {\n var params = Array.prototype.slice.call(arguments);\n var list = params[0];\n var rest = params.slice(1);\n\n var response = _.map(list, function(fn) { return fn.apply(this, rest); }).concat([_.noop]);\n\n return _.first(_.filter(response));\n }\n\n var options = this.options.tooltip;\n var formatters = [\n function (d) { return options.formatter ? _.partial(options.formatter, d, allPoints) : null; },\n function (d) { return d.hasOwnProperty('x') ? _.partial(function (d) { return d.series + '
' + d.x + '
' + d.y; }, d) : null; },\n function (d) { return d.data && d.data.hasOwnProperty('x') ? _.partial(function (d) { return d.series + '
' + d.x + '
' + d.y; }, d.data) : null; },\n function (d) { return d.hasOwnProperty('value') ? _.partial(function (d) { return d.value; }, d) : null; },\n function () { return function () { return 'NA'; }; }\n ];\n\n\n return match(formatters, d)();\n };\n\n var show = function (d) {\n clearHideTimer.call(this);\n\n var dataPoints = findOriginalDataPoint(d);\n\n this.tooltipElement.select('.text').html(getTooltipText.call(this, d || dataPoints[0], dataPoints));\n\n var pos = positionTooltip.call(this, d);\n\n this.tooltipElement\n .style('top', pos.y + 'px')\n .style('left', pos.x + 'px');\n\n changeOpacity.call(this, this.options.tooltip.opacity, this.options.tooltip.showTime);\n };\n\n function findOriginalDataPoint(d) {\n var res = [];\n _.each(data, function (series, seriesIndex) {\n var name = series.name;\n _.each(series.data, function (point) {\n if (point.x === d.x && d.y === point.y) {\n res.push(_.extend(point, { series: name, seriesIndex:seriesIndex }));\n }\n });\n });\n\n return res;\n }\n\n this.tooltipElement = this.container\n .style('position', 'relative')\n .selectAll('.nw-tooltip').data([1]);\n\n this.tooltipElement\n .enter().append('div')\n .attr('class', 'nw-tooltip')\n .style('opacity', 0)\n .append('div')\n .attr('class', 'text');\n\n this.svg.selectAll('.tooltip-tracker')\n .on('mouseover.tooltip', onMouseOver.bind(this))\n .on('mouseout.tooltip', onMouseOut.bind(this));\n }\n\n render.defaults = defaults;\n\n\n /**\n * Adds a tooltip on hover to all other visualizations in the Contour instance.\n *\n * Although not strictly required, this visualization does not appear unless there are already one or more visualizations in this Contour instance for which to show the tooltips.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .line([2, 4, 3, 5, 7])\n * .tooltip()\n * .render();\n *\n * @name tooltip(data, options)\n * @param {object|array} data Ignored!\n * @param {object} options Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n * ### Notes:\n *\n * Each Contour instance can only include one `tooltip` visualization.\n */\n Contour.export('tooltip', render);\n\n\n})();\n\n\n","(function () {\n\n function normalizeDataSet(dataSet) {\n var all = _.flatten(_.pluck(dataSet, 'data'));\n var isLinear = all.length && _.isNumber(all[0].x);\n var normalizer = function (d, i) { return { x: i, y: d.y }; };\n\n return isLinear ? all : _.map(all, normalizer);\n }\n\n function ctor(raw, layer, options) {\n this.checkDependencies('cartesian');\n var data = normalizeDataSet(raw);\n var duration = options.chart.animations.duration != null ? options.chart.animations.duration : 400;\n var shouldAnimate = options.chart.animations && options.chart.animations.enable;\n var x = _.bind(function(d) { return this.xScale(d) + this.rangeBand / 2; }, this);\n var y = _.bind(function(d) { return this.yScale(d); }, this);\n var regression = _.nw.linearRegression(data);\n var domain = d3.extent(this.xScale.domain());\n var numericDomain = d3.extent(data, function(p) { return p.x; });\n var lineY = function (x) { return regression.intercept + regression.slope * x; };\n\n var line = layer.selectAll('.trend-line')\n .data([1]);\n\n if (isNaN(lineY(numericDomain[0])) || isNaN(lineY(numericDomain[1])) || isNaN(x(domain[0])) || isNaN(x(domain[1]))) {\n line.remove();\n } else {\n line.enter().append('line')\n .attr('class', 'trend-line')\n .attr('x1', x(domain[0]))\n .attr('y1', y(lineY(numericDomain[0])))\n .attr('x2', x(domain[0]))\n .attr('y2', y(lineY(numericDomain[0])));\n\n line.exit().remove();\n\n if (shouldAnimate) {\n line = line.transition().duration(duration);\n }\n\n line.attr('x1', x(domain[0]))\n .attr('y1', y(lineY(numericDomain[0])))\n .attr('x2', x(domain[1]))\n .attr('y2', y(lineY(numericDomain[1])));\n }\n }\n\n ctor.defaults = {};\n\n /**\n * Adds a trend line to the Contour instance, based on linear regression.\n *\n * This visualization requires `.cartesian()`.\n *\n * ### Example:\n *\n * new Contour({el: '.myChart'})\n * .cartesian()\n * .trendLine([2,4,3,5,7])\n * .render();\n *\n * @name trendLine(data, options)\n * @param {object|array} data The _data series_ to be rendered with this visualization. This can be in any of the supported formats. A linear regression is performed on the _data series_ and the resulting trend line is displayed.\n * @param {object} [options] Configuration options particular to this visualization that override the defaults.\n * @api public\n *\n */\n Contour.export('trendLine', ctor);\n\n})();\n"]} \ No newline at end of file diff --git a/src/scripts/core/visualization-container.js b/src/scripts/core/visualization-container.js index ee4dae27..664cd329 100644 --- a/src/scripts/core/visualization-container.js +++ b/src/scripts/core/visualization-container.js @@ -74,6 +74,12 @@ return this.ctx; }, + setVisibility: function (visible) { + var node = this.layer.node(); + + visible ? $(node).show() : $(node).hide(); + }, + _updateDomain: function () { if(!this.options[this.type]) throw new Error('Set the options before calling setData or _updateDomain'); diff --git a/src/scripts/visualizations/legend.js b/src/scripts/visualizations/legend.js index 7ed284ad..1c2ec680 100644 --- a/src/scripts/visualizations/legend.js +++ b/src/scripts/visualizations/legend.js @@ -5,6 +5,7 @@ vAlign: 'middle', hAlign: 'right', direction: 'vertical', + enabled: true, formatter: function (d) { return d.name; }, @@ -34,6 +35,9 @@ } function Legend(data, layer, options) { + if (options.legend.enabled === false) { + return; + } var container; if (options.legend.el) { container = d3.select(options.legend.el).node(); From 8931ce801e95cb0628a13fae229474e6d87fafeb Mon Sep 17 00:00:00 2001 From: Shiv Parikh Date: Wed, 18 Jan 2017 14:11:11 -0800 Subject: [PATCH 3/4] replace jquery with javascript --- src/scripts/core/visualization-container.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/scripts/core/visualization-container.js b/src/scripts/core/visualization-container.js index 664cd329..278a820f 100644 --- a/src/scripts/core/visualization-container.js +++ b/src/scripts/core/visualization-container.js @@ -77,7 +77,9 @@ setVisibility: function (visible) { var node = this.layer.node(); - visible ? $(node).show() : $(node).hide(); + visible ? node.style.display = 'block' : node.style.display = 'none'; + + // visible ? $(node).show() : $(node).hide(); }, _updateDomain: function () { From e12a9ea5862f3298f21a49a30dc1a46b01bc7207 Mon Sep 17 00:00:00 2001 From: Shiv Parikh Date: Wed, 18 Jan 2017 14:15:12 -0800 Subject: [PATCH 4/4] remove unnecessary comment --- src/scripts/core/visualization-container.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/scripts/core/visualization-container.js b/src/scripts/core/visualization-container.js index 278a820f..3eb06f94 100644 --- a/src/scripts/core/visualization-container.js +++ b/src/scripts/core/visualization-container.js @@ -78,8 +78,6 @@ var node = this.layer.node(); visible ? node.style.display = 'block' : node.style.display = 'none'; - - // visible ? $(node).show() : $(node).hide(); }, _updateDomain: function () {