diff --git a/release/nyaplot.js b/release/nyaplot.js index 8574006..5dbfcd3 100644 --- a/release/nyaplot.js +++ b/release/nyaplot.js @@ -1771,8 +1771,10 @@ define("../contrib/almond/almond", function(){}); }).call(this); /* - * Manager is the overall frame manager that holds plots and data - * sources (DataFrame). + * Manager: + * + * Manager is the overall frame manager that holds plots and datasources (DataFrame). + * */ define('core/manager',[ @@ -2061,7 +2063,16 @@ define('core/manager',[ }).call(this); /* + * SimpleLegend: The simplest legend objects + * * SimpleLegend provides legend consists of simple circle buttons and labels. + * + * options(summary) + * title_height -> Float : height of title text. + * mode -> String: 'normal' and 'radio' are allowed. + * + * example: + * http://bl.ocks.org/domitry/e9a914b78f3a576ed3bb */ define('view/components/legend/simple_legend',[ @@ -2074,7 +2085,7 @@ define('view/components/legend/simple_legend',[ width: 150, height: 22, title_height: 15, - mode: 'normal' // or 'radio' + mode: 'normal' }; if(arguments.length>1)_.extend(options, _options); @@ -2093,6 +2104,7 @@ define('view/components/legend/simple_legend',[ return this.options.height * (this.data.length + 1); }; + // Create dom object independent form pane or context and return it. called by each diagram.o SimpleLegend.prototype.getDomObject = function(){ var model = this.model; var options = this.options; @@ -2167,8 +2179,22 @@ define('view/components/legend/simple_legend',[ /* * Bar chart + * * This diagram has two mode, ordinal-mode and count-mode. The former creates bar from x and y column. * The latter counts unique value in 'value' column and generates bar from the result. + * + * + * options: + * value -> String: column name. set when you'd like to build bar chart based on one-dimention data + * x, y -> String: column name. x should be discrete. y should be continuous. + * width -> Float : 0..1, width of each bar. + * color -> Array : color in which bars filled. + * hover -> Bool : set whether pop-up tool-tips when bars are hovered. + * tooltip -> Object: instance of Tooltip. set by pane. + * + * example: + * specified 'value' option : http://bl.ocks.org/domitry/b8785f02f36deef567ce + * specified 'x' and 'y' : http://bl.ocks.org/domitry/2f53781449025f772676 */ define('view/diagrams/bar',[ @@ -2222,6 +2248,7 @@ define('view/diagrams/bar',[ return this; } + // fetch data and update dom object. called by pane which this chart belongs to. Bar.prototype.update = function(){ var data; if(this.options.value !== null){ @@ -2235,23 +2262,20 @@ define('view/diagrams/bar',[ } var rects = this.model.selectAll("rect").data(data); - if(rects[0][0]==undefined){ - rects.enter() - .append("rect") - .attr("height", 0) - .attr("y", this.scales.get(0, 0).y); - } + rects.enter().append("rect") + .attr("height", 0) + .attr("y", this.scales.get(0, 0).y); this.updateModels(rects, this.scales, this.options); }; + // process data as: + // x: [1,2,3,...], y: [4,5,6,...] -> [{x: 1, y: 4},{x: 2, y: 5},...] Bar.prototype.processData = function(x, y, options){ - return _.map( - _.zip(x,y), - function(d, i){return {x:d[0], y:d[1]};} - ); + return _.map(_.zip(x,y),function(d, i){return {x:d[0], y:d[1]};}); }; + // update dom object Bar.prototype.updateModels = function(selector, scales, options){ var color_scale = this.color_scale; @@ -2289,10 +2313,12 @@ define('view/diagrams/bar',[ .on("mouseout", outMouse); }; + // return legend object based on data prepared by initializer Bar.prototype.getLegend = function(){ return new SimpleLegend(this.legend_data); }; + // count unique value. called when 'value' option was specified insead of 'x' and 'y' Bar.prototype.countData = function(values){ var hash = {}; _.each(values, function(val){ @@ -2302,6 +2328,7 @@ define('view/diagrams/bar',[ return {x: _.keys(hash), y: _.values(hash)}; }; + // not implemented yet. Bar.prototype.checkSelectedData = function(ranges){ return; }; @@ -2309,6 +2336,20 @@ define('view/diagrams/bar',[ return Bar; }); +/* + * Filter: + * + * Filtering data according to box on context area. Filter is implemented using d3.svg.brush(). + * See the website of d3.js to learn more: https://github.com/mbostock/d3/wiki/SVG-Controls + * + * options (summary) : + * opacity -> Float : Opacity of filtering area + * color -> String: Color of filtering area + * + * example : + * http://bl.ocks.org/domitry/b8785f02f36deef567ce + */ + define('view/components/filter',[ 'underscore', 'core/manager' @@ -2351,6 +2392,27 @@ define('view/components/filter',[ return Filter; }); +/* + * Histogram: Histogram + * + * Caluculate hights of each bar from column specified by 'value' option and create histogram. + * See the page of 'd3.layout.histogram' on d3.js's website to learn more. (https://github.com/mbostock/d3/wiki/Histogram-Layout) + * + * + * options: + * value -> String: column name. Build histogram based on this data. + * bin_num -> Float : number of bin + * width -> Float : 0..1, width of each bar. + * color -> Array : color in which bars filled. + * stroke_color -> String: stroke color + * stroke_width -> Float : stroke width + * hover -> Bool : set whether pop-up tool-tips when bars are hovered. + * tooltip -> Object: instance of Tooltip. set by pane. + * + * example: + * http://bl.ocks.org/domitry/f0e3f5c91cb83d8d715e + */ + define('view/diagrams/histogram',[ 'underscore', 'node-uuid', @@ -2385,26 +2447,23 @@ define('view/diagrams/histogram',[ return this; } + // fetch data and update dom object. called by pane which this chart belongs to. Histogram.prototype.update = function(){ var column_value = this.df.columnWithFilters(this.uuid, this.options.value); var data = this.processData(column_value, this.options); var models = this.model.selectAll("rect").data(data); - if(models[0][0]==undefined){ - models = models.enter() - .append("rect") - .attr("height", 0) - .attr("y", this.scales.get(0, 0).y); - } - + models.enter().append("rect").attr("height", 0).attr("y", this.scales.get(0, 0).y); this.updateModels(models, this.scales, this.options); }; + // pre-process data using function embeded in d3.js. Histogram.prototype.processData = function(column, options){ return d3.layout.histogram() .bins(this.scales.raw.x.ticks(options.bin_num))(column); }; + // update SVG dom nodes based on pre-processed data. Histogram.prototype.updateModels = function(selector, scales, options){ var onMouse = function(){ d3.select(this).transition() @@ -2439,10 +2498,12 @@ define('view/diagrams/histogram',[ .on("mouseout", outMouse); }; + // return legend object. Histogram.prototype.getLegend = function(){ return new SimpleLegend(this.legend_data); }; + // answer to callback coming from filter. Histogram.prototype.checkSelectedData = function(ranges){ var label_value = this.options.value; var filter = function(row){ @@ -2458,7 +2519,29 @@ define('view/diagrams/histogram',[ }); /* - * Scatter + * Scatter: Scatter and Bubble chart + * + * Scatter chart. This can create bubble chart when specified 'size_by' option. + * Tooltip, fill_by, size_by options should be implemented to other charts refering to this chart. + * + * + * options: + * x,y -> String: column name. both of continuous and descrete data are allowed. + * fill_by -> String: column name. Fill vectors according to this column. (c/d are allowd.) + * shape_by -> String: column name. Fill vectors according to this column. (d is allowd.) + * size_by -> String: column name. Fill vectors according to this column. (c/d are allowd.) + * color -> Array : Array of String. + * shape -> Array : Array of String. + * size -> Array : Array of Float. specified when creating bubble chart. + * stroke_color -> String: stroke color. + * stroke_width -> Float : stroke width. + * hover -> Bool : set whether pop-up tool-tips when bars are hovered. + * tooltip-contents-> Array : Array of column name. Used to create tooltip on points when hovering them. + * tooltip -> Object: instance of Tooltip. set by pane. + * + * example: + * http://bl.ocks.org/domitry/78e2a3300f2f27e18cc8 + * http://bl.ocks.org/domitry/308e27d8d12c1374e61f */ define('view/diagrams/scatter',[ @@ -2513,6 +2596,7 @@ define('view/diagrams/scatter',[ return this; } + // fetch data and update dom object. called by pane which this chart belongs to. Scatter.prototype.update = function(){ var data = this.processData(this.options); this.options.tooltip.reset(); @@ -2525,6 +2609,7 @@ define('view/diagrams/scatter',[ } }; + // pre-process data like: [{x: 1, y: 2, fill: '#000', size: 20, shape: 'triangle-up'}, {},...,{}] Scatter.prototype.processData = function(options){ var df = this.df; var labels = ['x', 'y', 'fill', 'size', 'shape']; @@ -2536,7 +2621,7 @@ define('view/diagrams/scatter',[ var scale = df.scale(options[info.column], options[info.val]); columns.push(_.map(df.column(options[info.column]), function(val){return scale(val);})); }else{ - columns.push(_.map(_.range(1, length, 1), function(d){ + columns.push(_.map(_.range(1, length+1, 1), function(d){ if(_.isArray(options[info.val]))return options[info.val][0]; else return options[info.val]; })); @@ -2554,6 +2639,7 @@ define('view/diagrams/scatter',[ }); }; + // update SVG dom nodes based on pre-processed data. Scatter.prototype.updateModels = function(selector, scales, options){ var id = this.uuid; @@ -2590,10 +2676,12 @@ define('view/diagrams/scatter',[ .on("mouseout", outMouse); }; + // return legend object. Scatter.prototype.getLegend = function(){ return new SimpleLegend(this.legend_data); }; + // answer to callback coming from filter. Scatter.prototype.checkSelectedData = function(ranges){ return; }; @@ -2601,6 +2689,24 @@ define('view/diagrams/scatter',[ return Scatter; }); +/* + * Line: Line chart + * + * Attention: 'Line' is totally designed to be used to visualize line chart for Mathematics. So it is not useful to visualize statistical data like stock price. + * If you feel so, feel free to add options like 'shape', 'shape_by' and 'fill_by' to this chart and send pull-request. + * Please be sure to refer to the code of other chart like scatter at that time. + * + * + * options: + * title -> String: title of this chart showen on legend + * x,y -> String: column name. + * color -> Array : color in which line is filled. + * stroke_width -> Float : stroke width. + * + * example: + * http://bl.ocks.org/domitry/e9a914b78f3a576ed3bb + */ + define('view/diagrams/line',[ 'underscore', 'core/manager', @@ -2609,9 +2715,9 @@ define('view/diagrams/line',[ ],function(_, Manager, Filter, SimpleLegend){ function Line(parent, scales, df_id, _options){ var options = { + title: 'line', x: null, y: null, - title: 'line', color:'steelblue', stroke_width: 2 }; @@ -2643,6 +2749,7 @@ define('view/diagrams/line',[ return this; } + // fetch data and update dom object. called by pane which this chart belongs to. Line.prototype.update = function(){ if(this.render){ var data = this.processData(this.df.column(this.options.x), this.df.column(this.options.y), this.options); @@ -2657,10 +2764,12 @@ define('view/diagrams/line',[ } }; + // pre-process data like: x: [1,3,..,3], y: [2,3,..,4] -> [{x: 1, y: 2}, ... ,{}] Line.prototype.processData = function(x_arr, y_arr, options){ return _.map(_.zip(x_arr, y_arr), function(d){return {x:d[0], y:d[1]};}); }; + // update SVG dom nodes based on pre-processed data. Line.prototype.updateModels = function(selector, scales, options){ var onMouse = function(){ d3.select(this).transition() @@ -2685,11 +2794,13 @@ define('view/diagrams/line',[ .attr("fill", "none"); }; + // return legend object. Line.prototype.getLegend = function(){ var legend = new SimpleLegend(this.legend_data); return legend; }; + // answer to callback coming from filter. Line.prototype.checkSelectedData = function(ranges){ return; }; @@ -2697,8 +2808,15 @@ define('view/diagrams/line',[ return Line; }); +/* + * Simplex: + * + * Implementation of downhill simplex method. + * See Wikipedia: http://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method + */ + + define('utils/simplex',['underscore'], function(_){ - // constant values var l_1 = 0.7, l_2 = 1.5; var EPS = 1.0e-20; var count = 0, COUNT_LIMIT=2000; @@ -2774,6 +2892,28 @@ define('utils/simplex',['underscore'], function(_){ return simplex; }); +/* + * Venn: 3-way venn diagram + * + * The implementation of traditional 3-way venn diagram. This chart is designed to work with histogram and bar chart. (See example at the bottom of this comment.) + * The overlapping areas are automatically changed according to common values in each pair of group. The calculation is excuted with downhill simplex method. + * Attention: This is still experimental implementation and should be modernized. Feel free to re-write the code below and send pull-request. + * + * + * options: + * category, count-> String: Column name. + * color -> Array : Array of String. Colors in which circles are filled. + * stroke_color -> String: stroke color. + * stroke_width -> Float : stroke width. + * hover -> Bool : set whether pop-up tool-tips when bars are hovered. + * area_names -> Array : Array of String. Names for each groups. + * filter_control -> Bool : Wheter to display controller for filtering. See the second example below. + * + * example: + * http://bl.ocks.org/domitry/d70dff56885218c7ad9a + * http://www.domitry.com/gsoc/multi_pane2.html + */ + define('view/diagrams/venn',[ 'underscore', 'core/manager', @@ -2868,6 +3008,7 @@ define('view/diagrams/venn',[ return this; } + // X->x, Y->y scales given by pane is useless when creating venn diagram, so create new scale consists of x, y, and r. Venn.prototype.getScales = function(data, scales){ var r_w = _.max(scales.range().x) - _.min(scales.range().x); var r_h = _.max(scales.range().y) - _.min(scales.range().y); @@ -2902,6 +3043,7 @@ define('view/diagrams/venn',[ return new_scales; }; + // fetch data and update dom objects. Venn.prototype.update = function(){ var column_count = this.df.columnWithFilters(this.uuid, this.options.count); var column_category = this.df.columnWithFilters(this.uuid, this.options.category); @@ -2919,6 +3061,7 @@ define('view/diagrams/venn',[ this.updateLabels(texts, scales, this.options); }; + // Calculate overlapping areas at first, and then decide center point of each circle with simplex module. Venn.prototype.processData = function(category_column, count_column, selected_category){ // decide overlapping areas var items = (function(){ @@ -3027,6 +3170,7 @@ define('view/diagrams/venn',[ return {pos:pos, labels:labels, counted_items:counted_items}; }; + // update dom objects according to pre-processed data. Venn.prototype.updateModels = function(selector, scales, options){ var color_scale = this.color_scale; var area_names = this.options.area_names; @@ -3061,6 +3205,7 @@ define('view/diagrams/venn',[ } }; + // update labels placed the center point between each pair of circle. Venn.prototype.updateLabels = function(selector, scales, options){ selector .attr("x", function(d){return scales.x(d.x);}) @@ -3069,10 +3214,12 @@ define('view/diagrams/venn',[ .text(function(d){return String(d.val);}); }; + // return legend object. Venn.prototype.getLegend = function(){ return this.legend_data; }; + // tell update to Manager when venn recieved change from filter controller. Venn.prototype.tellUpdate = function(){ var rows=[], selected_category = this.selected_category; var counted_items = this.counted_items; @@ -3126,6 +3273,13 @@ define('view/diagrams/venn',[ return Venn; }); +/* + * Venn: Venn diagram consisted in 3> circles + * + * Attention -- this chart is not supported yet. Please send pull-req if you are interested in re-implementing this chart. + * See src/view/diagrams/venn.js to learn more. + */ + define('view/diagrams/multiple_venn',[ 'underscore', 'core/manager', @@ -3384,9 +3538,26 @@ define('view/diagrams/multiple_venn',[ }); /* - * Box: Implementation of Boxplot for Nyaplot. + * Box: Boxplot + * + * This chart is generated from 'value' columns. Box calculates median and other parameters and create box plot using rect and line. + * Each box is placed in the position on x-axis, corresponds to column name. + * + * options: + * title -> String: title of this chart showen on legend + * value -> Array : Array of String (column name) + * width -> Float : 0..1, width of each box + * color -> Array : color in which bars filled. + * stroke_color -> String: stroke color + * stroke_width -> Float : stroke width + * outlier_r -> Float : radius of outliers + * tooltip -> Object: instance of Tooltip. set by pane. + * + * example: + * http://bl.ocks.org/domitry/5a89296dfb23f0ea2ffd */ + define('view/diagrams/box.js',[ 'underscore', 'node-uuid', @@ -3428,7 +3599,7 @@ define('view/diagrams/box.js',[ return this; } - // proceed data and build SVG dom node + // fetch data and update dom object. called by pane which this chart belongs to. Box.prototype.update = function(){ var uuid = this.uuid; var processData = this.processData; @@ -3543,11 +3714,12 @@ define('view/diagrams/box.js',[ }); }; + // return legend object based on data prepared by initializer Box.prototype.getLegend = function(){ return new SimpleLegend(this.legend_data); }; - // answer to callback coming from filter + // answer to callback coming from filter. not implemented yet. Box.prototype.checkSelectedData = function(ranges){ return; }; @@ -3556,8 +3728,17 @@ define('view/diagrams/box.js',[ }); /* - * Colorset provides colorbar filled with gradient for continuous data. + * ColorBar: + * + * ColorBar provides colorbar filled with gradient for continuous data. * Each diagram create an instance of Colorset and Pane append it to itself. + * + * options: + * width -> Float: width of the whole area for colorset (not noly for bar) + * height-> Float: height of the area for colorset + * + * example: + * http://bl.ocks.org/domitry/11322618 */ define('view/components/legend/color_bar',[ @@ -3583,6 +3764,7 @@ define('view/components/legend/color_bar',[ return this.options.height; }; + // Create dom object independent form pane or context and return it. called by each diagram.o ColorBar.prototype.getDomObject = function(){ var model = this.model; var color_scale = this.color_scale; @@ -3687,6 +3869,13 @@ return{ } }); +/* + * Colorset: The wrapper for colorbrewer + * + * Return colorset that have required name and number. + * See the website of colorbrewer to learn more: http://colorbrewer2.org/ + */ + define('utils/color',[ 'underscore', 'colorbrewer' @@ -3704,9 +3893,22 @@ define('utils/color',[ }); /* - * Heatmap or 2D Histogram - * Heatmap creates rectangles from discrete data or continuous data. When creating heatmap from continuous - * data, width and height values options should be specified. + * Heatmap: Heatmap or 2D Histogram + * + * Heatmap creates rectangles from continuous data. Width and height values should be specified. + * + * options: + * title -> String: title of this chart showen on legend + * x, y -> String: column name. Both x and y should be continuous. + * width, height-> Float : 0..1, width and height of each rectangle + * color -> Array : color in which bars filled. + * stroke_color -> String: stroke color + * stroke_width -> Float : stroke width + * hover -> Bool : set whether pop-up tool-tips when bars are hovered. + * tooltip -> Object: instance of Tooltip. set by pane. + * + * example: + * http://bl.ocks.org/domitry/eab8723ccb32fd3a6cd8 */ define('view/diagrams/heatmap.js',[ @@ -3728,7 +3930,8 @@ define('view/diagrams/heatmap.js',[ color: colorset("RdBu").reverse(), stroke_color: "#fff", stroke_width: 1, - hover: true + hover: true, + tooltip: null }; if(arguments.length>3)_.extend(options, _options); @@ -3752,6 +3955,7 @@ define('view/diagrams/heatmap.js',[ return this; }; + // fetch data and update dom object. called by pane which this chart belongs to. HeatMap.prototype.update = function(){ var data = this.processData(); var models = this.model.selectAll("rect").data(data); @@ -3764,6 +3968,7 @@ define('view/diagrams/heatmap.js',[ this.updateModels(models, this.options); }; + // pre-process data. convert data coorinates to dom coordinates with Scale. HeatMap.prototype.processData = function(){ var column_x = this.df.columnWithFilters(this.uuid, this.options.x); var column_y = this.df.columnWithFilters(this.uuid, this.options.y); @@ -3774,16 +3979,15 @@ define('view/diagrams/heatmap.js',[ return _.map(_.zip(column_x, column_y, column_fill), function(row){ var x, y, width, height; - // linear scale width = Math.abs(scales.get(options.width, 0).x - scales.get(0, 0).x); height = Math.abs(scales.get(0, options.height).y - scales.get(0, 0).y); x = scales.get(row[0], 0).x - width/2; y = scales.get(0, row[1]).y - height/2; - return {x: x, y:y, width:width, height:height, fill:color_scale(row[2]), x_raw: row[0], y_raw: row[1]}; }); }; + // update SVG dom nodes based on pre-processed data. HeatMap.prototype.updateModels = function(selector, options){ var id = this.uuid; var onMouse = function(){ @@ -3816,10 +4020,12 @@ define('view/diagrams/heatmap.js',[ .on("mouseout", outMouse); }; + // return legend object. HeatMap.prototype.getLegend = function(){ return new ColorBar(this.color_scale); }; + // answer to callback coming from filter. not implemented yet. HeatMap.prototype.checkSelectedData = function(ranges){ return; }; @@ -3827,6 +4033,26 @@ define('view/diagrams/heatmap.js',[ return HeatMap; }); +/* + * Vectors: Vector Field + * + * Draw vector field from x, y, dx, dy column. This chart is designed to visualize wind vector data. + * See Nyaplot's notebook: http://nbviewer.ipython.org/github/domitry/nyaplot/blob/master/examples/notebook/Mapnya2.ipynb + * + * + * options: + * x,y,dx,dy -> String: column name. + * fill_by -> String: column name. Fill vectors according to this column. (both of continuous and descrete data are allowed.) + * color -> Array : color in which vectors are filled. + * stroke_color -> String: stroke color. + * stroke_width -> Float : stroke width. + * hover -> Bool : set whether pop-up tool-tips when bars are hovered. + * tooltip -> Object: instance of Tooltip. set by pane. + * + * example: + * http://bl.ocks.org/domitry/1e1222cbc48ab3880849 + */ + define('view/diagrams/vectors.js',[ 'underscore', 'node-uuid', @@ -3845,7 +4071,7 @@ define('view/diagrams/vectors.js',[ color:['steelblue', '#000000'], stroke_color: '#000', stroke_width: 2, - hover: false, + hover: true, tooltip:null }; if(arguments.length>3)_.extend(options, _options); @@ -3876,6 +4102,7 @@ define('view/diagrams/vectors.js',[ return this; } + // fetch data and update dom object. called by pane which this chart belongs to. Vectors.prototype.update = function(){ var data = this.processData(this.options); this.options.tooltip.reset(); @@ -3888,6 +4115,7 @@ define('view/diagrams/vectors.js',[ } }; + // pre-process data like: [{x: 1, y: 2, dx: 0.1, dy: 0.2, fill:'#000'}, {},...,{}] Vectors.prototype.processData = function(options){ var df = this.df; var labels = ['x', 'y', 'dx', 'dy', 'fill']; @@ -3899,7 +4127,7 @@ define('view/diagrams/vectors.js',[ var scale = df.scale(options[info.column], options[info.val]); columns.push(_.map(df.column(options[info.column]), function(val){return scale(val);})); }else{ - columns.push(_.map(_.range(1, length, 1), function(d){ + columns.push(_.map(_.range(1, length+1, 1), function(d){ if(_.isArray(options[info.val]))return options[info.val][0]; else return options[info.val]; })); @@ -3911,6 +4139,7 @@ define('view/diagrams/vectors.js',[ }); }; + // update SVG dom nodes based on pre-processed data. Vectors.prototype.updateModels = function(selector, scales, options){ selector .attr({ @@ -3923,10 +4152,12 @@ define('view/diagrams/vectors.js',[ }); }; + // return legend object. Vectors.prototype.getLegend = function(){ return new SimpleLegend(this.legend_data); }; + // answer to callback coming from filter. Vectors.prototype.checkSelectedData = function(ranges){ return; }; @@ -3934,6 +4165,13 @@ define('view/diagrams/vectors.js',[ return Vectors; }); +/* + * Diagrams: Diagrams Factory + * + * Diagrams manages all diagrams bundled by Nyaplotjs. Extension registers their own diagrams through this module. + * + */ + define('view/diagrams/diagrams',['require','exports','module','view/diagrams/bar','view/diagrams/histogram','view/diagrams/scatter','view/diagrams/line','view/diagrams/venn','view/diagrams/multiple_venn','view/diagrams/box.js','view/diagrams/heatmap.js','view/diagrams/vectors.js'],function(require, exports, module){ var diagrams = {}; @@ -3947,6 +4185,7 @@ define('view/diagrams/diagrams',['require','exports','module','view/diagrams/bar diagrams.heatmap = require('view/diagrams/heatmap.js'); diagrams.vectors = require('view/diagrams/vectors.js'); + // Add diagrams. Called by other extensions diagrams.add = function(name, diagram){ diagrams[name] = diagram; }; @@ -3955,8 +4194,17 @@ define('view/diagrams/diagrams',['require','exports','module','view/diagrams/bar }); /* - * LegendArea keep a dom object which legends will be placed on and - * add legends on the best place in it. + * LegendArea: Space for legends + * + * LegendArea keep a dom object which legends will be placed on and add legends on the best place in it. + * + * options (summary): + * width -> Float : width of legend area + * height-> Float : height of legend area + * margin-> Object: margin inside of legend area + * + * example: + * http://bl.ocks.org/domitry/e9a914b78f3a576ed3bb */ define('view/components/legend_area',[ @@ -4026,8 +4274,22 @@ define('utils/ua_info',['underscore'], function(_){ }); /* - * Tooltip is an interface for generating small tool-tips and rendering them. + * Tooltip: + * + * Tooltip is an module to generate small tool-tips and rendering them. * Pane generate its instance and keep it. Then each diagrams send requests to it. + * + * options (summary): + * arrow_width -> Float : Width of arrow. See diagram below. + * arrow_height -> Float : Height of arrow. + * tooltip_margin-> Object: Margin inside of tool-tip box. + * + * ------ + * |_ _ | + * \/ <=== arrow + * + * example: + * http://bl.ocks.org/domitry/78e2a3300f2f27e18cc8 */ define('view/components/tooltip',[ @@ -4100,7 +4362,6 @@ define('view/components/tooltip',[ this.updateModels(model); }; - // generate dom objects for new tool-tips, and delete old ones Tooltip.prototype.updateModels = function(model){ model.exit().remove(); @@ -4257,8 +4518,19 @@ define('view/components/tooltip',[ }); /* - * Pane keeps a dom object which diagrams, filter, and legend will be placed on. - * It also calcurate scales and each diagram and axis will be rendered base on the scales. + * Pane: + * + * Pane keeps dom objects which diagrams, filter, and legend will be placed on. Pane will tell each diagram, axis, and scale to update. + * It also calcurate scales and each diagram and axis will be rendered according to the scales. + * + * options (summary) : + * rotate_x_label -> (Float) : rotate labels placed on x-axis (radian) + * zoom -> (Bool) : Decide whether to allow zooming and pan + * grid -> (Bool) : Decide whether to draw grid line on pane. + * legend_position -> (Object): String like 'right', 'left', 'top' and 'bottom', or Array like [0, 19] are allowed. The latter is coordinates in the plotting area. + * scale: -> (String): The type of axis. 'linear', 'log' and 'power' are allowed. + * scale_extra_options -> (Object): extra options for extension which has different coordinates system except x-y. + * axis_extra_options -> (Object): extra options for extension. */ define('view/pane',[ @@ -4495,8 +4767,17 @@ define('view/pane',[ }); /* + * Axis: + * * Axis generates x and y axies for plot. It also controlls grids. * Have a look at documents on d3.svg.axis and d3.behavior.zoom to learn more. + * + * options (summary) : + * width -> (Float) : Width of *context area*. + * height -> (Float) : Height of *context area*. + * margin -> (Object): Margin outside of context area. used when adding axis labels. + * pane_uuid -> (Float) : Given by pane itself. used to tell update information to Manager. + * z_index -> (Float) : Given by pane. Usually axis are placed below context and over backgroupd. */ define('view/components/axis',[ @@ -4620,13 +4901,22 @@ define('view/components/axis',[ }); /* - * the wrapper for d3.scales.ordinal and d3.scales.linear + * Scales: The wrapper for d3.scales + * + * Scales for x-y coordinates system. Other types of scales are implemented by extension system like Bionya and Mapnya. + * If you are interested in writing extension for Nyaplot, see the code of extensions. + * This module is implemented using d3.scales.ordinal and d3.scales.linear. See the document of d3.js to learn more about scales: + * - https://github.com/mbostock/d3/wiki/Ordinal-Scales + * - https://github.com/mbostock/d3/wiki/Quantitative-Scales + * + * options: + * linear -> String: The type of linear scale. 'linear', 'power', and 'log' are allowed. */ define('view/components/scale',['underscore'], function(_){ function Scales(domains, ranges, _options){ var options = { - linear: 'linear' //linear, power, and log + linear: 'linear' }; if(arguments.length>1)_.extend(options, _options); @@ -4651,6 +4941,7 @@ define('view/components/scale',['underscore'], function(_){ return this; } + // convert from data points to svg dom coordiantes like: ['nya', 'hoge'] -> {x: 23, y:56}] Scales.prototype.get = function(x, y){ return { x: this.scales.x(x), @@ -4658,6 +4949,7 @@ define('view/components/scale',['underscore'], function(_){ }; }; + // domain: the word unique to d3.js. See the website of d3.js. Scales.prototype.domain = function(){ return { x: this.scales.x.domain(), @@ -4665,6 +4957,7 @@ define('view/components/scale',['underscore'], function(_){ }; }; + // range: the word unique to d3.js. See the website of d3.js. Scales.prototype.range = function(){ return { x: this.scales.x.range(), @@ -4676,6 +4969,8 @@ define('view/components/scale',['underscore'], function(_){ }); /* + * STL: + * * Standard library for Nyaplot */ @@ -4688,6 +4983,8 @@ define('core/stl',['require','exports','module','view/pane','view/components/axi }); /* + * Extension: + * * Extension keeps information about extensions for Nyaplot. * */ @@ -4729,6 +5026,8 @@ define('core/extension',[ }); /* + * Dataframe: + * * Dataframe loads (JSON) data or through a URI and allows * a plot to query that data */ @@ -4828,12 +5127,14 @@ define('utils/dataframe',[ }); }; + // experimental implementation of accessor to nested dataframe. Dataframe.prototype.nested_column = function(row_num, name){ if(!this.nested)throw "Recieved dataframe is not nested."; var df = new Dataframe('', this.row(row_num)[this.nested]); return df.column(name); }; + // return the range of values in specified column Dataframe.prototype.columnRange = function(label){ var column = this.column(label); return { @@ -4846,6 +5147,8 @@ define('utils/dataframe',[ }); /* + * parse: + * * parse JSON model and generate plots based on the order. * */ diff --git a/release/nyaplot.min.js b/release/nyaplot.min.js index f992eae..9cdcfc2 100644 --- a/release/nyaplot.min.js +++ b/release/nyaplot.min.js @@ -14,6 +14,6 @@ // Copyright (c) 2010-2012 Robert Kieffer // MIT License - http://opensource.org/licenses/mit-license.php -!function(r,t){r.Nyaplot=t()}(this,function(){var r,t,e;return function(n){function i(r,t){return x.call(r,t)}function o(r,t){var e,n,i,o,g,a,b,s,l,u,c,d=t&&t.split("/"),f=y.map,p=f&&f["*"]||{};if(r&&"."===r.charAt(0))if(t){for(d=d.slice(0,d.length-1),r=r.split("/"),g=r.length-1,y.nodeIdCompat&&w.test(r[g])&&(r[g]=r[g].replace(w,"")),r=d.concat(r),l=0;l0&&(r.splice(l-1,2),l-=2)}r=r.join("/")}else 0===r.indexOf("./")&&(r=r.substring(2));if((d||p)&&f){for(e=r.split("/"),l=e.length;l>0;l-=1){if(n=e.slice(0,l).join("/"),d)for(u=d.length;u>0;u-=1)if(i=f[d.slice(0,u).join("/")],i&&(i=i[n])){o=i,a=l;break}if(o)break;!b&&p&&p[n]&&(b=p[n],s=l)}!o&&b&&(o=b,a=s),o&&(e.splice(0,a,o),r=e.join("/"))}return r}function g(r,t){return function(){return d.apply(n,_.call(arguments,0).concat([r,t]))}}function a(r){return function(t){return o(t,r)}}function b(r){return function(t){h[r]=t}}function s(r){if(i(m,r)){var t=m[r];delete m[r],v[r]=!0,c.apply(n,t)}if(!i(h,r)&&!i(v,r))throw new Error("No "+r);return h[r]}function l(r){var t,e=r?r.indexOf("!"):-1;return e>-1&&(t=r.substring(0,e),r=r.substring(e+1,r.length)),[t,r]}function u(r){return function(){return y&&y.config&&y.config[r]||{}}}var c,d,f,p,h={},m={},y={},v={},x=Object.prototype.hasOwnProperty,_=[].slice,w=/\.js$/;f=function(r,t){var e,n=l(r),i=n[0];return r=n[1],i&&(i=o(i,t),e=s(i)),i?r=e&&e.normalize?e.normalize(r,a(t)):o(r,t):(r=o(r,t),n=l(r),i=n[0],r=n[1],i&&(e=s(i))),{f:i?i+"!"+r:r,n:r,pr:i,p:e}},p={require:function(r){return g(r)},exports:function(r){var t=h[r];return"undefined"!=typeof t?t:h[r]={}},module:function(r){return{id:r,uri:"",exports:h[r],config:u(r)}}},c=function(r,t,e,o){var a,l,u,c,d,y,x=[],_=typeof e;if(o=o||r,"undefined"===_||"function"===_){for(t=!t.length&&e.length?["require","exports","module"]:t,d=0;di;i++)if(t.call(e,r[i],i,r)===n)return}else for(var g=A.keys(r),i=0,o=g.length;o>i;i++)if(t.call(e,r[g[i]],g[i],r)===n)return;return r};A.map=A.collect=function(r,t,e){var n=[];return null==r?n:d&&r.map===d?r.map(t,e):(M(r,function(r,i,o){n.push(t.call(e,r,i,o))}),n)};var q="Reduce of empty array with no initial value";A.reduce=A.foldl=A.inject=function(r,t,e,n){var i=arguments.length>2;if(null==r&&(r=[]),f&&r.reduce===f)return n&&(t=A.bind(t,n)),i?r.reduce(t,e):r.reduce(t);if(M(r,function(r,o,g){i?e=t.call(n,e,r,o,g):(e=r,i=!0)}),!i)throw new TypeError(q);return e},A.reduceRight=A.foldr=function(r,t,e,n){var i=arguments.length>2;if(null==r&&(r=[]),p&&r.reduceRight===p)return n&&(t=A.bind(t,n)),i?r.reduceRight(t,e):r.reduceRight(t);var o=r.length;if(o!==+o){var g=A.keys(r);o=g.length}if(M(r,function(a,b,s){b=g?g[--o]:--o,i?e=t.call(n,e,r[b],b,s):(e=r[b],i=!0)}),!i)throw new TypeError(q);return e},A.find=A.detect=function(r,t,e){var n;return D(r,function(r,i,o){return t.call(e,r,i,o)?(n=r,!0):void 0}),n},A.filter=A.select=function(r,t,e){var n=[];return null==r?n:h&&r.filter===h?r.filter(t,e):(M(r,function(r,i,o){t.call(e,r,i,o)&&n.push(r)}),n)},A.reject=function(r,t,e){return A.filter(r,function(r,n,i){return!t.call(e,r,n,i)},e)},A.every=A.all=function(r,t,e){t||(t=A.identity);var i=!0;return null==r?i:m&&r.every===m?r.every(t,e):(M(r,function(r,o,g){return(i=i&&t.call(e,r,o,g))?void 0:n}),!!i)};var D=A.some=A.any=function(r,t,e){t||(t=A.identity);var i=!1;return null==r?i:y&&r.some===y?r.some(t,e):(M(r,function(r,o,g){return i||(i=t.call(e,r,o,g))?n:void 0}),!!i)};A.contains=A.include=function(r,t){return null==r?!1:v&&r.indexOf===v?-1!=r.indexOf(t):D(r,function(r){return r===t})},A.invoke=function(r,t){var e=b.call(arguments,2),n=A.isFunction(t);return A.map(r,function(r){return(n?t:r[t]).apply(r,e)})},A.pluck=function(r,t){return A.map(r,A.property(t))},A.where=function(r,t){return A.filter(r,A.matches(t))},A.findWhere=function(r,t){return A.find(r,A.matches(t))},A.max=function(r,t,e){if(!t&&A.isArray(r)&&r[0]===+r[0]&&r.length<65535)return Math.max.apply(Math,r);var n=-1/0,i=-1/0;return M(r,function(r,o,g){var a=t?t.call(e,r,o,g):r;a>i&&(n=r,i=a)}),n},A.min=function(r,t,e){if(!t&&A.isArray(r)&&r[0]===+r[0]&&r.length<65535)return Math.min.apply(Math,r);var n=1/0,i=1/0;return M(r,function(r,o,g){var a=t?t.call(e,r,o,g):r;i>a&&(n=r,i=a)}),n},A.shuffle=function(r){var t,e=0,n=[];return M(r,function(r){t=A.random(e++),n[e-1]=n[t],n[t]=r}),n},A.sample=function(r,t,e){return null==t||e?(r.length!==+r.length&&(r=A.values(r)),r[A.random(r.length-1)]):A.shuffle(r).slice(0,Math.max(0,t))};var z=function(r){return null==r?A.identity:A.isFunction(r)?r:A.property(r)};A.sortBy=function(r,t,e){return t=z(t),A.pluck(A.map(r,function(r,n,i){return{value:r,index:n,criteria:t.call(e,r,n,i)}}).sort(function(r,t){var e=r.criteria,n=t.criteria;if(e!==n){if(e>n||void 0===e)return 1;if(n>e||void 0===n)return-1}return r.index-t.index}),"value")};var j=function(r){return function(t,e,n){var i={};return e=z(e),M(t,function(o,g){var a=e.call(n,o,g,t);r(i,a,o)}),i}};A.groupBy=j(function(r,t,e){A.has(r,t)?r[t].push(e):r[t]=[e]}),A.indexBy=j(function(r,t,e){r[t]=e}),A.countBy=j(function(r,t){A.has(r,t)?r[t]++:r[t]=1}),A.sortedIndex=function(r,t,e,n){e=z(e);for(var i=e.call(n,t),o=0,g=r.length;g>o;){var a=o+g>>>1;e.call(n,r[a])t?[]:b.call(r,0,t)},A.initial=function(r,t,e){return b.call(r,0,r.length-(null==t||e?1:t))},A.last=function(r,t,e){return null==r?void 0:null==t||e?r[r.length-1]:b.call(r,Math.max(r.length-t,0))},A.rest=A.tail=A.drop=function(r,t,e){return b.call(r,null==t||e?1:t)},A.compact=function(r){return A.filter(r,A.identity)};var S=function(r,t,e){return t&&A.every(r,A.isArray)?s.apply(e,r):(M(r,function(r){A.isArray(r)||A.isArguments(r)?t?a.apply(e,r):S(r,t,e):e.push(r)}),e)};A.flatten=function(r,t){return S(r,t,[])},A.without=function(r){return A.difference(r,b.call(arguments,1))},A.partition=function(r,t){var e=[],n=[];return M(r,function(r){(t(r)?e:n).push(r)}),[e,n]},A.uniq=A.unique=function(r,t,e,n){A.isFunction(t)&&(n=e,e=t,t=!1);var i=e?A.map(r,e,n):r,o=[],g=[];return M(i,function(e,n){(t?n&&g[g.length-1]===e:A.contains(g,e))||(g.push(e),o.push(r[n]))}),o},A.union=function(){return A.uniq(A.flatten(arguments,!0))},A.intersection=function(r){var t=b.call(arguments,1);return A.filter(A.uniq(r),function(r){return A.every(t,function(t){return A.contains(t,r)})})},A.difference=function(r){var t=s.apply(i,b.call(arguments,1));return A.filter(r,function(r){return!A.contains(t,r)})},A.zip=function(){for(var r=A.max(A.pluck(arguments,"length").concat(0)),t=new Array(r),e=0;r>e;e++)t[e]=A.pluck(arguments,""+e);return t},A.object=function(r,t){if(null==r)return{};for(var e={},n=0,i=r.length;i>n;n++)t?e[r[n]]=t[n]:e[r[n][0]]=r[n][1];return e},A.indexOf=function(r,t,e){if(null==r)return-1;var n=0,i=r.length;if(e){if("number"!=typeof e)return n=A.sortedIndex(r,t),r[n]===t?n:-1;n=0>e?Math.max(0,i+e):e}if(v&&r.indexOf===v)return r.indexOf(t,e);for(;i>n;n++)if(r[n]===t)return n;return-1},A.lastIndexOf=function(r,t,e){if(null==r)return-1;var n=null!=e;if(x&&r.lastIndexOf===x)return n?r.lastIndexOf(t,e):r.lastIndexOf(t);for(var i=n?e:r.length;i--;)if(r[i]===t)return i;return-1},A.range=function(r,t,e){arguments.length<=1&&(t=r||0,r=0),e=arguments[2]||1;for(var n=Math.max(Math.ceil((t-r)/e),0),i=0,o=new Array(n);n>i;)o[i++]=r,r+=e;return o};var O=function(){};A.bind=function(r,t){var e,n;if(k&&r.bind===k)return k.apply(r,b.call(arguments,1));if(!A.isFunction(r))throw new TypeError;return e=b.call(arguments,2),n=function(){if(!(this instanceof n))return r.apply(t,e.concat(b.call(arguments)));O.prototype=r.prototype;var i=new O;O.prototype=null;var o=r.apply(i,e.concat(b.call(arguments)));return Object(o)===o?o:i}},A.partial=function(r){var t=b.call(arguments,1);return function(){for(var e=0,n=t.slice(),i=0,o=n.length;o>i;i++)n[i]===A&&(n[i]=arguments[e++]);for(;e=l?(clearTimeout(g),g=null,a=s,o=r.apply(n,i),n=i=null):g||e.trailing===!1||(g=setTimeout(b,l)),o}},A.debounce=function(r,t,e){var n,i,o,g,a,b=function(){var s=A.now()-g;t>s?n=setTimeout(b,t-s):(n=null,e||(a=r.apply(o,i),o=i=null))};return function(){o=this,i=arguments,g=A.now();var s=e&&!n;return n||(n=setTimeout(b,t)),s&&(a=r.apply(o,i),o=i=null),a}},A.once=function(r){var t,e=!1;return function(){return e?t:(e=!0,t=r.apply(this,arguments),r=null,t)}},A.wrap=function(r,t){return A.partial(t,r)},A.compose=function(){var r=arguments;return function(){for(var t=arguments,e=r.length-1;e>=0;e--)t=[r[e].apply(this,t)];return t[0]}},A.after=function(r,t){return function(){return--r<1?t.apply(this,arguments):void 0}},A.keys=function(r){if(!A.isObject(r))return[];if(w)return w(r);var t=[];for(var e in r)A.has(r,e)&&t.push(e);return t},A.values=function(r){for(var t=A.keys(r),e=t.length,n=new Array(e),i=0;e>i;i++)n[i]=r[t[i]];return n},A.pairs=function(r){for(var t=A.keys(r),e=t.length,n=new Array(e),i=0;e>i;i++)n[i]=[t[i],r[t[i]]];return n},A.invert=function(r){for(var t={},e=A.keys(r),n=0,i=e.length;i>n;n++)t[r[e[n]]]=e[n];return t},A.functions=A.methods=function(r){var t=[];for(var e in r)A.isFunction(r[e])&&t.push(e);return t.sort()},A.extend=function(r){return M(b.call(arguments,1),function(t){if(t)for(var e in t)r[e]=t[e]}),r},A.pick=function(r){var t={},e=s.apply(i,b.call(arguments,1));return M(e,function(e){e in r&&(t[e]=r[e])}),t},A.omit=function(r){var t={},e=s.apply(i,b.call(arguments,1));for(var n in r)A.contains(e,n)||(t[n]=r[n]);return t},A.defaults=function(r){return M(b.call(arguments,1),function(t){if(t)for(var e in t)void 0===r[e]&&(r[e]=t[e])}),r},A.clone=function(r){return A.isObject(r)?A.isArray(r)?r.slice():A.extend({},r):r},A.tap=function(r,t){return t(r),r};var B=function(r,t,e,n){if(r===t)return 0!==r||1/r==1/t;if(null==r||null==t)return r===t;r instanceof A&&(r=r._wrapped),t instanceof A&&(t=t._wrapped);var i=l.call(r);if(i!=l.call(t))return!1;switch(i){case"[object String]":return r==String(t);case"[object Number]":return r!=+r?t!=+t:0==r?1/r==1/t:r==+t;case"[object Date]":case"[object Boolean]":return+r==+t;case"[object RegExp]":return r.source==t.source&&r.global==t.global&&r.multiline==t.multiline&&r.ignoreCase==t.ignoreCase}if("object"!=typeof r||"object"!=typeof t)return!1;for(var o=e.length;o--;)if(e[o]==r)return n[o]==t;var g=r.constructor,a=t.constructor;if(g!==a&&!(A.isFunction(g)&&g instanceof g&&A.isFunction(a)&&a instanceof a)&&"constructor"in r&&"constructor"in t)return!1;e.push(r),n.push(t);var b=0,s=!0;if("[object Array]"==i){if(b=r.length,s=b==t.length)for(;b--&&(s=B(r[b],t[b],e,n)););}else{for(var u in r)if(A.has(r,u)&&(b++,!(s=A.has(t,u)&&B(r[u],t[u],e,n))))break;if(s){for(u in t)if(A.has(t,u)&&!b--)break;s=!b}}return e.pop(),n.pop(),s};A.isEqual=function(r,t){return B(r,t,[],[])},A.isEmpty=function(r){if(null==r)return!0;if(A.isArray(r)||A.isString(r))return 0===r.length;for(var t in r)if(A.has(r,t))return!1;return!0},A.isElement=function(r){return!(!r||1!==r.nodeType)},A.isArray=_||function(r){return"[object Array]"==l.call(r)},A.isObject=function(r){return r===Object(r)},M(["Arguments","Function","String","Number","Date","RegExp"],function(r){A["is"+r]=function(t){return l.call(t)=="[object "+r+"]"}}),A.isArguments(arguments)||(A.isArguments=function(r){return!(!r||!A.has(r,"callee"))}),"function"!=typeof/./&&(A.isFunction=function(r){return"function"==typeof r}),A.isFinite=function(r){return isFinite(r)&&!isNaN(parseFloat(r))},A.isNaN=function(r){return A.isNumber(r)&&r!=+r},A.isBoolean=function(r){return r===!0||r===!1||"[object Boolean]"==l.call(r)},A.isNull=function(r){return null===r},A.isUndefined=function(r){return void 0===r},A.has=function(r,t){return u.call(r,t)},A.noConflict=function(){return r._=t,this},A.identity=function(r){return r},A.constant=function(r){return function(){return r}},A.property=function(r){return function(t){return t[r]}},A.matches=function(r){return function(t){if(t===r)return!0;for(var e in r)if(r[e]!==t[e])return!1;return!0}},A.times=function(r,t,e){for(var n=Array(Math.max(0,r)),i=0;r>i;i++)n[i]=t.call(e,i);return n},A.random=function(r,t){return null==t&&(t=r,r=0),r+Math.floor(Math.random()*(t-r+1))},A.now=Date.now||function(){return(new Date).getTime()};var F={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};F.unescape=A.invert(F.escape);var E={escape:new RegExp("["+A.keys(F.escape).join("")+"]","g"),unescape:new RegExp("("+A.keys(F.unescape).join("|")+")","g")};A.each(["escape","unescape"],function(r){A[r]=function(t){return null==t?"":(""+t).replace(E[r],function(t){return F[r][t]})}}),A.result=function(r,t){if(null==r)return void 0;var e=r[t];return A.isFunction(e)?e.call(r):e},A.mixin=function(r){M(A.functions(r),function(t){var e=A[t]=r[t];A.prototype[t]=function(){var r=[this._wrapped];return a.apply(r,arguments),Y.call(this,e.apply(A,r))}})};var R=0;A.uniqueId=function(r){var t=++R+"";return r?r+t:t},A.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var T=/(.)^/,N={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},P=/\\|'|\r|\n|\t|\u2028|\u2029/g;A.template=function(r,t,e){var n;e=A.defaults({},e,A.templateSettings);var i=new RegExp([(e.escape||T).source,(e.interpolate||T).source,(e.evaluate||T).source].join("|")+"|$","g"),o=0,g="__p+='";r.replace(i,function(t,e,n,i,a){return g+=r.slice(o,a).replace(P,function(r){return"\\"+N[r]}),e&&(g+="'+\n((__t=("+e+"))==null?'':_.escape(__t))+\n'"),n&&(g+="'+\n((__t=("+n+"))==null?'':__t)+\n'"),i&&(g+="';\n"+i+"\n__p+='"),o=a+t.length,t}),g+="';\n",e.variable||(g="with(obj||{}){\n"+g+"}\n"),g="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+g+"return __p;\n";try{n=new Function(e.variable||"obj","_",g)}catch(a){throw a.source=g,a}if(t)return n(t,A);var b=function(r){return n.call(this,r,A)};return b.source="function("+(e.variable||"obj")+"){\n"+g+"}",b},A.chain=function(r){return A(r).chain()};var Y=function(r){return this._chain?A(r).chain():r};A.mixin(A),M(["pop","push","reverse","shift","sort","splice","unshift"],function(r){var t=i[r];A.prototype[r]=function(){var e=this._wrapped;return t.apply(e,arguments),"shift"!=r&&"splice"!=r||0!==e.length||delete e[0],Y.call(this,e)}}),M(["concat","join","slice"],function(r){var t=i[r];A.prototype[r]=function(){return Y.call(this,t.apply(this._wrapped,arguments))}}),A.extend(A.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),"function"==typeof e&&e.amd&&e("underscore",[],function(){return A})}.call(this),e("core/manager",["underscore"],function(r){var t={data_frames:{},panes:[]};return t.addData=function(t,e){var n={};n[t]=e,r.extend(this.data_frames,n)},t.getData=function(r){return this.data_frames[r]},t.addPane=function(r){this.panes.push(r)},t.update=function(t){if(arguments.length>0){var e=r.filter(this.panes,function(r){return r.uuid==t});r.each(e,function(r){r.pane.update()})}else r.each(this.panes,function(r){r.pane.update()})},t}),function(){function r(r,t,e){var n=t&&e||0,i=0;for(t=t||[],r.toLowerCase().replace(/[0-9a-f]{2}/g,function(r){16>i&&(t[n+i++]=f[r])});16>i;)t[n+i++]=0;return t}function n(r,t){var e=t||0,n=d;return n[r[e++]]+n[r[e++]]+n[r[e++]]+n[r[e++]]+"-"+n[r[e++]]+n[r[e++]]+"-"+n[r[e++]]+n[r[e++]]+"-"+n[r[e++]]+n[r[e++]]+"-"+n[r[e++]]+n[r[e++]]+n[r[e++]]+n[r[e++]]+n[r[e++]]+n[r[e++]]}function i(r,t,e){var i=t&&e||0,o=t||[];r=r||{};var g=null!=r.clockseq?r.clockseq:y,a=null!=r.msecs?r.msecs:(new Date).getTime(),b=null!=r.nsecs?r.nsecs:x+1,s=a-v+(b-x)/1e4;if(0>s&&null==r.clockseq&&(g=g+1&16383),(0>s||a>v)&&null==r.nsecs&&(b=0),b>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");v=a,x=b,y=g,a+=122192928e5;var l=(1e4*(268435455&a)+b)%4294967296;o[i++]=l>>>24&255,o[i++]=l>>>16&255,o[i++]=l>>>8&255,o[i++]=255&l;var u=a/4294967296*1e4&268435455;o[i++]=u>>>8&255,o[i++]=255&u,o[i++]=u>>>24&15|16,o[i++]=u>>>16&255,o[i++]=g>>>8|128,o[i++]=255&g;for(var c=r.node||m,d=0;6>d;d++)o[i+d]=c[d];return t?t:n(o)}function o(r,t,e){var i=t&&e||0;"string"==typeof r&&(t="binary"==r?new c(16):null,r=null),r=r||{};var o=r.random||(r.rng||g)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var a=0;16>a;a++)t[i+a]=o[a];return t||n(o)}var g,a=this;if("function"==typeof t)try{var b=t("crypto").randomBytes;g=b&&function(){return b(16)}}catch(s){}if(!g&&a.crypto&&crypto.getRandomValues){var l=new Uint8Array(16);g=function(){return crypto.getRandomValues(l),l}}if(!g){var u=new Array(16);g=function(){for(var r,t=0;16>t;t++)0===(3&t)&&(r=4294967296*Math.random()),u[t]=r>>>((3&t)<<3)&255;return u}}for(var c="function"==typeof Buffer?Buffer:Array,d=[],f={},p=0;256>p;p++)d[p]=(p+256).toString(16).substr(1),f[d[p]]=p;var h=g(),m=[1|h[0],h[1],h[2],h[3],h[4],h[5]],y=16383&(h[6]<<8|h[7]),v=0,x=0,_=o;if(_.v1=i,_.v4=o,_.parse=r,_.unparse=n,_.BufferClass=c,"function"==typeof e&&e.amd)e("node-uuid",[],function(){return _});else if("undefined"!=typeof module&&module.exports)module.exports=_;else{var w=a.uuid;_.noConflict=function(){return a.uuid=w,_},a.uuid=_}}.call(this),e("view/components/legend/simple_legend",["underscore","core/manager"],function(r){function t(t,e){var n={title:"",width:150,height:22,title_height:15,mode:"normal"};return arguments.length>1&&r.extend(n,e),this.model=d3.select(document.createElementNS("http://www.w3.org/2000/svg","g")),this.options=n,this.data=t,this}return t.prototype.width=function(){return this.options.width},t.prototype.height=function(){return this.options.height*(this.data.length+1)},t.prototype.getDomObject=function(){var r=this.model,t=this.options;r.append("text").attr("x",12).attr("y",t.height).attr("font-size","14").text(t.title);var e=this.model.selectAll("g").data(this.data).enter().append("g"),n=e.append("circle").attr("cx","8").attr("cy",function(r,e){return t.height*(e+1)}).attr("r","6").attr("stroke",function(r){return r.color}).attr("stroke-width","2").attr("fill",function(r){return r.color}).attr("fill-opacity",function(r){return"off"==r.mode?0:1});switch(t.mode){case"normal":n.on("click",function(r){if(r.on||r.off){var t=d3.select(this);1==t.attr("fill-opacity")?(t.attr("fill-opacity",0),r.off()):(t.attr("fill-opacity",1),r.on())}});break;case"radio":n.on("click",function(r){var t=d3.select(this);if(0==t.attr("fill-opacity")){var e=this;n.filter(function(r){return this!=e&&!(!r.on&&!r.off)}).attr("fill-opacity",0),t.attr("fill-opacity",1),r.on()}})}return n.style("cursor",function(r){return void 0==r.on&&void 0==r.off?"default":"pointer"}),e.append("text").attr("x","18").attr("y",function(r,e){return t.height*(e+1)+4}).attr("font-size","12").text(function(r){return r.label}),r},t}),e("view/diagrams/bar",["underscore","node-uuid","core/manager","view/components/legend/simple_legend"],function(r,t,e,n){function i(t,n,i,o){var g={value:null,x:null,y:null,width:.9,color:null,hover:!0,tooltip_contents:null,tooltip:null};arguments.length>3&&r.extend(g,o);var a,b=e.getData(i);a=null==g.color?d3.scale.category20b():d3.scale.ordinal().range(g.color),this.color_scale=a;var s,l=t.append("g"),u=[];if(null!=g.value){var c=b.column(g.value);s=r.uniq(c)}else s=b.column(g.x);return r.each(s,function(r){u.push({label:r,color:a(r)})}),this.model=l,this.scales=n,this.options=g,this.legend_data=u,this.df=b,this.df_id=i,this.uuid=g.uuid,this}return i.prototype.update=function(){var r;if(null!==this.options.value){var t=this.df.columnWithFilters(this.uuid,this.options.value),e=this.countData(t);r=this.processData(e.x,e.y,this.options)}else{var n=this.df.columnWithFilters(this.uuid,this.options.x),i=this.df.columnWithFilters(this.uuid,this.options.y);r=this.processData(n,i,this.options)}var o=this.model.selectAll("rect").data(r);void 0==o[0][0]&&o.enter().append("rect").attr("height",0).attr("y",this.scales.get(0,0).y),this.updateModels(o,this.scales,this.options)},i.prototype.processData=function(t,e){return r.map(r.zip(t,e),function(r){return{x:r[0],y:r[1]}})},i.prototype.updateModels=function(r,e,n){var i=this.color_scale,o=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return d3.rgb(i(r.x)).darker(1)});var r=d3.select(this).attr("id");n.tooltip.addToYAxis(r,this.__data__.y),n.tooltip.update()},g=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return i(r.x)});d3.select(this).attr("id");n.tooltip.reset()},a=e.raw.x.rangeBand()*n.width,b=e.raw.x.rangeBand()*((1-n.width)/2);r.attr("x",function(r){return e.get(r.x,r.y).x+b}).attr("width",a).attr("fill",function(r){return i(r.x)}).transition().duration(200).attr("y",function(r){return e.get(r.x,r.y).y}).attr("height",function(r){return e.get(0,0).y-e.get(0,r.y).y}).attr("id",t.v4()),n.hover&&r.on("mouseover",o).on("mouseout",g)},i.prototype.getLegend=function(){return new n(this.legend_data)},i.prototype.countData=function(t){var e={};return r.each(t,function(r){e[r]=e[r]||0,e[r]+=1}),{x:r.keys(e),y:r.values(e)}},i.prototype.checkSelectedData=function(){},i}),e("view/components/filter",["underscore","core/manager"],function(r){function t(t,e,n,i){var o={opacity:.125,color:"gray"};arguments.length>2&&r.extend(o,i);var g=function(){var r={x:a.empty()?e.domain().x:a.extent(),y:e.domain().y};n(r)},a=d3.svg.brush().x(e.raw.x).on("brushend",g),b=t.append("g"),s=d3.max(e.range().y)-d3.min(e.range().y),l=d3.min(e.range().y);return b.call(a).selectAll("rect").attr("y",l).attr("height",s).style("fill-opacity",o.opacity).style("fill",o.color).style("shape-rendering","crispEdges"),this}return t}),e("view/diagrams/histogram",["underscore","node-uuid","core/manager","view/components/filter","view/components/legend/simple_legend"],function(r,t,e,n,i){function o(t,n,i,o){var g={title:"histogram",value:null,bin_num:20,width:.9,color:"steelblue",stroke_color:"black",stroke_width:1,hover:!0,tooltip:null};arguments.length>3&&r.extend(g,o);var a=e.getData(i),b=t.append("g");return this.scales=n,this.legends=[{label:g.title,color:g.color}],this.options=g,this.model=b,this.df=a,this.uuid=g.uuid,this}return o.prototype.update=function(){var r=this.df.columnWithFilters(this.uuid,this.options.value),t=this.processData(r,this.options),e=this.model.selectAll("rect").data(t);void 0==e[0][0]&&(e=e.enter().append("rect").attr("height",0).attr("y",this.scales.get(0,0).y)),this.updateModels(e,this.scales,this.options)},o.prototype.processData=function(r,t){return d3.layout.histogram().bins(this.scales.raw.x.ticks(t.bin_num))(r)},o.prototype.updateModels=function(r,e,n){var i=function(){d3.select(this).transition().duration(200).attr("fill",d3.rgb(n.color).darker(1));var r=d3.select(this).attr("id");n.tooltip.addToYAxis(r,this.__data__.y,3),n.tooltip.update()},o=function(){d3.select(this).transition().duration(200).attr("fill",n.color);d3.select(this).attr("id");n.tooltip.reset()};r.attr("x",function(r){return e.get(r.x,0).x}).attr("width",function(r){return e.get(r.dx,0).x-e.get(0,0).x}).attr("fill",n.color).attr("stroke",n.stroke_color).attr("stroke-width",n.stroke_width).transition().duration(200).attr("y",function(r){return e.get(0,r.y).y}).attr("height",function(r){return e.get(0,0).y-e.get(0,r.y).y}).attr("id",t.v4()),n.hover&&r.on("mouseover",i).on("mouseout",o)},o.prototype.getLegend=function(){return new i(this.legend_data)},o.prototype.checkSelectedData=function(r){var t=this.options.value,n=function(e){var n=e[t];return n>r.x[0]&&n3&&r.extend(g,o),this.scales=n;var a=e.getData(i),b=t.append("g");return this.legend_data=function(r){var t=function(){r.render=!0,r.update()},e=function(){r.render=!1,r.update()};return[{label:g.title,color:g.color,on:t,off:e}]}(this),this.render=!0,this.options=g,this.model=b,this.df=a,this.uuid=g.uuid,this}return o.prototype.update=function(){var r=this.processData(this.options);if(this.options.tooltip.reset(),this.render){var t=this.model.selectAll("path").data(r);t.enter().append("path"),this.updateModels(t,this.scales,this.options)}else this.model.selectAll("path").remove()},o.prototype.processData=function(t){var e=this.df,n=["x","y","fill","size","shape"],i=r.map(["x","y"],function(r){return e.column(t[r])}),o=i[0].length;if(r.each([{column:"fill_by",val:"color"},{column:"size_by",val:"size"},{column:"shape_by",val:"shape"}],function(n){if(t[n.column]){var g=e.scale(t[n.column],t[n.val]);i.push(r.map(e.column(t[n.column]),function(r){return g(r)}))}else i.push(r.map(r.range(1,o,1),function(){return r.isArray(t[n.val])?t[n.val][0]:t[n.val]}))}),t.tooltip_contents.length>0){var g=e.getPartialDf(t.tooltip_contents);n.push("tt"),i.push(g)}return r.map(r.zip.apply(null,i),function(t){return r.reduce(t,function(r,t,e){return r[n[e]]=t,r},{})})},o.prototype.updateModels=function(r,t,e){var n=this.uuid,i=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return d3.rgb(r.fill).darker(1)}),e.tooltip.addToXAxis(n,this.__data__.x,3),e.tooltip.addToYAxis(n,this.__data__.y,3),e.tooltip_contents.length>0&&e.tooltip.add(n,this.__data__.x,this.__data__.y,"top",this.__data__.tt),e.tooltip.update()},o=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return r.fill}),e.tooltip.reset()};r.attr("transform",function(r){return"translate("+t.get(r.x,r.y).x+","+t.get(r.x,r.y).y+")"}).attr("fill",function(r){return r.fill}).attr("stroke",e.stroke_color).attr("stroke-width",e.stroke_width).transition().duration(200).attr("d",d3.svg.symbol().type(function(r){return r.shape}).size(function(r){return r.size})),e.hover&&r.on("mouseover",i).on("mouseout",o)},o.prototype.getLegend=function(){return new i(this.legend_data)},o.prototype.checkSelectedData=function(){},o}),e("view/diagrams/line",["underscore","core/manager","view/components/filter","view/components/legend/simple_legend"],function(r,t,e,n){function i(e,n,i,o){var g={x:null,y:null,title:"line",color:"steelblue",stroke_width:2};arguments.length>3&&r.extend(g,o),this.scales=n;var a=t.getData(i),b=e.append("g");return this.legend_data=function(r){var t=function(){r.render=!0,r.update()},e=function(){r.render=!1,r.update()};return[{label:g.title,color:g.color,on:t,off:e}]}(this),this.render=!0,this.options=g,this.model=b,this.df=a,this.df_id=i,this}return i.prototype.update=function(){if(this.render){var r=this.processData(this.df.column(this.options.x),this.df.column(this.options.y),this.options);this.model.selectAll("path").remove();var t=this.model.append("path").datum(r);this.updateModels(t,this.scales,this.options)}else this.model.selectAll("path").remove()},i.prototype.processData=function(t,e){return r.map(r.zip(t,e),function(r){return{x:r[0],y:r[1]}})},i.prototype.updateModels=function(r,t,e){var n=d3.svg.line().x(function(r){return t.get(r.x,r.y).x}).y(function(r){return t.get(r.x,r.y).y});r.attr("d",n).attr("stroke",e.color).attr("stroke-width",e.stroke_width).attr("fill","none")},i.prototype.getLegend=function(){var r=new n(this.legend_data);return r},i.prototype.checkSelectedData=function(){},i}),e("utils/simplex",["underscore"],function(r){function t(t){var e=[];return r.each(r.zip.apply(null,t),function(t,n){e[n]=0,r.each(t,function(r){e[n]+=r}),e[n]=e[n]/t.length}),e}function e(n,s){n=r.sortBy(n,function(r){return s(r)});for(var l=n.length,u=n[0].length,c=n[l-1],d=n[l-2],f=n[0],p=t(n.concat().splice(0,l-1)),h=[],m=0;u>m;m++)h[m]=2*p[m]-c[m];if(s(h)>=s(c))for(var m=0;u>m;m++)n[l-1][m]=(1-i)*c[m]+i*h[m];else if(s(h)<(s(f)+(o-1)*s(c))/o){for(var y=[],m=0;u>m;m++)y[m]=o*h[m]-(o-1)*c[m];n[l-1]=s(y)<=s(h)?y:h}else n[l-1]=h;s(n[l-1])>=s(d)&&r.each(n,function(r,t){for(var e=0;u>e;e++)n[t][e]=.5*(r[e]+f[e])});var v=0;return r.each(n,function(r){v+=Math.pow(s(r)-s(f),2)}),g>v?n[l-1]:(a++,a>b?n[l-1]:e(n,s))}function n(t,n){var i=1,o=t.length,g=[t];return r.each(r.range(o),function(r){var e=t.concat();e[r]+=i,g.push(e)}),e(g,n)}var i=.7,o=1.5,g=1e-20,a=0,b=2e3;return n}),e("view/diagrams/venn",["underscore","core/manager","view/components/filter","view/components/legend/simple_legend","utils/simplex"],function(r,t,e,n,i){function o(e,i,o,g){var a={category:null,count:null,color:null,stroke_color:"#000",stroke_width:1,opacity:.7,hover:!1,area_names:["VENN1","VENN2","VENN3"],filter_control:!1};arguments.length>3&&r.extend(a,g);var b,s=t.getData(o),l=e.append("g"),u=s.column(a.category),c=r.uniq(u);b=null==a.color?d3.scale.category20().domain(a.area_names):d3.scale.ordinal().range(a.color).domain(a.area_names),this.color_scale=b;for(var d=[],f=[[c[0]],[c[1]],[c[2]]],p=this.update,h=this.tellUpdate,m=this,y=0;3>y;y++){var v=[];v.push({label:a.area_names[y],color:b(a.area_names[y])}),r.each(c,function(r){var t=y,e=function(){f[t].push(r),p.call(m),h.call(m)},n=function(){var e=f[t].indexOf(r);f[t].splice(e,1),p.call(m),h.call(m)},i=r==f[y]?"on":"off";v.push({label:r,color:"black",mode:i,on:e,off:n})}),d.push(new n(v))}var x="all";if(a.filter_control){var v=[],_=["all","overlapping","non-overlapping"],w=x; -v.push({label:"Filter",color:"gray"}),r.each(_,function(r){var t=function(){m.filter_mode=r,p.call(m),h.call(m)},e=r==w?"on":"off";v.push({label:r,color:"black",on:t,off:function(){},mode:e})}),d.push(new n(v,{mode:"radio"}))}return this.selected_category=f,this.filter_mode=x,this.legend_data=d,this.options=a,this.scales=i,this.model=l,this.df_id=o,this.df=s,this.uuid=a.uuid,this.tellUpdate(),this}return o.prototype.getScales=function(t,e){var n=r.max(e.range().x)-r.min(e.range().x),i=r.max(e.range().y)-r.min(e.range().y),o={min:function(){var e=r.min(t.pos,function(r){return r.x-r.r});return e.x-e.r}(),max:function(){var e=r.max(t.pos,function(r){return r.x+r.r});return e.x+e.r}()},g={min:function(){var e=r.min(t.pos,function(r){return r.y-r.r});return e.y-e.r}(),max:function(){var e=r.max(t.pos,function(r){return r.y+r.r});return e.y+e.r}()},a=o.max-o.min,b=g.max-g.min,s=0;if(n/i>a/b){s=b/i;var l=s*n;o.min-=(l-a)/2,o.max+=(l-a)/2}else{s=a/n;var u=s*i;b.min-=(u-b)/2,b.max+=(u-b)/2}var c={};return c.x=d3.scale.linear().range(e.range().x).domain([o.min,o.max]),c.y=d3.scale.linear().range(e.range().y).domain([g.min,g.max]),c.r=d3.scale.linear().range([0,100]).domain([0,100*s]),c},o.prototype.update=function(){var r=this.df.columnWithFilters(this.uuid,this.options.count),t=this.df.columnWithFilters(this.uuid,this.options.category),e=this.processData(t,r,this.selected_category),n=this.getScales(e,this.scales),i=this.model.selectAll("circle").data(e.pos),o=this.model.selectAll("text").data(e.labels);void 0==i[0][0]&&(i=i.enter().append("circle")),void 0==o[0][0]&&(o=o.enter().append("text")),this.counted_items=e.counted_items,this.updateModels(i,n,this.options),this.updateLabels(o,n,this.options)},o.prototype.processData=function(t,e,n){for(var o=(function(){for(var i=[],o=function(){var i={};return r.each(r.zip(t,e),function(t){void 0==i[t[1]]&&(i[t[1]]={}),r.each(n,function(r,e){-1!=r.indexOf(t[0])&&(i[t[1]][e]=!0)})}),i}(),g=(function(t){var e=0;return r.each(r.values(o),function(n){r.some(t,function(r){return!(r in n)})||e++}),e}),a=0;3>a;a++){i[a]=[],i[a][a]=g([a]);for(var b=a+1;3>b;b++){var s=g([a,b]);i[a][b]=s}}return{table:i,counted_items:o}}()),g=o.table,a=o.counted_items,b=r.map(g,function(r,t){return Math.sqrt(g[t][t]/(2*Math.PI))}),s=function(t){for(var e=0,n=0;nu+c?f=0:r.each([[u,c],[c,u]],function(r){var t=Math.acos((r[1]*r[1]-r[0]*r[0]+d*d)/(2*r[1]*d)),e=r[n]*r[n]*t-.5*r[1]*r[1]*Math.sin(2*t);f+=e}),e+=Math.pow(g[n/2][i/2]-f,2)}return e},l=function(){var t=[],e=g[0].length,n=r.max(g,function(r,t){for(var e=0,n=0;t>n;n++)e+=g[n][t];for(var n=t+1;ns;s++)if(s!=i){var l=b[i]+b[s]/2;t[2*s]=l*Math.sin(o),t[2*s+1]=l*Math.cos(o),o+=a}return t}(),u=i(l,s),c=[],d=[],f=0;ff;f++){d.push({x:u[2*f],y:u[2*f+1],val:g[f][f]});for(var p=f+1;3>p;p++){var h=(u[2*f]+u[2*p])/2,m=(u[2*f+1]+u[2*p+1])/2;d.push({x:h,y:m,val:g[f][p]})}}return{pos:c,labels:d,counted_items:a}},o.prototype.updateModels=function(r,t,e){var n=this.color_scale,i=this.options.area_names;if(r.attr("cx",function(r){return t.x(r.x)}).attr("cy",function(r){return t.y(r.y)}).attr("stroke",e.stroke_color).attr("stroke-width",e.stroke_width).attr("fill",function(r){return n(i[r.id])}).attr("fill-opacity",e.opacity).transition().duration(500).attr("r",function(r){return t.r(r.r)}),e.hover){var o=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return d3.rgb(n(i[r.id])).darker(1)})},g=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return n(i[r.id])})};r.on("mouseover",o).on("mouseout",g)}},o.prototype.updateLabels=function(r,t){r.attr("x",function(r){return t.x(r.x)}).attr("y",function(r){return t.y(r.y)}).attr("text-anchor","middle").text(function(r){return String(r.val)})},o.prototype.getLegend=function(){return this.legend_data},o.prototype.tellUpdate=function(){var e=this.selected_category,n=this.counted_items,i=this.filter_mode,o=this.options.category,g=this.options.count,a={all:function(t){return r.some(e,function(r){return-1!=r.indexOf(t[o])?!0:!1})},overlapping:function(t){if(!r.some(e,function(r){return-1!=r.indexOf(t[o])?!0:!1}))return!1;for(var i=0;3>i;i++)for(var a=i+1;3>a;a++)if(n[t[g]][i]&&n[t[g]][a])return!0;return!1},"non-overlapping":function(t){if(!r.some(e,function(r){return-1!=r.indexOf(t[o])?!0:!1}))return!1;for(var i=0;3>i;i++)for(var a=i+1;3>a;a++)if(n[t[g]][i]&&n[t[g]][a])return!1;return!0}}[i];this.df.addFilter(this.uuid,a,["self"]),t.update()},o}),e("view/diagrams/multiple_venn",["underscore","core/manager","view/components/filter","utils/simplex"],function(r,t,e,n){function i(e,n,i,o){var g={category:null,count:null,color:null,stroke_color:"#000",stroke_width:1,opacity:.7,hover:!1};arguments.length>3&&r.extend(g,o),this.getScales=function(t,e){var n=r.max(e.x.range())-r.min(e.x.range()),i=r.max(e.y.range())-r.min(e.y.range()),o={min:function(){var e=r.min(t.pos,function(r){return r.x-r.r});return e.x-e.r}(),max:function(){var e=r.max(t.pos,function(r){return r.x+r.r});return e.x+e.r}()},g={min:function(){var e=r.min(t.pos,function(r){return r.y-r.r});return e.y-e.r}(),max:function(){var e=r.max(t.pos,function(r){return r.y+r.r});return e.y+e.r}()},a=o.max-o.min,b=g.max-g.min,s=0;if(n/i>a/b){s=b/i;var l=s*n;o.min-=(l-a)/2,o.max+=(l-a)/2}else{s=a/n;var u=s*i;b.min-=(u-b)/2,b.max+=(u-b)/2}var c={};return c.x=d3.scale.linear().range(e.x.range()).domain([o.min,o.max]),c.y=d3.scale.linear().range(e.y.range()).domain([g.min,g.max]),c.r=d3.scale.linear().range([0,100]).domain([0,100*s]),c};var a=t.getData(i),b=this.processData(a.column(g.category),a.column(g.count)),s=this.getScales(b,n),l=e.append("g"),u=l.selectAll("circle").data(b.pos).enter().append("circle"),c=l.selectAll("text").data(b.labels).enter().append("text");this.color_scale=null==g.color?d3.scale.category20():d3.scale.ordinal().range(g.color);var d=this.color_scale;this.updateModels(u,s,g),this.updateLabels(c,s,g);var f=[];return r.each(b.pos,function(r){f.push({label:r.name,color:d(r.name)})}),this.legends=f,this.scales=n,this.options=g,this.model=l,this.df=a,this.df_id=i,this}return i.prototype.processData=function(t,e){for(var i=r.uniq(t),o=(function(){for(var n=[],o=function(){var n={};return r.each(r.zip(t,e),function(r){void 0==n[r[1]]&&(n[r[1]]={}),n[r[1]][r[0]]=!0}),r.values(n)}(),g=(function(t){var e=0;return r.each(o,function(n){r.some(t,function(r){return!(r in n)})||e++}),e}),a=0;au+c?f=0:r.each([[u,c],[c,u]],function(r){var t=Math.acos((r[1]*r[1]-r[0]*r[0]+d*d)/(2*r[1]*d)),e=r[n]*r[n]*t-.5*r[1]*r[1]*Math.sin(2*t);f+=e}),e+=Math.pow(o[n/2][i/2]-f,2)}return e},b=function(){var t=[],e=o[0].length,n=r.max(o,function(r,t){for(var e=0,n=0;t>n;n++)e+=o[n][t];for(var n=t+1;ns;s++)if(s!=i){var l=g[i]+g[s]/2;t[2*s]=l*Math.sin(a),t[2*s+1]=l*Math.cos(a),a+=b}return t}(),s=n(b,a),l=[],u=[],c=0;c3&&r.extend(g,o);var a,b=t.append("g"),s=e.getData(i);return a=null==g.color?d3.scale.category20b():d3.scale.ordinal().range(g.color),this.model=b,this.scales=n,this.options=g,this.df=s,this.color_scale=a,this.uuid=g.uuid,this}return i.prototype.update=function(){var t=this.uuid,e=this.processData,n=this.df,i=[];r.each(this.options.value,function(o){var g=n.columnWithFilters(t,o);i.push(r.extend(e(g),{x:o}))});var o=this.model.selectAll("g").data(i);o.enter().append("g"),this.updateModels(o,this.scales,this.options)},i.prototype.processData=function(t){var e=function(r){var t=r.length;return t%2==1?r[Math.floor(t/2)]:(r[t/2]+r[t/2+1])/2},n=r.sortBy(t),i=e(n),o=e(n.slice(0,n.length/2-1)),g=e(n.slice(n.length%2==0?n.length/2:n.length/2+1,n.length-1)),a=g-o,b=r.max(n)-g>1.5*a?g+1.5*a:r.max(n),s=o-r.min(n)>1.5*a?o-1.5*a:r.min(n),l=r.filter(n,function(r){return r>b||s>r});return{med:i,q1:o,q3:g,max:b,min:s,outlier:l}},i.prototype.updateModels=function(r,e,n){var i=e.raw.x.rangeBand()*n.width,o=e.raw.x.rangeBand()*((1-n.width)/2),g=this.color_scale,a=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return d3.rgb(g(r.x)).darker(1)});var r=d3.select(this).attr("id");n.tooltip.addToYAxis(r,this.__data__.min,3),n.tooltip.addToYAxis(r,this.__data__.q1,3),n.tooltip.addToYAxis(r,this.__data__.med,3),n.tooltip.addToYAxis(r,this.__data__.q3,3),n.tooltip.addToYAxis(r,this.__data__.max,3),n.tooltip.update()},b=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return d3.rgb(g(r.x))});d3.select(this).attr("id");n.tooltip.reset()};r.append("line").attr("x1",function(r){return e.get(r.x,0).x+i/2+o}).attr("y1",function(r){return e.get(r.x,r.max).y}).attr("x2",function(r){return e.get(r.x,0).x+i/2+o}).attr("y2",function(r){return e.get(r.x,r.min).y}).attr("stroke",n.stroke_color),r.append("rect").attr("x",function(r){return e.get(r.x,0).x+o}).attr("y",function(r){return e.get(r.x,r.q3).y}).attr("height",function(r){return e.get(r.x,r.q1).y-e.get(r.x,r.q3).y}).attr("width",i).attr("fill",function(r){return g(r.x)}).attr("stroke",n.stroke_color).attr("id",t.v4()).on("mouseover",a).on("mouseout",b),r.append("line").attr("x1",function(r){return e.get(r.x,0).x+o}).attr("y1",function(r){return e.get(r.x,r.med).y}).attr("x2",function(r){return e.get(r.x,0).x+i+o}).attr("y2",function(r){return e.get(r.x,r.med).y}).attr("stroke",n.stroke_color),r.append("g").each(function(r){d3.select(this).selectAll("circle").data(r.outlier).enter().append("circle").attr("cx",function(){return e.get(r.x,0).x+i/2+o}).attr("cy",function(t){return e.get(r.x,t).y}).attr("r",n.outlier_r)})},i.prototype.getLegend=function(){return new n(this.legend_data)},i.prototype.checkSelectedData=function(){},i}),e("view/components/legend/color_bar",["underscore"],function(r){function t(t,e){var n={width:150,height:200};arguments.length>1&&r.extend(n,e),this.options=n,this.model=d3.select(document.createElementNS("http://www.w3.org/2000/svg","g")),this.color_scale=t}return t.prototype.width=function(){return this.options.width},t.prototype.height=function(){return this.options.height},t.prototype.getDomObject=function(){for(var r=this.model,t=this.color_scale,e=t.range(),n=t.domain(),i=d3.scale.linear().domain(d3.extent(n)).range([this.options.height,0]),o=r.append("svg:defs").append("svg:linearGradient").attr("id","gradient").attr("x1","0%").attr("x2","0%").attr("y1","100%").attr("y2","0%"),g=0;g1)return t[e][n];var i=r.map(r.keys(t[e]),function(t){return r.isFinite(t)?Number(t):0}),o=r.max(i);return t[e][String(o)]}return e}),e("view/diagrams/heatmap.js",["underscore","node-uuid","core/manager","view/components/filter","view/components/legend/color_bar","utils/color"],function(r,t,e,n,i,o){function g(t,n,i,g){var a={title:"heatmap",x:null,y:null,fill:null,width:1,height:1,color:o("RdBu").reverse(),stroke_color:"#fff",stroke_width:1,hover:!0};arguments.length>3&&r.extend(a,g);var b=e.getData(i),s=t.append("g");return this.color_scale=function(){var r=b.columnWithFilters(a.uuid,a.fill),t=d3.extent(r),e=d3.range(t[0],t[1],(t[1]-t[0])/a.color.length);return d3.scale.linear().range(a.color).domain(e)}(),this.scales=n,this.options=a,this.model=s,this.df=b,this.uuid=a.uuid,this}return g.prototype.update=function(){var r=this.processData(),t=this.model.selectAll("rect").data(r);t.each(function(){var r=document.createEvent("MouseEvents");r.initEvent("mouseout",!1,!0),this.dispatchEvent(r)}),t.enter().append("rect"),this.updateModels(t,this.options)},g.prototype.processData=function(){var t=this.df.columnWithFilters(this.uuid,this.options.x),e=this.df.columnWithFilters(this.uuid,this.options.y),n=this.df.columnWithFilters(this.uuid,this.options.fill),i=this.scales,o=this.options,g=this.color_scale;return r.map(r.zip(t,e,n),function(r){var t,e,n,a;return n=Math.abs(i.get(o.width,0).x-i.get(0,0).x),a=Math.abs(i.get(0,o.height).y-i.get(0,0).y),t=i.get(r[0],0).x-n/2,e=i.get(0,r[1]).y-a/2,{x:t,y:e,width:n,height:a,fill:g(r[2]),x_raw:r[0],y_raw:r[1]}})},g.prototype.updateModels=function(r,t){var e=this.uuid,n=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return d3.rgb(r.fill).darker(1)}),t.tooltip.addToXAxis(e,this.__data__.x_raw,3),t.tooltip.addToYAxis(e,this.__data__.y_raw,3),t.tooltip.update()},i=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return r.fill}),t.tooltip.reset()};r.attr("x",function(r){return r.x}).attr("width",function(r){return r.width}).attr("y",function(r){return r.y}).attr("height",function(r){return r.height}).attr("fill",function(r){return r.fill}).attr("stroke",t.stroke_color).attr("stroke-width",t.stroke_width),t.hover&&r.on("mouseover",n).on("mouseout",i)},g.prototype.getLegend=function(){return new i(this.color_scale)},g.prototype.checkSelectedData=function(){},g}),e("view/diagrams/vectors.js",["underscore","node-uuid","core/manager","view/components/filter","view/components/legend/simple_legend"],function(r,t,e,n,i){function o(t,n,i,o){var g={title:"vectors",x:null,y:null,dx:null,dy:null,fill_by:null,color:["steelblue","#000000"],stroke_color:"#000",stroke_width:2,hover:!1,tooltip:null};arguments.length>3&&r.extend(g,o),this.scales=n;var a=e.getData(i),b=t.append("g");return this.legend_data=function(r){var t=function(){r.render=!0,r.update()},e=function(){r.render=!1,r.update()};return[{label:g.title,color:g.color,on:t,off:e}]}(this),this.render=!0,this.options=g,this.model=b,this.df=a,this.uuid=g.uuid,this}return o.prototype.update=function(){var r=this.processData(this.options);if(this.options.tooltip.reset(),this.render){var t=this.model.selectAll("line").data(r);t.enter().append("line"),this.updateModels(t,this.scales,this.options)}else this.model.selectAll("line").remove()},o.prototype.processData=function(t){var e=this.df,n=["x","y","dx","dy","fill"],i=r.map(["x","y","dx","dy"],function(r){return e.column(t[r])}),o=i[0].length;return r.each([{column:"fill_by",val:"color"}],function(n){if(t[n.column]){var g=e.scale(t[n.column],t[n.val]);i.push(r.map(e.column(t[n.column]),function(r){return g(r)}))}else i.push(r.map(r.range(1,o,1),function(){return r.isArray(t[n.val])?t[n.val][0]:t[n.val]}))}),r.map(r.zip.apply(null,i),function(t){return r.reduce(t,function(r,t,e){return r[n[e]]=t,r},{})})},o.prototype.updateModels=function(r,t,e){r.attr({x1:function(r){return t.get(r.x,r.y).x},x2:function(r){return t.get(r.x+r.dx,r.y+r.dy).x},y1:function(r){return t.get(r.x,r.y).y},y2:function(r){return t.get(r.x+r.dx,r.y+r.dy).y},stroke:function(r){return r.fill},"stroke-width":e.stroke_width})},o.prototype.getLegend=function(){return new i(this.legend_data)},o.prototype.checkSelectedData=function(){},o}),e("view/diagrams/diagrams",["require","exports","module","view/diagrams/bar","view/diagrams/histogram","view/diagrams/scatter","view/diagrams/line","view/diagrams/venn","view/diagrams/multiple_venn","view/diagrams/box.js","view/diagrams/heatmap.js","view/diagrams/vectors.js"],function(r){var t={};return t.bar=r("view/diagrams/bar"),t.histogram=r("view/diagrams/histogram"),t.scatter=r("view/diagrams/scatter"),t.line=r("view/diagrams/line"),t.venn=r("view/diagrams/venn"),t.multiple_venn=r("view/diagrams/multiple_venn"),t.box=r("view/diagrams/box.js"),t.heatmap=r("view/diagrams/heatmap.js"),t.vectors=r("view/diagrams/vectors.js"),t.add=function(r,e){t[r]=e},t}),e("view/components/legend_area",["underscore","core/manager"],function(r){function t(t,e){var n={width:200,height:300,margin:{top:10,bottom:10,left:10,right:10},fill_color:"none",stroke_color:"#000",stroke_width:0};arguments.length>1&&r.extend(n,e);var i=t.append("g");return i.append("rect").attr("width",n.width).attr("height",n.height).attr("x",0).attr("y",0).attr("fill",n.fill_color).attr("stroke",n.stroke_color).attr("stroke-width",n.stroke_width),this.model=i,this.options=n,this.seek={x:n.margin.left,y:n.margin.top,width:0},this}return t.prototype.add=function(t){var e=this.model.append("g").attr("transform","translate("+this.seek.x+","+this.seek.y+")"),n=t.getDomObject();e[0][0].appendChild(n[0][0]),this.seek.y+t.height()>this.options.height?(this.seek.x+=this.seek.width,this.seek.y=this.options.margin.top):(this.seek.width=r.max([this.seek.width,t.width()]),this.seek.y+=t.height())},t}),e("utils/ua_info",["underscore"],function(){return function(){var r=window.navigator.userAgent.toLowerCase();return-1!=r.indexOf("chrome")?"chrome":-1!=r.indexOf("firefox")?"firefox":"unknown"}}),e("view/components/tooltip",["underscore","utils/ua_info"],function(r,t){function e(t,e,n){var i={bg_color:"#333",stroke_color:"#000",stroke_width:1,text_color:"#fff",context_width:0,context_height:0,context_margin:{top:0,left:0,bottom:0,right:0},arrow_width:10,arrow_height:10,tooltip_margin:{top:2,left:5,bottom:2,right:5},font:"Helvetica, Arial, sans-serif",font_size:"1em"};arguments.length>1&&r.extend(i,n);var o=t.append("g");return this.scales=e,this.options=i,this.lists=[],this.model=o,this}return e.prototype.add=function(t,e,n,i,o){var g=r.map(o,function(r,t){return String(t)+":"+String(r)});this.lists.push({id:t,x:e,y:n,pos:i,contents:g})},e.prototype.addToXAxis=function(r,t,e){if(arguments.length>2){var n=Math.pow(10,e);t=Math.round(t*n)/n}this.lists.push({id:r,x:t,y:"bottom",pos:"bottom",contents:String(t)})},e.prototype.addToYAxis=function(r,t,e){if(arguments.length>2){var n=Math.pow(10,e);t=Math.round(t*n)/n}this.lists.push({id:r,x:"left",y:t,pos:"right",contents:String(t)})},e.prototype.reset=function(){this.lists=[],this.update()},e.prototype.update=function(){var r=this.processData(this.lists),t=this.model.selectAll("g").data(r);this.updateModels(t)},e.prototype.updateModels=function(e){e.exit().remove();this.options;!function(e,n){var i=d3.svg.line().x(function(r){return r.x}).y(function(r){return r.y}).interpolate("linear");e.append("path").attr("d",function(r){return i(r.shape)}).attr("stroke",n.stroke_color).attr("fill",n.bg_color),e.each(function(){var e;if(r.isArray(this.__data__.text)){var i=this.__data__.text,o=this.__data__.text_x,g=this.__data__.text_y,a=r.map(r.zip(i,g),function(r){return{text:r[0],y:r[1]}});e=d3.select(this).append("g").selectAll("text").data(a).enter().append("text").text(function(r){return r.text}).attr("x",function(){return o}).attr("y",function(r){return r.y})}else e=d3.select(this).append("text").text(function(r){return r.text}).attr("x",function(r){return r.text_x}).attr("y",function(r){return r.text_y});switch(e.attr("text-anchor","middle").attr("fill","#ffffff").attr("font-size",n.font_size).style("font-family",n.font),t()){case"chrome":e.attr("dominant-baseline","middle").attr("baseline-shift","50%");break;default:e.attr("dominant-baseline","text-after-edge")}}),e.attr("transform",function(r){return"translate("+r.tip_x+","+r.tip_y+")"})}(e.enter().append("g"),this.options)},e.prototype.processData=function(t){var e=this.options,n=function(t,n,i){var o=e.arrow_width,g=e.arrow_height,a=n,b=i,s={top:[{x:0,y:0},{x:o/2,y:-g},{x:a/2,y:-g},{x:a/2,y:-g-b},{x:-a/2,y:-g-b},{x:-a/2,y:-g},{x:-o/2,y:-g},{x:0,y:0}],right:[{x:0,y:0},{x:-o,y:-g/2},{x:-o,y:-b/2},{x:-o-a,y:-b/2},{x:-o-a,y:b/2},{x:-o,y:b/2},{x:-o,y:g/2},{x:0,y:0}]};s.bottom=r.map(s.top,function(r){return{x:r.x,y:-r.y}}),s.left=r.map(s.right,function(r){return{x:-r.x,y:r.y}});var l=function(r){var e={};switch(t){case"top":case"bottom":e={x:0,y:(r[2].y+r[3].y)/2};break;case"right":case"left":e={x:(r[2].x+r[3].x)/2,y:0}}return e}(s[t]);return{shape:s[t],text:l}},i=this.options.tooltip_margin,o=this.options.context_height,g=this.scales,a=this.model,b=function(r,t){var n=a.append("text").text(r).attr("font-size",t).style("font-family",e.font),i=n[0][0].getBBox().width,o=n[0][0].getBBox().height;return n.remove(),{w:i,h:o}};return r.map(t,function(t){var a,s=r.isArray(t.contents)?t.contents.length:1,l=r.isArray(t.contents)?r.max(t.contents,function(r){return r.length}):t.contents,u=b(l,e.font_size),c=u.w+i.left+i.right,d=(u.h+i.top+i.bottom)*s,f=g.get(t.x,t.y),p="left"==t.x?0:f.x,h="bottom"==t.y?o:f.y,m=n(t.pos,c,d);if(r.isArray(t.contents)){var y=t.contents.length;a=r.map(t.contents,function(r,t){return m.text.y-u.h/2*(y-2)+u.h*t})}else a=m.text.y+u.h/2;return{shape:m.shape,tip_x:p,tip_y:h,text_x:m.text.x,text_y:a,text:t.contents}})},e}),e("view/pane",["underscore","node-uuid","view/diagrams/diagrams","view/components/filter","view/components/legend_area","view/components/tooltip"],function(r,t,e,n,i,o){function g(e,n,g,a){var b={width:700,height:500,margin:{top:30,bottom:80,left:80,right:30},xrange:[0,0],yrange:[0,0],x_label:"X",y_label:"Y",rotate_x_label:0,rotate_y_label:0,zoom:!1,grid:!0,zoom_range:[.5,5],bg_color:"#eee",grid_color:"#fff",legend:!1,legend_position:"right",legend_width:150,legend_height:300,legend_stroke_color:"#000",legend_stroke_width:0,font:"Helvetica, Arial, sans-serif",scale:"linear",scale_extra_options:{},axis_extra_options:{}};arguments.length>1&&r.extend(b,a),this.uuid=t.v4();var s=e.append("svg").attr("width",b.width).attr("height",b.height),l=function(){var t={};if(t.plot_x=b.margin.left,t.plot_y=b.margin.top,t.plot_width=b.width-b.margin.left-b.margin.right,t.plot_height=b.height-b.margin.top-b.margin.bottom,b.legend)switch(b.legend_position){case"top":t.plot_width-=b.legend_width,t.plot_y+=b.legend_height,t.legend_x=(b.width-b.legend_width)/2,t.legend_y=b.margin.top;break;case"bottom":t.plot_height-=b.legend_height,t.legend_x=(b.width-b.legend_width)/2,t.legend_y=b.margin.top+b.height;break;case"left":t.plot_x+=b.legend_width,t.plot_width-=b.legend_width,t.legend_x=b.margin.left,t.legend_y=b.margin.top;break;case"right":t.plot_width-=b.legend_width,t.legend_x=t.plot_width+b.margin.left,t.legend_y=b.margin.top;break;case r.isArray(b.legend_position):t.legend_x=b.width*b.legend_position[0],t.legend_y=b.height*b.legend_position[1]}return t}(),u=function(){var r={x:b.xrange,y:b.yrange},t={x:[0,l.plot_width],y:[l.plot_height,0]};return new n(r,t,{linear:b.scale,extra:b.scale_extra_options})}();s.append("g").attr("transform","translate("+l.plot_x+","+l.plot_y+")").append("rect").attr("x",0).attr("y",0).attr("width",l.plot_width).attr("height",l.plot_height).attr("fill",b.bg_color).style("z-index",1);new g(s.select("g"),u,{width:l.plot_width,height:l.plot_height,margin:b.margin,grid:b.grid,zoom:b.zoom,zoom_range:b.zoom_range,x_label:b.x_label,y_label:b.y_label,rotate_x_label:b.rotate_x_label,rotate_y_label:b.rotate_y_label,stroke_color:b.grid_color,pane_uuid:this.uuid,z_index:100,extra:b.axis_extra_options});s.select("g").append("g").attr("class","context").append("clipPath").attr("id",this.uuid+"clip_context").append("rect").attr("x",0).attr("y",0).attr("width",l.plot_width).attr("height",l.plot_height),s.select(".context").attr("clip-path","url(#"+this.uuid+"clip_context)"),s.select("g").append("rect").attr("x",-1).attr("y",-1).attr("width",l.plot_width+2).attr("height",l.plot_height+2).attr("fill","none").attr("stroke","#666").attr("stroke-width",1).style("z-index",200);var c=new o(s.select("g"),u,{font:b.font,context_width:l.plot_width,context_height:l.plot_height,context_margin:{top:l.plot_x,left:l.plot_y,bottom:b.margin.bottom,right:b.margin.right}});return b.legend&&(s.append("g").attr("class","legend_area").attr("transform","translate("+l.legend_x+","+l.legend_y+")"),this.legend_area=new i(s.select(".legend_area"),{width:b.legend_width,height:b.legend_height,stroke_color:b.legend_stroke_color,stroke_width:b.legend_stroke_width})),this.diagrams=[],this.tooltip=c,this.context=s.select(".context").append("g").attr("class","context_child"),this.model=s,this.scales=u,this.options=b,this.filter=null,this}return g.prototype.addDiagram=function(n,i,o){r.extend(o,{uuid:t.v4(),tooltip:this.tooltip});var g=new e[n](this.context,this.scales,i,o);if(this.options.legend){var a=this.legend_area,b=g.getLegend();r.isArray(b)?r.each(b,function(r){a.add(r)}):this.legend_area.add(b)}this.diagrams.push(g)},g.prototype.addFilter=function(t,e){var i=this.diagrams,o=function(t){r.each(i,function(r){r.checkSelectedData(t)})};this.filter=new n(this.context,this.scales,o,e)},g.prototype.update=function(){var t=this.options.font;r.each(this.diagrams,function(r){r.update()}),this.model.selectAll("text").style("font-family",t)},g}),e("view/components/axis",["underscore","core/manager"],function(r,t){function e(e,n,i){var o={width:0,height:0,margin:{top:0,bottom:0,left:0,right:0},stroke_color:"#fff",stroke_width:1,x_label:"X",y_label:"Y",grid:!0,zoom:!1,zoom_range:[.5,5],rotate_x_label:0,rotate_y_label:0,pane_uuid:null,z_index:0};arguments.length>2&&r.extend(o,i);var g=d3.svg.axis().scale(n.raw.x).orient("bottom"),a=d3.svg.axis().scale(n.raw.y).orient("left");e.append("g").attr("class","x_axis"),e.append("g").attr("class","y_axis"),e.append("text").attr("x",o.width/2).attr("y",o.height+o.margin.bottom/1.5).attr("text-anchor","middle").attr("fill","rgb(50,50,50)").attr("font-size",22).text(o.x_label),e.append("text").attr("x",-o.margin.left/1.5).attr("y",o.height/2).attr("text-anchor","middle").attr("fill","rgb(50,50,50)").attr("font-size",22).attr("transform","rotate(-90,"+-o.margin.left/1.5+","+o.height/2+")").text(o.y_label);var b=function(){e.select(".x_axis").call(g),e.select(".y_axis").call(a),e.selectAll(".x_axis, .y_axis").selectAll("path, line").style("z-index",o.z_index).style("fill","none").style("stroke",o.stroke_color).style("stroke-width",o.stroke_width),e.selectAll(".x_axis, .y_axis").selectAll("text").attr("fill","rgb(50,50,50)"),e.selectAll(".x_axis").attr("transform","translate(0,"+(o.height+4)+")"),e.selectAll(".y_axis").attr("transform","translate(-4,0)"),0!=o.rotate_x_label&&e.selectAll(".x_axis").selectAll("text").style("text-anchor","end").attr("transform",function(){return"rotate("+o.rotate_x_label+")"}),0!=o.rotate_y_label&&e.selectAll(".y_axis").selectAll("text").style("text-anchor","end").attr("transform",function(){return"rotate("+o.rotate_y_label+")"}),t.update(o.pane_uuid)};if(o.grid&&(g.tickSize(-1*o.height),a.tickSize(-1*o.width)),o.zoom){var s=d3.behavior.zoom().x(n.raw.x).y(n.raw.y).scaleExtent(o.zoom_range).on("zoom",b);e.call(s),e.on("dblclick.zoom",null)}return b(),this.model=e,this}return e}),e("view/components/scale",["underscore"],function(r){function t(t,e,n){var i={linear:"linear"};arguments.length>1&&r.extend(i,n);var o={};return r.each(["x","y"],function(n){if(r.some(t[n],function(t){return r.isString(t)}))o[n]=d3.scale.ordinal().domain(t[n]).rangeBands(e[n]);else{var g=d3.scale[i.linear]();o[n]=g.domain(t[n]).range(e[n])}}),this.scales=o,this.raw=o,this}return t.prototype.get=function(r,t){return{x:this.scales.x(r),y:this.scales.y(t)}},t.prototype.domain=function(){return{x:this.scales.x.domain(),y:this.scales.y.domain()}},t.prototype.range=function(){return{x:this.scales.x.range(),y:this.scales.y.range()}},t}),e("core/stl",["require","exports","module","view/pane","view/components/axis","view/components/scale"],function(r){var t={};return t.pane=r("view/pane"),t.axis=r("view/components/axis"),t.scale=r("view/components/scale"),t}),e("core/extension",["underscore","core/stl","view/diagrams/diagrams"],function(r,t,e){var n={},i={};return n.load=function(n){if("undefined"!=typeof window[n]&&"undefined"!=typeof window[n].Nya){var o=window[n].Nya;r.each(["pane","scale","axis"],function(r){"undefined"==typeof o[r]&&(o[r]=t[r])}),"undefined"!=typeof o.diagrams&&r.each(o.diagrams,function(r,t){e.add(t,r)}),i[n]=o}},n.get=function(r){return i[r]},n}),e("utils/dataframe",["underscore"],function(r){function t(t,e){if(e instanceof String&&/url(.+)/g.test(e)){var n=e.match(/url\((.+)\)/)[1],i=this;d3.json(n,function(r,t){i.raw=JSON.parse(t)}),this.raw={}}else this.raw=e;var o=r.keys(e[0]),g=r.zip.apply(this,r.map(e,function(t){return r.toArray(t)})),a=r.filter(g,function(t){return r.all(t,function(t){return r.isArray(t)})});return this.nested=1==a.length?o[g.indexOf(a[0])]:!1,this.filters={},this}return t.prototype.row=function(r){return this.raw[r]},t.prototype.column=function(t){var e=[],n=this.raw;return r.each(n,function(r){e.push(r[t])}),e},t.prototype.scale=function(t,e){if(this.isContinuous(t)){var n=this.columnRange(t);return n=r.range(n.min,n.max+1,(n.max-n.min)/(e.length-1)),d3.scale.linear().domain(n).range(e)}return d3.scale.ordinal().domain(r.uniq(this.column(t))).range(e)},t.prototype.isContinuous=function(t){return r.every(this.column(t),function(t){return r.isNumber(t)})},t.prototype.addFilter=function(r,t,e){this.filters[r]={func:t,excepts:e}},t.prototype.columnWithFilters=function(t,e){var n=this.raw.concat();return r.each(this.filters,function(e,i){(-1==e.excepts.indexOf("self")||i!=t)&&(t in e.excepts||(n=r.filter(n,e.func)))}),r.map(n,function(r){return r[e]})},t.prototype.pickUpCells=function(t,e){var n=this.column(t);return r.map(e,function(r){return n[r]})},t.prototype.getPartialDf=function(t){return r.map(this.raw,function(e){return r.reduce(t,function(r,t){return r[t]=e[t],r},{})})},t.prototype.nested_column=function(r,e){if(!this.nested)throw"Recieved dataframe is not nested.";var n=new t("",this.row(r)[this.nested]);return n.column(e)},t.prototype.columnRange=function(r){var t=this.column(r);return{max:d3.max(t,function(r){return r}),min:d3.min(t,function(r){return r})}},t}),e("core/parse",["underscore","core/manager","core/extension","core/stl","utils/dataframe"],function(r,t,e,n,i){function o(t,n){var i=d3.select(n);"undefined"!=typeof t.extension&&(r.isArray(t.extension)?r.each(t.extension,function(r){e.load(r)}):e.load(t.extension)),g(t,i)}function g(o,g){r.each(o.data,function(r,e){t.addData(e,new i(e,r))}),r.each(o.panes,function(i){var o,a,b,s;if("undefined"!=typeof i.extension){var l=e.get(i.extension);a=l.pane,b=l.axis,s=l.scale}else a=n.pane,b=n.axis,s=n.scale;o=new a(g,s,b,i.options);var u=[];if(r.each(i.diagrams,function(r){o.addDiagram(r.type,r.data,r.options||{}),u.push(r.data)}),void 0!==i.filter){var c=i.filter;o.addFilter(c.type,c.options||{})}t.addPane({pane:o,data:u,uuid:o.uuid}),t.update(o.uuid)})}return o}),e("main",["require","exports","module","core/parse","core/stl","core/manager","node-uuid","underscore"],function(r){var t={};return t.core={},t.core.parse=r("core/parse"),t.STL=r("core/stl"),t.Manager=r("core/manager"),t.uuid=r("node-uuid"),t._=r("underscore"),t}),t("main")}); \ No newline at end of file +!function(r,t){r.Nyaplot=t()}(this,function(){var r,t,e;return function(n){function i(r,t){return x.call(r,t)}function o(r,t){var e,n,i,o,g,a,b,s,l,u,c,d=t&&t.split("/"),f=y.map,p=f&&f["*"]||{};if(r&&"."===r.charAt(0))if(t){for(d=d.slice(0,d.length-1),r=r.split("/"),g=r.length-1,y.nodeIdCompat&&w.test(r[g])&&(r[g]=r[g].replace(w,"")),r=d.concat(r),l=0;l0&&(r.splice(l-1,2),l-=2)}r=r.join("/")}else 0===r.indexOf("./")&&(r=r.substring(2));if((d||p)&&f){for(e=r.split("/"),l=e.length;l>0;l-=1){if(n=e.slice(0,l).join("/"),d)for(u=d.length;u>0;u-=1)if(i=f[d.slice(0,u).join("/")],i&&(i=i[n])){o=i,a=l;break}if(o)break;!b&&p&&p[n]&&(b=p[n],s=l)}!o&&b&&(o=b,a=s),o&&(e.splice(0,a,o),r=e.join("/"))}return r}function g(r,t){return function(){return d.apply(n,_.call(arguments,0).concat([r,t]))}}function a(r){return function(t){return o(t,r)}}function b(r){return function(t){h[r]=t}}function s(r){if(i(m,r)){var t=m[r];delete m[r],v[r]=!0,c.apply(n,t)}if(!i(h,r)&&!i(v,r))throw new Error("No "+r);return h[r]}function l(r){var t,e=r?r.indexOf("!"):-1;return e>-1&&(t=r.substring(0,e),r=r.substring(e+1,r.length)),[t,r]}function u(r){return function(){return y&&y.config&&y.config[r]||{}}}var c,d,f,p,h={},m={},y={},v={},x=Object.prototype.hasOwnProperty,_=[].slice,w=/\.js$/;f=function(r,t){var e,n=l(r),i=n[0];return r=n[1],i&&(i=o(i,t),e=s(i)),i?r=e&&e.normalize?e.normalize(r,a(t)):o(r,t):(r=o(r,t),n=l(r),i=n[0],r=n[1],i&&(e=s(i))),{f:i?i+"!"+r:r,n:r,pr:i,p:e}},p={require:function(r){return g(r)},exports:function(r){var t=h[r];return"undefined"!=typeof t?t:h[r]={}},module:function(r){return{id:r,uri:"",exports:h[r],config:u(r)}}},c=function(r,t,e,o){var a,l,u,c,d,y,x=[],_=typeof e;if(o=o||r,"undefined"===_||"function"===_){for(t=!t.length&&e.length?["require","exports","module"]:t,d=0;di;i++)if(t.call(e,r[i],i,r)===n)return}else for(var g=A.keys(r),i=0,o=g.length;o>i;i++)if(t.call(e,r[g[i]],g[i],r)===n)return;return r};A.map=A.collect=function(r,t,e){var n=[];return null==r?n:d&&r.map===d?r.map(t,e):(M(r,function(r,i,o){n.push(t.call(e,r,i,o))}),n)};var q="Reduce of empty array with no initial value";A.reduce=A.foldl=A.inject=function(r,t,e,n){var i=arguments.length>2;if(null==r&&(r=[]),f&&r.reduce===f)return n&&(t=A.bind(t,n)),i?r.reduce(t,e):r.reduce(t);if(M(r,function(r,o,g){i?e=t.call(n,e,r,o,g):(e=r,i=!0)}),!i)throw new TypeError(q);return e},A.reduceRight=A.foldr=function(r,t,e,n){var i=arguments.length>2;if(null==r&&(r=[]),p&&r.reduceRight===p)return n&&(t=A.bind(t,n)),i?r.reduceRight(t,e):r.reduceRight(t);var o=r.length;if(o!==+o){var g=A.keys(r);o=g.length}if(M(r,function(a,b,s){b=g?g[--o]:--o,i?e=t.call(n,e,r[b],b,s):(e=r[b],i=!0)}),!i)throw new TypeError(q);return e},A.find=A.detect=function(r,t,e){var n;return D(r,function(r,i,o){return t.call(e,r,i,o)?(n=r,!0):void 0}),n},A.filter=A.select=function(r,t,e){var n=[];return null==r?n:h&&r.filter===h?r.filter(t,e):(M(r,function(r,i,o){t.call(e,r,i,o)&&n.push(r)}),n)},A.reject=function(r,t,e){return A.filter(r,function(r,n,i){return!t.call(e,r,n,i)},e)},A.every=A.all=function(r,t,e){t||(t=A.identity);var i=!0;return null==r?i:m&&r.every===m?r.every(t,e):(M(r,function(r,o,g){return(i=i&&t.call(e,r,o,g))?void 0:n}),!!i)};var D=A.some=A.any=function(r,t,e){t||(t=A.identity);var i=!1;return null==r?i:y&&r.some===y?r.some(t,e):(M(r,function(r,o,g){return i||(i=t.call(e,r,o,g))?n:void 0}),!!i)};A.contains=A.include=function(r,t){return null==r?!1:v&&r.indexOf===v?-1!=r.indexOf(t):D(r,function(r){return r===t})},A.invoke=function(r,t){var e=b.call(arguments,2),n=A.isFunction(t);return A.map(r,function(r){return(n?t:r[t]).apply(r,e)})},A.pluck=function(r,t){return A.map(r,A.property(t))},A.where=function(r,t){return A.filter(r,A.matches(t))},A.findWhere=function(r,t){return A.find(r,A.matches(t))},A.max=function(r,t,e){if(!t&&A.isArray(r)&&r[0]===+r[0]&&r.length<65535)return Math.max.apply(Math,r);var n=-1/0,i=-1/0;return M(r,function(r,o,g){var a=t?t.call(e,r,o,g):r;a>i&&(n=r,i=a)}),n},A.min=function(r,t,e){if(!t&&A.isArray(r)&&r[0]===+r[0]&&r.length<65535)return Math.min.apply(Math,r);var n=1/0,i=1/0;return M(r,function(r,o,g){var a=t?t.call(e,r,o,g):r;i>a&&(n=r,i=a)}),n},A.shuffle=function(r){var t,e=0,n=[];return M(r,function(r){t=A.random(e++),n[e-1]=n[t],n[t]=r}),n},A.sample=function(r,t,e){return null==t||e?(r.length!==+r.length&&(r=A.values(r)),r[A.random(r.length-1)]):A.shuffle(r).slice(0,Math.max(0,t))};var z=function(r){return null==r?A.identity:A.isFunction(r)?r:A.property(r)};A.sortBy=function(r,t,e){return t=z(t),A.pluck(A.map(r,function(r,n,i){return{value:r,index:n,criteria:t.call(e,r,n,i)}}).sort(function(r,t){var e=r.criteria,n=t.criteria;if(e!==n){if(e>n||void 0===e)return 1;if(n>e||void 0===n)return-1}return r.index-t.index}),"value")};var j=function(r){return function(t,e,n){var i={};return e=z(e),M(t,function(o,g){var a=e.call(n,o,g,t);r(i,a,o)}),i}};A.groupBy=j(function(r,t,e){A.has(r,t)?r[t].push(e):r[t]=[e]}),A.indexBy=j(function(r,t,e){r[t]=e}),A.countBy=j(function(r,t){A.has(r,t)?r[t]++:r[t]=1}),A.sortedIndex=function(r,t,e,n){e=z(e);for(var i=e.call(n,t),o=0,g=r.length;g>o;){var a=o+g>>>1;e.call(n,r[a])t?[]:b.call(r,0,t)},A.initial=function(r,t,e){return b.call(r,0,r.length-(null==t||e?1:t))},A.last=function(r,t,e){return null==r?void 0:null==t||e?r[r.length-1]:b.call(r,Math.max(r.length-t,0))},A.rest=A.tail=A.drop=function(r,t,e){return b.call(r,null==t||e?1:t)},A.compact=function(r){return A.filter(r,A.identity)};var S=function(r,t,e){return t&&A.every(r,A.isArray)?s.apply(e,r):(M(r,function(r){A.isArray(r)||A.isArguments(r)?t?a.apply(e,r):S(r,t,e):e.push(r)}),e)};A.flatten=function(r,t){return S(r,t,[])},A.without=function(r){return A.difference(r,b.call(arguments,1))},A.partition=function(r,t){var e=[],n=[];return M(r,function(r){(t(r)?e:n).push(r)}),[e,n]},A.uniq=A.unique=function(r,t,e,n){A.isFunction(t)&&(n=e,e=t,t=!1);var i=e?A.map(r,e,n):r,o=[],g=[];return M(i,function(e,n){(t?n&&g[g.length-1]===e:A.contains(g,e))||(g.push(e),o.push(r[n]))}),o},A.union=function(){return A.uniq(A.flatten(arguments,!0))},A.intersection=function(r){var t=b.call(arguments,1);return A.filter(A.uniq(r),function(r){return A.every(t,function(t){return A.contains(t,r)})})},A.difference=function(r){var t=s.apply(i,b.call(arguments,1));return A.filter(r,function(r){return!A.contains(t,r)})},A.zip=function(){for(var r=A.max(A.pluck(arguments,"length").concat(0)),t=new Array(r),e=0;r>e;e++)t[e]=A.pluck(arguments,""+e);return t},A.object=function(r,t){if(null==r)return{};for(var e={},n=0,i=r.length;i>n;n++)t?e[r[n]]=t[n]:e[r[n][0]]=r[n][1];return e},A.indexOf=function(r,t,e){if(null==r)return-1;var n=0,i=r.length;if(e){if("number"!=typeof e)return n=A.sortedIndex(r,t),r[n]===t?n:-1;n=0>e?Math.max(0,i+e):e}if(v&&r.indexOf===v)return r.indexOf(t,e);for(;i>n;n++)if(r[n]===t)return n;return-1},A.lastIndexOf=function(r,t,e){if(null==r)return-1;var n=null!=e;if(x&&r.lastIndexOf===x)return n?r.lastIndexOf(t,e):r.lastIndexOf(t);for(var i=n?e:r.length;i--;)if(r[i]===t)return i;return-1},A.range=function(r,t,e){arguments.length<=1&&(t=r||0,r=0),e=arguments[2]||1;for(var n=Math.max(Math.ceil((t-r)/e),0),i=0,o=new Array(n);n>i;)o[i++]=r,r+=e;return o};var O=function(){};A.bind=function(r,t){var e,n;if(k&&r.bind===k)return k.apply(r,b.call(arguments,1));if(!A.isFunction(r))throw new TypeError;return e=b.call(arguments,2),n=function(){if(!(this instanceof n))return r.apply(t,e.concat(b.call(arguments)));O.prototype=r.prototype;var i=new O;O.prototype=null;var o=r.apply(i,e.concat(b.call(arguments)));return Object(o)===o?o:i}},A.partial=function(r){var t=b.call(arguments,1);return function(){for(var e=0,n=t.slice(),i=0,o=n.length;o>i;i++)n[i]===A&&(n[i]=arguments[e++]);for(;e=l?(clearTimeout(g),g=null,a=s,o=r.apply(n,i),n=i=null):g||e.trailing===!1||(g=setTimeout(b,l)),o}},A.debounce=function(r,t,e){var n,i,o,g,a,b=function(){var s=A.now()-g;t>s?n=setTimeout(b,t-s):(n=null,e||(a=r.apply(o,i),o=i=null))};return function(){o=this,i=arguments,g=A.now();var s=e&&!n;return n||(n=setTimeout(b,t)),s&&(a=r.apply(o,i),o=i=null),a}},A.once=function(r){var t,e=!1;return function(){return e?t:(e=!0,t=r.apply(this,arguments),r=null,t)}},A.wrap=function(r,t){return A.partial(t,r)},A.compose=function(){var r=arguments;return function(){for(var t=arguments,e=r.length-1;e>=0;e--)t=[r[e].apply(this,t)];return t[0]}},A.after=function(r,t){return function(){return--r<1?t.apply(this,arguments):void 0}},A.keys=function(r){if(!A.isObject(r))return[];if(w)return w(r);var t=[];for(var e in r)A.has(r,e)&&t.push(e);return t},A.values=function(r){for(var t=A.keys(r),e=t.length,n=new Array(e),i=0;e>i;i++)n[i]=r[t[i]];return n},A.pairs=function(r){for(var t=A.keys(r),e=t.length,n=new Array(e),i=0;e>i;i++)n[i]=[t[i],r[t[i]]];return n},A.invert=function(r){for(var t={},e=A.keys(r),n=0,i=e.length;i>n;n++)t[r[e[n]]]=e[n];return t},A.functions=A.methods=function(r){var t=[];for(var e in r)A.isFunction(r[e])&&t.push(e);return t.sort()},A.extend=function(r){return M(b.call(arguments,1),function(t){if(t)for(var e in t)r[e]=t[e]}),r},A.pick=function(r){var t={},e=s.apply(i,b.call(arguments,1));return M(e,function(e){e in r&&(t[e]=r[e])}),t},A.omit=function(r){var t={},e=s.apply(i,b.call(arguments,1));for(var n in r)A.contains(e,n)||(t[n]=r[n]);return t},A.defaults=function(r){return M(b.call(arguments,1),function(t){if(t)for(var e in t)void 0===r[e]&&(r[e]=t[e])}),r},A.clone=function(r){return A.isObject(r)?A.isArray(r)?r.slice():A.extend({},r):r},A.tap=function(r,t){return t(r),r};var B=function(r,t,e,n){if(r===t)return 0!==r||1/r==1/t;if(null==r||null==t)return r===t;r instanceof A&&(r=r._wrapped),t instanceof A&&(t=t._wrapped);var i=l.call(r);if(i!=l.call(t))return!1;switch(i){case"[object String]":return r==String(t);case"[object Number]":return r!=+r?t!=+t:0==r?1/r==1/t:r==+t;case"[object Date]":case"[object Boolean]":return+r==+t;case"[object RegExp]":return r.source==t.source&&r.global==t.global&&r.multiline==t.multiline&&r.ignoreCase==t.ignoreCase}if("object"!=typeof r||"object"!=typeof t)return!1;for(var o=e.length;o--;)if(e[o]==r)return n[o]==t;var g=r.constructor,a=t.constructor;if(g!==a&&!(A.isFunction(g)&&g instanceof g&&A.isFunction(a)&&a instanceof a)&&"constructor"in r&&"constructor"in t)return!1;e.push(r),n.push(t);var b=0,s=!0;if("[object Array]"==i){if(b=r.length,s=b==t.length)for(;b--&&(s=B(r[b],t[b],e,n)););}else{for(var u in r)if(A.has(r,u)&&(b++,!(s=A.has(t,u)&&B(r[u],t[u],e,n))))break;if(s){for(u in t)if(A.has(t,u)&&!b--)break;s=!b}}return e.pop(),n.pop(),s};A.isEqual=function(r,t){return B(r,t,[],[])},A.isEmpty=function(r){if(null==r)return!0;if(A.isArray(r)||A.isString(r))return 0===r.length;for(var t in r)if(A.has(r,t))return!1;return!0},A.isElement=function(r){return!(!r||1!==r.nodeType)},A.isArray=_||function(r){return"[object Array]"==l.call(r)},A.isObject=function(r){return r===Object(r)},M(["Arguments","Function","String","Number","Date","RegExp"],function(r){A["is"+r]=function(t){return l.call(t)=="[object "+r+"]"}}),A.isArguments(arguments)||(A.isArguments=function(r){return!(!r||!A.has(r,"callee"))}),"function"!=typeof/./&&(A.isFunction=function(r){return"function"==typeof r}),A.isFinite=function(r){return isFinite(r)&&!isNaN(parseFloat(r))},A.isNaN=function(r){return A.isNumber(r)&&r!=+r},A.isBoolean=function(r){return r===!0||r===!1||"[object Boolean]"==l.call(r)},A.isNull=function(r){return null===r},A.isUndefined=function(r){return void 0===r},A.has=function(r,t){return u.call(r,t)},A.noConflict=function(){return r._=t,this},A.identity=function(r){return r},A.constant=function(r){return function(){return r}},A.property=function(r){return function(t){return t[r]}},A.matches=function(r){return function(t){if(t===r)return!0;for(var e in r)if(r[e]!==t[e])return!1;return!0}},A.times=function(r,t,e){for(var n=Array(Math.max(0,r)),i=0;r>i;i++)n[i]=t.call(e,i);return n},A.random=function(r,t){return null==t&&(t=r,r=0),r+Math.floor(Math.random()*(t-r+1))},A.now=Date.now||function(){return(new Date).getTime()};var F={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};F.unescape=A.invert(F.escape);var E={escape:new RegExp("["+A.keys(F.escape).join("")+"]","g"),unescape:new RegExp("("+A.keys(F.unescape).join("|")+")","g")};A.each(["escape","unescape"],function(r){A[r]=function(t){return null==t?"":(""+t).replace(E[r],function(t){return F[r][t]})}}),A.result=function(r,t){if(null==r)return void 0;var e=r[t];return A.isFunction(e)?e.call(r):e},A.mixin=function(r){M(A.functions(r),function(t){var e=A[t]=r[t];A.prototype[t]=function(){var r=[this._wrapped];return a.apply(r,arguments),Y.call(this,e.apply(A,r))}})};var R=0;A.uniqueId=function(r){var t=++R+"";return r?r+t:t},A.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var T=/(.)^/,N={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},P=/\\|'|\r|\n|\t|\u2028|\u2029/g;A.template=function(r,t,e){var n;e=A.defaults({},e,A.templateSettings);var i=new RegExp([(e.escape||T).source,(e.interpolate||T).source,(e.evaluate||T).source].join("|")+"|$","g"),o=0,g="__p+='";r.replace(i,function(t,e,n,i,a){return g+=r.slice(o,a).replace(P,function(r){return"\\"+N[r]}),e&&(g+="'+\n((__t=("+e+"))==null?'':_.escape(__t))+\n'"),n&&(g+="'+\n((__t=("+n+"))==null?'':__t)+\n'"),i&&(g+="';\n"+i+"\n__p+='"),o=a+t.length,t}),g+="';\n",e.variable||(g="with(obj||{}){\n"+g+"}\n"),g="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+g+"return __p;\n";try{n=new Function(e.variable||"obj","_",g)}catch(a){throw a.source=g,a}if(t)return n(t,A);var b=function(r){return n.call(this,r,A)};return b.source="function("+(e.variable||"obj")+"){\n"+g+"}",b},A.chain=function(r){return A(r).chain()};var Y=function(r){return this._chain?A(r).chain():r};A.mixin(A),M(["pop","push","reverse","shift","sort","splice","unshift"],function(r){var t=i[r];A.prototype[r]=function(){var e=this._wrapped;return t.apply(e,arguments),"shift"!=r&&"splice"!=r||0!==e.length||delete e[0],Y.call(this,e)}}),M(["concat","join","slice"],function(r){var t=i[r];A.prototype[r]=function(){return Y.call(this,t.apply(this._wrapped,arguments))}}),A.extend(A.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),"function"==typeof e&&e.amd&&e("underscore",[],function(){return A})}.call(this),e("core/manager",["underscore"],function(r){var t={data_frames:{},panes:[]};return t.addData=function(t,e){var n={};n[t]=e,r.extend(this.data_frames,n)},t.getData=function(r){return this.data_frames[r]},t.addPane=function(r){this.panes.push(r)},t.update=function(t){if(arguments.length>0){var e=r.filter(this.panes,function(r){return r.uuid==t});r.each(e,function(r){r.pane.update()})}else r.each(this.panes,function(r){r.pane.update()})},t}),function(){function r(r,t,e){var n=t&&e||0,i=0;for(t=t||[],r.toLowerCase().replace(/[0-9a-f]{2}/g,function(r){16>i&&(t[n+i++]=f[r])});16>i;)t[n+i++]=0;return t}function n(r,t){var e=t||0,n=d;return n[r[e++]]+n[r[e++]]+n[r[e++]]+n[r[e++]]+"-"+n[r[e++]]+n[r[e++]]+"-"+n[r[e++]]+n[r[e++]]+"-"+n[r[e++]]+n[r[e++]]+"-"+n[r[e++]]+n[r[e++]]+n[r[e++]]+n[r[e++]]+n[r[e++]]+n[r[e++]]}function i(r,t,e){var i=t&&e||0,o=t||[];r=r||{};var g=null!=r.clockseq?r.clockseq:y,a=null!=r.msecs?r.msecs:(new Date).getTime(),b=null!=r.nsecs?r.nsecs:x+1,s=a-v+(b-x)/1e4;if(0>s&&null==r.clockseq&&(g=g+1&16383),(0>s||a>v)&&null==r.nsecs&&(b=0),b>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");v=a,x=b,y=g,a+=122192928e5;var l=(1e4*(268435455&a)+b)%4294967296;o[i++]=l>>>24&255,o[i++]=l>>>16&255,o[i++]=l>>>8&255,o[i++]=255&l;var u=a/4294967296*1e4&268435455;o[i++]=u>>>8&255,o[i++]=255&u,o[i++]=u>>>24&15|16,o[i++]=u>>>16&255,o[i++]=g>>>8|128,o[i++]=255&g;for(var c=r.node||m,d=0;6>d;d++)o[i+d]=c[d];return t?t:n(o)}function o(r,t,e){var i=t&&e||0;"string"==typeof r&&(t="binary"==r?new c(16):null,r=null),r=r||{};var o=r.random||(r.rng||g)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var a=0;16>a;a++)t[i+a]=o[a];return t||n(o)}var g,a=this;if("function"==typeof t)try{var b=t("crypto").randomBytes;g=b&&function(){return b(16)}}catch(s){}if(!g&&a.crypto&&crypto.getRandomValues){var l=new Uint8Array(16);g=function(){return crypto.getRandomValues(l),l}}if(!g){var u=new Array(16);g=function(){for(var r,t=0;16>t;t++)0===(3&t)&&(r=4294967296*Math.random()),u[t]=r>>>((3&t)<<3)&255;return u}}for(var c="function"==typeof Buffer?Buffer:Array,d=[],f={},p=0;256>p;p++)d[p]=(p+256).toString(16).substr(1),f[d[p]]=p;var h=g(),m=[1|h[0],h[1],h[2],h[3],h[4],h[5]],y=16383&(h[6]<<8|h[7]),v=0,x=0,_=o;if(_.v1=i,_.v4=o,_.parse=r,_.unparse=n,_.BufferClass=c,"function"==typeof e&&e.amd)e("node-uuid",[],function(){return _});else if("undefined"!=typeof module&&module.exports)module.exports=_;else{var w=a.uuid;_.noConflict=function(){return a.uuid=w,_},a.uuid=_}}.call(this),e("view/components/legend/simple_legend",["underscore","core/manager"],function(r){function t(t,e){var n={title:"",width:150,height:22,title_height:15,mode:"normal"};return arguments.length>1&&r.extend(n,e),this.model=d3.select(document.createElementNS("http://www.w3.org/2000/svg","g")),this.options=n,this.data=t,this}return t.prototype.width=function(){return this.options.width},t.prototype.height=function(){return this.options.height*(this.data.length+1)},t.prototype.getDomObject=function(){var r=this.model,t=this.options;r.append("text").attr("x",12).attr("y",t.height).attr("font-size","14").text(t.title);var e=this.model.selectAll("g").data(this.data).enter().append("g"),n=e.append("circle").attr("cx","8").attr("cy",function(r,e){return t.height*(e+1)}).attr("r","6").attr("stroke",function(r){return r.color}).attr("stroke-width","2").attr("fill",function(r){return r.color}).attr("fill-opacity",function(r){return"off"==r.mode?0:1});switch(t.mode){case"normal":n.on("click",function(r){if(r.on||r.off){var t=d3.select(this);1==t.attr("fill-opacity")?(t.attr("fill-opacity",0),r.off()):(t.attr("fill-opacity",1),r.on())}});break;case"radio":n.on("click",function(r){var t=d3.select(this);if(0==t.attr("fill-opacity")){var e=this;n.filter(function(r){return this!=e&&!(!r.on&&!r.off)}).attr("fill-opacity",0),t.attr("fill-opacity",1),r.on()}})}return n.style("cursor",function(r){return void 0==r.on&&void 0==r.off?"default":"pointer"}),e.append("text").attr("x","18").attr("y",function(r,e){return t.height*(e+1)+4}).attr("font-size","12").text(function(r){return r.label}),r},t}),e("view/diagrams/bar",["underscore","node-uuid","core/manager","view/components/legend/simple_legend"],function(r,t,e,n){function i(t,n,i,o){var g={value:null,x:null,y:null,width:.9,color:null,hover:!0,tooltip_contents:null,tooltip:null};arguments.length>3&&r.extend(g,o);var a,b=e.getData(i);a=null==g.color?d3.scale.category20b():d3.scale.ordinal().range(g.color),this.color_scale=a;var s,l=t.append("g"),u=[];if(null!=g.value){var c=b.column(g.value);s=r.uniq(c)}else s=b.column(g.x);return r.each(s,function(r){u.push({label:r,color:a(r)})}),this.model=l,this.scales=n,this.options=g,this.legend_data=u,this.df=b,this.df_id=i,this.uuid=g.uuid,this}return i.prototype.update=function(){var r;if(null!==this.options.value){var t=this.df.columnWithFilters(this.uuid,this.options.value),e=this.countData(t);r=this.processData(e.x,e.y,this.options)}else{var n=this.df.columnWithFilters(this.uuid,this.options.x),i=this.df.columnWithFilters(this.uuid,this.options.y);r=this.processData(n,i,this.options)}var o=this.model.selectAll("rect").data(r);o.enter().append("rect").attr("height",0).attr("y",this.scales.get(0,0).y),this.updateModels(o,this.scales,this.options)},i.prototype.processData=function(t,e){return r.map(r.zip(t,e),function(r){return{x:r[0],y:r[1]}})},i.prototype.updateModels=function(r,e,n){var i=this.color_scale,o=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return d3.rgb(i(r.x)).darker(1)});var r=d3.select(this).attr("id");n.tooltip.addToYAxis(r,this.__data__.y),n.tooltip.update()},g=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return i(r.x)});d3.select(this).attr("id");n.tooltip.reset()},a=e.raw.x.rangeBand()*n.width,b=e.raw.x.rangeBand()*((1-n.width)/2);r.attr("x",function(r){return e.get(r.x,r.y).x+b}).attr("width",a).attr("fill",function(r){return i(r.x)}).transition().duration(200).attr("y",function(r){return e.get(r.x,r.y).y}).attr("height",function(r){return e.get(0,0).y-e.get(0,r.y).y}).attr("id",t.v4()),n.hover&&r.on("mouseover",o).on("mouseout",g)},i.prototype.getLegend=function(){return new n(this.legend_data)},i.prototype.countData=function(t){var e={};return r.each(t,function(r){e[r]=e[r]||0,e[r]+=1}),{x:r.keys(e),y:r.values(e)}},i.prototype.checkSelectedData=function(){},i}),e("view/components/filter",["underscore","core/manager"],function(r){function t(t,e,n,i){var o={opacity:.125,color:"gray"};arguments.length>2&&r.extend(o,i);var g=function(){var r={x:a.empty()?e.domain().x:a.extent(),y:e.domain().y};n(r)},a=d3.svg.brush().x(e.raw.x).on("brushend",g),b=t.append("g"),s=d3.max(e.range().y)-d3.min(e.range().y),l=d3.min(e.range().y);return b.call(a).selectAll("rect").attr("y",l).attr("height",s).style("fill-opacity",o.opacity).style("fill",o.color).style("shape-rendering","crispEdges"),this}return t}),e("view/diagrams/histogram",["underscore","node-uuid","core/manager","view/components/filter","view/components/legend/simple_legend"],function(r,t,e,n,i){function o(t,n,i,o){var g={title:"histogram",value:null,bin_num:20,width:.9,color:"steelblue",stroke_color:"black",stroke_width:1,hover:!0,tooltip:null};arguments.length>3&&r.extend(g,o);var a=e.getData(i),b=t.append("g");return this.scales=n,this.legends=[{label:g.title,color:g.color}],this.options=g,this.model=b,this.df=a,this.uuid=g.uuid,this}return o.prototype.update=function(){var r=this.df.columnWithFilters(this.uuid,this.options.value),t=this.processData(r,this.options),e=this.model.selectAll("rect").data(t);e.enter().append("rect").attr("height",0).attr("y",this.scales.get(0,0).y),this.updateModels(e,this.scales,this.options)},o.prototype.processData=function(r,t){return d3.layout.histogram().bins(this.scales.raw.x.ticks(t.bin_num))(r)},o.prototype.updateModels=function(r,e,n){var i=function(){d3.select(this).transition().duration(200).attr("fill",d3.rgb(n.color).darker(1));var r=d3.select(this).attr("id");n.tooltip.addToYAxis(r,this.__data__.y,3),n.tooltip.update()},o=function(){d3.select(this).transition().duration(200).attr("fill",n.color);d3.select(this).attr("id");n.tooltip.reset()};r.attr("x",function(r){return e.get(r.x,0).x}).attr("width",function(r){return e.get(r.dx,0).x-e.get(0,0).x}).attr("fill",n.color).attr("stroke",n.stroke_color).attr("stroke-width",n.stroke_width).transition().duration(200).attr("y",function(r){return e.get(0,r.y).y}).attr("height",function(r){return e.get(0,0).y-e.get(0,r.y).y}).attr("id",t.v4()),n.hover&&r.on("mouseover",i).on("mouseout",o)},o.prototype.getLegend=function(){return new i(this.legend_data)},o.prototype.checkSelectedData=function(r){var t=this.options.value,n=function(e){var n=e[t];return n>r.x[0]&&n3&&r.extend(g,o),this.scales=n;var a=e.getData(i),b=t.append("g");return this.legend_data=function(r){var t=function(){r.render=!0,r.update()},e=function(){r.render=!1,r.update()};return[{label:g.title,color:g.color,on:t,off:e}]}(this),this.render=!0,this.options=g,this.model=b,this.df=a,this.uuid=g.uuid,this}return o.prototype.update=function(){var r=this.processData(this.options);if(this.options.tooltip.reset(),this.render){var t=this.model.selectAll("path").data(r);t.enter().append("path"),this.updateModels(t,this.scales,this.options)}else this.model.selectAll("path").remove()},o.prototype.processData=function(t){var e=this.df,n=["x","y","fill","size","shape"],i=r.map(["x","y"],function(r){return e.column(t[r])}),o=i[0].length;if(r.each([{column:"fill_by",val:"color"},{column:"size_by",val:"size"},{column:"shape_by",val:"shape"}],function(n){if(t[n.column]){var g=e.scale(t[n.column],t[n.val]);i.push(r.map(e.column(t[n.column]),function(r){return g(r)}))}else i.push(r.map(r.range(1,o+1,1),function(){return r.isArray(t[n.val])?t[n.val][0]:t[n.val]}))}),t.tooltip_contents.length>0){var g=e.getPartialDf(t.tooltip_contents);n.push("tt"),i.push(g)}return r.map(r.zip.apply(null,i),function(t){return r.reduce(t,function(r,t,e){return r[n[e]]=t,r},{})})},o.prototype.updateModels=function(r,t,e){var n=this.uuid,i=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return d3.rgb(r.fill).darker(1)}),e.tooltip.addToXAxis(n,this.__data__.x,3),e.tooltip.addToYAxis(n,this.__data__.y,3),e.tooltip_contents.length>0&&e.tooltip.add(n,this.__data__.x,this.__data__.y,"top",this.__data__.tt),e.tooltip.update()},o=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return r.fill}),e.tooltip.reset()};r.attr("transform",function(r){return"translate("+t.get(r.x,r.y).x+","+t.get(r.x,r.y).y+")"}).attr("fill",function(r){return r.fill}).attr("stroke",e.stroke_color).attr("stroke-width",e.stroke_width).transition().duration(200).attr("d",d3.svg.symbol().type(function(r){return r.shape}).size(function(r){return r.size})),e.hover&&r.on("mouseover",i).on("mouseout",o)},o.prototype.getLegend=function(){return new i(this.legend_data)},o.prototype.checkSelectedData=function(){},o}),e("view/diagrams/line",["underscore","core/manager","view/components/filter","view/components/legend/simple_legend"],function(r,t,e,n){function i(e,n,i,o){var g={title:"line",x:null,y:null,color:"steelblue",stroke_width:2};arguments.length>3&&r.extend(g,o),this.scales=n;var a=t.getData(i),b=e.append("g");return this.legend_data=function(r){var t=function(){r.render=!0,r.update()},e=function(){r.render=!1,r.update()};return[{label:g.title,color:g.color,on:t,off:e}]}(this),this.render=!0,this.options=g,this.model=b,this.df=a,this.df_id=i,this}return i.prototype.update=function(){if(this.render){var r=this.processData(this.df.column(this.options.x),this.df.column(this.options.y),this.options);this.model.selectAll("path").remove();var t=this.model.append("path").datum(r);this.updateModels(t,this.scales,this.options)}else this.model.selectAll("path").remove()},i.prototype.processData=function(t,e){return r.map(r.zip(t,e),function(r){return{x:r[0],y:r[1]}})},i.prototype.updateModels=function(r,t,e){var n=d3.svg.line().x(function(r){return t.get(r.x,r.y).x}).y(function(r){return t.get(r.x,r.y).y});r.attr("d",n).attr("stroke",e.color).attr("stroke-width",e.stroke_width).attr("fill","none")},i.prototype.getLegend=function(){var r=new n(this.legend_data);return r},i.prototype.checkSelectedData=function(){},i}),e("utils/simplex",["underscore"],function(r){function t(t){var e=[];return r.each(r.zip.apply(null,t),function(t,n){e[n]=0,r.each(t,function(r){e[n]+=r}),e[n]=e[n]/t.length}),e}function e(n,s){n=r.sortBy(n,function(r){return s(r)});for(var l=n.length,u=n[0].length,c=n[l-1],d=n[l-2],f=n[0],p=t(n.concat().splice(0,l-1)),h=[],m=0;u>m;m++)h[m]=2*p[m]-c[m];if(s(h)>=s(c))for(var m=0;u>m;m++)n[l-1][m]=(1-i)*c[m]+i*h[m];else if(s(h)<(s(f)+(o-1)*s(c))/o){for(var y=[],m=0;u>m;m++)y[m]=o*h[m]-(o-1)*c[m];n[l-1]=s(y)<=s(h)?y:h}else n[l-1]=h;s(n[l-1])>=s(d)&&r.each(n,function(r,t){for(var e=0;u>e;e++)n[t][e]=.5*(r[e]+f[e])});var v=0;return r.each(n,function(r){v+=Math.pow(s(r)-s(f),2)}),g>v?n[l-1]:(a++,a>b?n[l-1]:e(n,s))}function n(t,n){var i=1,o=t.length,g=[t];return r.each(r.range(o),function(r){var e=t.concat();e[r]+=i,g.push(e)}),e(g,n)}var i=.7,o=1.5,g=1e-20,a=0,b=2e3;return n}),e("view/diagrams/venn",["underscore","core/manager","view/components/filter","view/components/legend/simple_legend","utils/simplex"],function(r,t,e,n,i){function o(e,i,o,g){var a={category:null,count:null,color:null,stroke_color:"#000",stroke_width:1,opacity:.7,hover:!1,area_names:["VENN1","VENN2","VENN3"],filter_control:!1};arguments.length>3&&r.extend(a,g);var b,s=t.getData(o),l=e.append("g"),u=s.column(a.category),c=r.uniq(u);b=null==a.color?d3.scale.category20().domain(a.area_names):d3.scale.ordinal().range(a.color).domain(a.area_names),this.color_scale=b;for(var d=[],f=[[c[0]],[c[1]],[c[2]]],p=this.update,h=this.tellUpdate,m=this,y=0;3>y;y++){var v=[];v.push({label:a.area_names[y],color:b(a.area_names[y])}),r.each(c,function(r){var t=y,e=function(){f[t].push(r),p.call(m),h.call(m)},n=function(){var e=f[t].indexOf(r);f[t].splice(e,1),p.call(m),h.call(m)},i=r==f[y]?"on":"off";v.push({label:r,color:"black",mode:i,on:e,off:n})}),d.push(new n(v))}var x="all";if(a.filter_control){var v=[],_=["all","overlapping","non-overlapping"],w=x;v.push({label:"Filter",color:"gray"}),r.each(_,function(r){var t=function(){m.filter_mode=r,p.call(m),h.call(m) +},e=r==w?"on":"off";v.push({label:r,color:"black",on:t,off:function(){},mode:e})}),d.push(new n(v,{mode:"radio"}))}return this.selected_category=f,this.filter_mode=x,this.legend_data=d,this.options=a,this.scales=i,this.model=l,this.df_id=o,this.df=s,this.uuid=a.uuid,this.tellUpdate(),this}return o.prototype.getScales=function(t,e){var n=r.max(e.range().x)-r.min(e.range().x),i=r.max(e.range().y)-r.min(e.range().y),o={min:function(){var e=r.min(t.pos,function(r){return r.x-r.r});return e.x-e.r}(),max:function(){var e=r.max(t.pos,function(r){return r.x+r.r});return e.x+e.r}()},g={min:function(){var e=r.min(t.pos,function(r){return r.y-r.r});return e.y-e.r}(),max:function(){var e=r.max(t.pos,function(r){return r.y+r.r});return e.y+e.r}()},a=o.max-o.min,b=g.max-g.min,s=0;if(n/i>a/b){s=b/i;var l=s*n;o.min-=(l-a)/2,o.max+=(l-a)/2}else{s=a/n;var u=s*i;b.min-=(u-b)/2,b.max+=(u-b)/2}var c={};return c.x=d3.scale.linear().range(e.range().x).domain([o.min,o.max]),c.y=d3.scale.linear().range(e.range().y).domain([g.min,g.max]),c.r=d3.scale.linear().range([0,100]).domain([0,100*s]),c},o.prototype.update=function(){var r=this.df.columnWithFilters(this.uuid,this.options.count),t=this.df.columnWithFilters(this.uuid,this.options.category),e=this.processData(t,r,this.selected_category),n=this.getScales(e,this.scales),i=this.model.selectAll("circle").data(e.pos),o=this.model.selectAll("text").data(e.labels);void 0==i[0][0]&&(i=i.enter().append("circle")),void 0==o[0][0]&&(o=o.enter().append("text")),this.counted_items=e.counted_items,this.updateModels(i,n,this.options),this.updateLabels(o,n,this.options)},o.prototype.processData=function(t,e,n){for(var o=(function(){for(var i=[],o=function(){var i={};return r.each(r.zip(t,e),function(t){void 0==i[t[1]]&&(i[t[1]]={}),r.each(n,function(r,e){-1!=r.indexOf(t[0])&&(i[t[1]][e]=!0)})}),i}(),g=(function(t){var e=0;return r.each(r.values(o),function(n){r.some(t,function(r){return!(r in n)})||e++}),e}),a=0;3>a;a++){i[a]=[],i[a][a]=g([a]);for(var b=a+1;3>b;b++){var s=g([a,b]);i[a][b]=s}}return{table:i,counted_items:o}}()),g=o.table,a=o.counted_items,b=r.map(g,function(r,t){return Math.sqrt(g[t][t]/(2*Math.PI))}),s=function(t){for(var e=0,n=0;nu+c?f=0:r.each([[u,c],[c,u]],function(r){var t=Math.acos((r[1]*r[1]-r[0]*r[0]+d*d)/(2*r[1]*d)),e=r[n]*r[n]*t-.5*r[1]*r[1]*Math.sin(2*t);f+=e}),e+=Math.pow(g[n/2][i/2]-f,2)}return e},l=function(){var t=[],e=g[0].length,n=r.max(g,function(r,t){for(var e=0,n=0;t>n;n++)e+=g[n][t];for(var n=t+1;ns;s++)if(s!=i){var l=b[i]+b[s]/2;t[2*s]=l*Math.sin(o),t[2*s+1]=l*Math.cos(o),o+=a}return t}(),u=i(l,s),c=[],d=[],f=0;ff;f++){d.push({x:u[2*f],y:u[2*f+1],val:g[f][f]});for(var p=f+1;3>p;p++){var h=(u[2*f]+u[2*p])/2,m=(u[2*f+1]+u[2*p+1])/2;d.push({x:h,y:m,val:g[f][p]})}}return{pos:c,labels:d,counted_items:a}},o.prototype.updateModels=function(r,t,e){var n=this.color_scale,i=this.options.area_names;if(r.attr("cx",function(r){return t.x(r.x)}).attr("cy",function(r){return t.y(r.y)}).attr("stroke",e.stroke_color).attr("stroke-width",e.stroke_width).attr("fill",function(r){return n(i[r.id])}).attr("fill-opacity",e.opacity).transition().duration(500).attr("r",function(r){return t.r(r.r)}),e.hover){var o=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return d3.rgb(n(i[r.id])).darker(1)})},g=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return n(i[r.id])})};r.on("mouseover",o).on("mouseout",g)}},o.prototype.updateLabels=function(r,t){r.attr("x",function(r){return t.x(r.x)}).attr("y",function(r){return t.y(r.y)}).attr("text-anchor","middle").text(function(r){return String(r.val)})},o.prototype.getLegend=function(){return this.legend_data},o.prototype.tellUpdate=function(){var e=this.selected_category,n=this.counted_items,i=this.filter_mode,o=this.options.category,g=this.options.count,a={all:function(t){return r.some(e,function(r){return-1!=r.indexOf(t[o])?!0:!1})},overlapping:function(t){if(!r.some(e,function(r){return-1!=r.indexOf(t[o])?!0:!1}))return!1;for(var i=0;3>i;i++)for(var a=i+1;3>a;a++)if(n[t[g]][i]&&n[t[g]][a])return!0;return!1},"non-overlapping":function(t){if(!r.some(e,function(r){return-1!=r.indexOf(t[o])?!0:!1}))return!1;for(var i=0;3>i;i++)for(var a=i+1;3>a;a++)if(n[t[g]][i]&&n[t[g]][a])return!1;return!0}}[i];this.df.addFilter(this.uuid,a,["self"]),t.update()},o}),e("view/diagrams/multiple_venn",["underscore","core/manager","view/components/filter","utils/simplex"],function(r,t,e,n){function i(e,n,i,o){var g={category:null,count:null,color:null,stroke_color:"#000",stroke_width:1,opacity:.7,hover:!1};arguments.length>3&&r.extend(g,o),this.getScales=function(t,e){var n=r.max(e.x.range())-r.min(e.x.range()),i=r.max(e.y.range())-r.min(e.y.range()),o={min:function(){var e=r.min(t.pos,function(r){return r.x-r.r});return e.x-e.r}(),max:function(){var e=r.max(t.pos,function(r){return r.x+r.r});return e.x+e.r}()},g={min:function(){var e=r.min(t.pos,function(r){return r.y-r.r});return e.y-e.r}(),max:function(){var e=r.max(t.pos,function(r){return r.y+r.r});return e.y+e.r}()},a=o.max-o.min,b=g.max-g.min,s=0;if(n/i>a/b){s=b/i;var l=s*n;o.min-=(l-a)/2,o.max+=(l-a)/2}else{s=a/n;var u=s*i;b.min-=(u-b)/2,b.max+=(u-b)/2}var c={};return c.x=d3.scale.linear().range(e.x.range()).domain([o.min,o.max]),c.y=d3.scale.linear().range(e.y.range()).domain([g.min,g.max]),c.r=d3.scale.linear().range([0,100]).domain([0,100*s]),c};var a=t.getData(i),b=this.processData(a.column(g.category),a.column(g.count)),s=this.getScales(b,n),l=e.append("g"),u=l.selectAll("circle").data(b.pos).enter().append("circle"),c=l.selectAll("text").data(b.labels).enter().append("text");this.color_scale=null==g.color?d3.scale.category20():d3.scale.ordinal().range(g.color);var d=this.color_scale;this.updateModels(u,s,g),this.updateLabels(c,s,g);var f=[];return r.each(b.pos,function(r){f.push({label:r.name,color:d(r.name)})}),this.legends=f,this.scales=n,this.options=g,this.model=l,this.df=a,this.df_id=i,this}return i.prototype.processData=function(t,e){for(var i=r.uniq(t),o=(function(){for(var n=[],o=function(){var n={};return r.each(r.zip(t,e),function(r){void 0==n[r[1]]&&(n[r[1]]={}),n[r[1]][r[0]]=!0}),r.values(n)}(),g=(function(t){var e=0;return r.each(o,function(n){r.some(t,function(r){return!(r in n)})||e++}),e}),a=0;au+c?f=0:r.each([[u,c],[c,u]],function(r){var t=Math.acos((r[1]*r[1]-r[0]*r[0]+d*d)/(2*r[1]*d)),e=r[n]*r[n]*t-.5*r[1]*r[1]*Math.sin(2*t);f+=e}),e+=Math.pow(o[n/2][i/2]-f,2)}return e},b=function(){var t=[],e=o[0].length,n=r.max(o,function(r,t){for(var e=0,n=0;t>n;n++)e+=o[n][t];for(var n=t+1;ns;s++)if(s!=i){var l=g[i]+g[s]/2;t[2*s]=l*Math.sin(a),t[2*s+1]=l*Math.cos(a),a+=b}return t}(),s=n(b,a),l=[],u=[],c=0;c3&&r.extend(g,o);var a,b=t.append("g"),s=e.getData(i);return a=null==g.color?d3.scale.category20b():d3.scale.ordinal().range(g.color),this.model=b,this.scales=n,this.options=g,this.df=s,this.color_scale=a,this.uuid=g.uuid,this}return i.prototype.update=function(){var t=this.uuid,e=this.processData,n=this.df,i=[];r.each(this.options.value,function(o){var g=n.columnWithFilters(t,o);i.push(r.extend(e(g),{x:o}))});var o=this.model.selectAll("g").data(i);o.enter().append("g"),this.updateModels(o,this.scales,this.options)},i.prototype.processData=function(t){var e=function(r){var t=r.length;return t%2==1?r[Math.floor(t/2)]:(r[t/2]+r[t/2+1])/2},n=r.sortBy(t),i=e(n),o=e(n.slice(0,n.length/2-1)),g=e(n.slice(n.length%2==0?n.length/2:n.length/2+1,n.length-1)),a=g-o,b=r.max(n)-g>1.5*a?g+1.5*a:r.max(n),s=o-r.min(n)>1.5*a?o-1.5*a:r.min(n),l=r.filter(n,function(r){return r>b||s>r});return{med:i,q1:o,q3:g,max:b,min:s,outlier:l}},i.prototype.updateModels=function(r,e,n){var i=e.raw.x.rangeBand()*n.width,o=e.raw.x.rangeBand()*((1-n.width)/2),g=this.color_scale,a=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return d3.rgb(g(r.x)).darker(1)});var r=d3.select(this).attr("id");n.tooltip.addToYAxis(r,this.__data__.min,3),n.tooltip.addToYAxis(r,this.__data__.q1,3),n.tooltip.addToYAxis(r,this.__data__.med,3),n.tooltip.addToYAxis(r,this.__data__.q3,3),n.tooltip.addToYAxis(r,this.__data__.max,3),n.tooltip.update()},b=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return d3.rgb(g(r.x))});d3.select(this).attr("id");n.tooltip.reset()};r.append("line").attr("x1",function(r){return e.get(r.x,0).x+i/2+o}).attr("y1",function(r){return e.get(r.x,r.max).y}).attr("x2",function(r){return e.get(r.x,0).x+i/2+o}).attr("y2",function(r){return e.get(r.x,r.min).y}).attr("stroke",n.stroke_color),r.append("rect").attr("x",function(r){return e.get(r.x,0).x+o}).attr("y",function(r){return e.get(r.x,r.q3).y}).attr("height",function(r){return e.get(r.x,r.q1).y-e.get(r.x,r.q3).y}).attr("width",i).attr("fill",function(r){return g(r.x)}).attr("stroke",n.stroke_color).attr("id",t.v4()).on("mouseover",a).on("mouseout",b),r.append("line").attr("x1",function(r){return e.get(r.x,0).x+o}).attr("y1",function(r){return e.get(r.x,r.med).y}).attr("x2",function(r){return e.get(r.x,0).x+i+o}).attr("y2",function(r){return e.get(r.x,r.med).y}).attr("stroke",n.stroke_color),r.append("g").each(function(r){d3.select(this).selectAll("circle").data(r.outlier).enter().append("circle").attr("cx",function(){return e.get(r.x,0).x+i/2+o}).attr("cy",function(t){return e.get(r.x,t).y}).attr("r",n.outlier_r)})},i.prototype.getLegend=function(){return new n(this.legend_data)},i.prototype.checkSelectedData=function(){},i}),e("view/components/legend/color_bar",["underscore"],function(r){function t(t,e){var n={width:150,height:200};arguments.length>1&&r.extend(n,e),this.options=n,this.model=d3.select(document.createElementNS("http://www.w3.org/2000/svg","g")),this.color_scale=t}return t.prototype.width=function(){return this.options.width},t.prototype.height=function(){return this.options.height},t.prototype.getDomObject=function(){for(var r=this.model,t=this.color_scale,e=t.range(),n=t.domain(),i=d3.scale.linear().domain(d3.extent(n)).range([this.options.height,0]),o=r.append("svg:defs").append("svg:linearGradient").attr("id","gradient").attr("x1","0%").attr("x2","0%").attr("y1","100%").attr("y2","0%"),g=0;g1)return t[e][n];var i=r.map(r.keys(t[e]),function(t){return r.isFinite(t)?Number(t):0}),o=r.max(i);return t[e][String(o)]}return e}),e("view/diagrams/heatmap.js",["underscore","node-uuid","core/manager","view/components/filter","view/components/legend/color_bar","utils/color"],function(r,t,e,n,i,o){function g(t,n,i,g){var a={title:"heatmap",x:null,y:null,fill:null,width:1,height:1,color:o("RdBu").reverse(),stroke_color:"#fff",stroke_width:1,hover:!0,tooltip:null};arguments.length>3&&r.extend(a,g);var b=e.getData(i),s=t.append("g");return this.color_scale=function(){var r=b.columnWithFilters(a.uuid,a.fill),t=d3.extent(r),e=d3.range(t[0],t[1],(t[1]-t[0])/a.color.length);return d3.scale.linear().range(a.color).domain(e)}(),this.scales=n,this.options=a,this.model=s,this.df=b,this.uuid=a.uuid,this}return g.prototype.update=function(){var r=this.processData(),t=this.model.selectAll("rect").data(r);t.each(function(){var r=document.createEvent("MouseEvents");r.initEvent("mouseout",!1,!0),this.dispatchEvent(r)}),t.enter().append("rect"),this.updateModels(t,this.options)},g.prototype.processData=function(){var t=this.df.columnWithFilters(this.uuid,this.options.x),e=this.df.columnWithFilters(this.uuid,this.options.y),n=this.df.columnWithFilters(this.uuid,this.options.fill),i=this.scales,o=this.options,g=this.color_scale;return r.map(r.zip(t,e,n),function(r){var t,e,n,a;return n=Math.abs(i.get(o.width,0).x-i.get(0,0).x),a=Math.abs(i.get(0,o.height).y-i.get(0,0).y),t=i.get(r[0],0).x-n/2,e=i.get(0,r[1]).y-a/2,{x:t,y:e,width:n,height:a,fill:g(r[2]),x_raw:r[0],y_raw:r[1]}})},g.prototype.updateModels=function(r,t){var e=this.uuid,n=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return d3.rgb(r.fill).darker(1)}),t.tooltip.addToXAxis(e,this.__data__.x_raw,3),t.tooltip.addToYAxis(e,this.__data__.y_raw,3),t.tooltip.update()},i=function(){d3.select(this).transition().duration(200).attr("fill",function(r){return r.fill}),t.tooltip.reset()};r.attr("x",function(r){return r.x}).attr("width",function(r){return r.width}).attr("y",function(r){return r.y}).attr("height",function(r){return r.height}).attr("fill",function(r){return r.fill}).attr("stroke",t.stroke_color).attr("stroke-width",t.stroke_width),t.hover&&r.on("mouseover",n).on("mouseout",i)},g.prototype.getLegend=function(){return new i(this.color_scale)},g.prototype.checkSelectedData=function(){},g}),e("view/diagrams/vectors.js",["underscore","node-uuid","core/manager","view/components/filter","view/components/legend/simple_legend"],function(r,t,e,n,i){function o(t,n,i,o){var g={title:"vectors",x:null,y:null,dx:null,dy:null,fill_by:null,color:["steelblue","#000000"],stroke_color:"#000",stroke_width:2,hover:!0,tooltip:null};arguments.length>3&&r.extend(g,o),this.scales=n;var a=e.getData(i),b=t.append("g");return this.legend_data=function(r){var t=function(){r.render=!0,r.update()},e=function(){r.render=!1,r.update()};return[{label:g.title,color:g.color,on:t,off:e}]}(this),this.render=!0,this.options=g,this.model=b,this.df=a,this.uuid=g.uuid,this}return o.prototype.update=function(){var r=this.processData(this.options);if(this.options.tooltip.reset(),this.render){var t=this.model.selectAll("line").data(r);t.enter().append("line"),this.updateModels(t,this.scales,this.options)}else this.model.selectAll("line").remove()},o.prototype.processData=function(t){var e=this.df,n=["x","y","dx","dy","fill"],i=r.map(["x","y","dx","dy"],function(r){return e.column(t[r])}),o=i[0].length;return r.each([{column:"fill_by",val:"color"}],function(n){if(t[n.column]){var g=e.scale(t[n.column],t[n.val]);i.push(r.map(e.column(t[n.column]),function(r){return g(r)}))}else i.push(r.map(r.range(1,o+1,1),function(){return r.isArray(t[n.val])?t[n.val][0]:t[n.val]}))}),r.map(r.zip.apply(null,i),function(t){return r.reduce(t,function(r,t,e){return r[n[e]]=t,r},{})})},o.prototype.updateModels=function(r,t,e){r.attr({x1:function(r){return t.get(r.x,r.y).x},x2:function(r){return t.get(r.x+r.dx,r.y+r.dy).x},y1:function(r){return t.get(r.x,r.y).y},y2:function(r){return t.get(r.x+r.dx,r.y+r.dy).y},stroke:function(r){return r.fill},"stroke-width":e.stroke_width})},o.prototype.getLegend=function(){return new i(this.legend_data)},o.prototype.checkSelectedData=function(){},o}),e("view/diagrams/diagrams",["require","exports","module","view/diagrams/bar","view/diagrams/histogram","view/diagrams/scatter","view/diagrams/line","view/diagrams/venn","view/diagrams/multiple_venn","view/diagrams/box.js","view/diagrams/heatmap.js","view/diagrams/vectors.js"],function(r){var t={};return t.bar=r("view/diagrams/bar"),t.histogram=r("view/diagrams/histogram"),t.scatter=r("view/diagrams/scatter"),t.line=r("view/diagrams/line"),t.venn=r("view/diagrams/venn"),t.multiple_venn=r("view/diagrams/multiple_venn"),t.box=r("view/diagrams/box.js"),t.heatmap=r("view/diagrams/heatmap.js"),t.vectors=r("view/diagrams/vectors.js"),t.add=function(r,e){t[r]=e},t}),e("view/components/legend_area",["underscore","core/manager"],function(r){function t(t,e){var n={width:200,height:300,margin:{top:10,bottom:10,left:10,right:10},fill_color:"none",stroke_color:"#000",stroke_width:0};arguments.length>1&&r.extend(n,e);var i=t.append("g");return i.append("rect").attr("width",n.width).attr("height",n.height).attr("x",0).attr("y",0).attr("fill",n.fill_color).attr("stroke",n.stroke_color).attr("stroke-width",n.stroke_width),this.model=i,this.options=n,this.seek={x:n.margin.left,y:n.margin.top,width:0},this}return t.prototype.add=function(t){var e=this.model.append("g").attr("transform","translate("+this.seek.x+","+this.seek.y+")"),n=t.getDomObject();e[0][0].appendChild(n[0][0]),this.seek.y+t.height()>this.options.height?(this.seek.x+=this.seek.width,this.seek.y=this.options.margin.top):(this.seek.width=r.max([this.seek.width,t.width()]),this.seek.y+=t.height())},t}),e("utils/ua_info",["underscore"],function(){return function(){var r=window.navigator.userAgent.toLowerCase();return-1!=r.indexOf("chrome")?"chrome":-1!=r.indexOf("firefox")?"firefox":"unknown"}}),e("view/components/tooltip",["underscore","utils/ua_info"],function(r,t){function e(t,e,n){var i={bg_color:"#333",stroke_color:"#000",stroke_width:1,text_color:"#fff",context_width:0,context_height:0,context_margin:{top:0,left:0,bottom:0,right:0},arrow_width:10,arrow_height:10,tooltip_margin:{top:2,left:5,bottom:2,right:5},font:"Helvetica, Arial, sans-serif",font_size:"1em"};arguments.length>1&&r.extend(i,n);var o=t.append("g");return this.scales=e,this.options=i,this.lists=[],this.model=o,this}return e.prototype.add=function(t,e,n,i,o){var g=r.map(o,function(r,t){return String(t)+":"+String(r)});this.lists.push({id:t,x:e,y:n,pos:i,contents:g})},e.prototype.addToXAxis=function(r,t,e){if(arguments.length>2){var n=Math.pow(10,e);t=Math.round(t*n)/n}this.lists.push({id:r,x:t,y:"bottom",pos:"bottom",contents:String(t)})},e.prototype.addToYAxis=function(r,t,e){if(arguments.length>2){var n=Math.pow(10,e);t=Math.round(t*n)/n}this.lists.push({id:r,x:"left",y:t,pos:"right",contents:String(t)})},e.prototype.reset=function(){this.lists=[],this.update()},e.prototype.update=function(){var r=this.processData(this.lists),t=this.model.selectAll("g").data(r);this.updateModels(t)},e.prototype.updateModels=function(e){e.exit().remove();this.options;!function(e,n){var i=d3.svg.line().x(function(r){return r.x}).y(function(r){return r.y}).interpolate("linear");e.append("path").attr("d",function(r){return i(r.shape)}).attr("stroke",n.stroke_color).attr("fill",n.bg_color),e.each(function(){var e;if(r.isArray(this.__data__.text)){var i=this.__data__.text,o=this.__data__.text_x,g=this.__data__.text_y,a=r.map(r.zip(i,g),function(r){return{text:r[0],y:r[1]}});e=d3.select(this).append("g").selectAll("text").data(a).enter().append("text").text(function(r){return r.text}).attr("x",function(){return o}).attr("y",function(r){return r.y})}else e=d3.select(this).append("text").text(function(r){return r.text}).attr("x",function(r){return r.text_x}).attr("y",function(r){return r.text_y});switch(e.attr("text-anchor","middle").attr("fill","#ffffff").attr("font-size",n.font_size).style("font-family",n.font),t()){case"chrome":e.attr("dominant-baseline","middle").attr("baseline-shift","50%");break;default:e.attr("dominant-baseline","text-after-edge")}}),e.attr("transform",function(r){return"translate("+r.tip_x+","+r.tip_y+")"})}(e.enter().append("g"),this.options)},e.prototype.processData=function(t){var e=this.options,n=function(t,n,i){var o=e.arrow_width,g=e.arrow_height,a=n,b=i,s={top:[{x:0,y:0},{x:o/2,y:-g},{x:a/2,y:-g},{x:a/2,y:-g-b},{x:-a/2,y:-g-b},{x:-a/2,y:-g},{x:-o/2,y:-g},{x:0,y:0}],right:[{x:0,y:0},{x:-o,y:-g/2},{x:-o,y:-b/2},{x:-o-a,y:-b/2},{x:-o-a,y:b/2},{x:-o,y:b/2},{x:-o,y:g/2},{x:0,y:0}]};s.bottom=r.map(s.top,function(r){return{x:r.x,y:-r.y}}),s.left=r.map(s.right,function(r){return{x:-r.x,y:r.y}});var l=function(r){var e={};switch(t){case"top":case"bottom":e={x:0,y:(r[2].y+r[3].y)/2};break;case"right":case"left":e={x:(r[2].x+r[3].x)/2,y:0}}return e}(s[t]);return{shape:s[t],text:l}},i=this.options.tooltip_margin,o=this.options.context_height,g=this.scales,a=this.model,b=function(r,t){var n=a.append("text").text(r).attr("font-size",t).style("font-family",e.font),i=n[0][0].getBBox().width,o=n[0][0].getBBox().height;return n.remove(),{w:i,h:o}};return r.map(t,function(t){var a,s=r.isArray(t.contents)?t.contents.length:1,l=r.isArray(t.contents)?r.max(t.contents,function(r){return r.length}):t.contents,u=b(l,e.font_size),c=u.w+i.left+i.right,d=(u.h+i.top+i.bottom)*s,f=g.get(t.x,t.y),p="left"==t.x?0:f.x,h="bottom"==t.y?o:f.y,m=n(t.pos,c,d);if(r.isArray(t.contents)){var y=t.contents.length;a=r.map(t.contents,function(r,t){return m.text.y-u.h/2*(y-2)+u.h*t})}else a=m.text.y+u.h/2;return{shape:m.shape,tip_x:p,tip_y:h,text_x:m.text.x,text_y:a,text:t.contents}})},e}),e("view/pane",["underscore","node-uuid","view/diagrams/diagrams","view/components/filter","view/components/legend_area","view/components/tooltip"],function(r,t,e,n,i,o){function g(e,n,g,a){var b={width:700,height:500,margin:{top:30,bottom:80,left:80,right:30},xrange:[0,0],yrange:[0,0],x_label:"X",y_label:"Y",rotate_x_label:0,rotate_y_label:0,zoom:!1,grid:!0,zoom_range:[.5,5],bg_color:"#eee",grid_color:"#fff",legend:!1,legend_position:"right",legend_width:150,legend_height:300,legend_stroke_color:"#000",legend_stroke_width:0,font:"Helvetica, Arial, sans-serif",scale:"linear",scale_extra_options:{},axis_extra_options:{}};arguments.length>1&&r.extend(b,a),this.uuid=t.v4();var s=e.append("svg").attr("width",b.width).attr("height",b.height),l=function(){var t={};if(t.plot_x=b.margin.left,t.plot_y=b.margin.top,t.plot_width=b.width-b.margin.left-b.margin.right,t.plot_height=b.height-b.margin.top-b.margin.bottom,b.legend)switch(b.legend_position){case"top":t.plot_width-=b.legend_width,t.plot_y+=b.legend_height,t.legend_x=(b.width-b.legend_width)/2,t.legend_y=b.margin.top;break;case"bottom":t.plot_height-=b.legend_height,t.legend_x=(b.width-b.legend_width)/2,t.legend_y=b.margin.top+b.height;break;case"left":t.plot_x+=b.legend_width,t.plot_width-=b.legend_width,t.legend_x=b.margin.left,t.legend_y=b.margin.top;break;case"right":t.plot_width-=b.legend_width,t.legend_x=t.plot_width+b.margin.left,t.legend_y=b.margin.top;break;case r.isArray(b.legend_position):t.legend_x=b.width*b.legend_position[0],t.legend_y=b.height*b.legend_position[1]}return t}(),u=function(){var r={x:b.xrange,y:b.yrange},t={x:[0,l.plot_width],y:[l.plot_height,0]};return new n(r,t,{linear:b.scale,extra:b.scale_extra_options})}();s.append("g").attr("transform","translate("+l.plot_x+","+l.plot_y+")").append("rect").attr("x",0).attr("y",0).attr("width",l.plot_width).attr("height",l.plot_height).attr("fill",b.bg_color).style("z-index",1);new g(s.select("g"),u,{width:l.plot_width,height:l.plot_height,margin:b.margin,grid:b.grid,zoom:b.zoom,zoom_range:b.zoom_range,x_label:b.x_label,y_label:b.y_label,rotate_x_label:b.rotate_x_label,rotate_y_label:b.rotate_y_label,stroke_color:b.grid_color,pane_uuid:this.uuid,z_index:100,extra:b.axis_extra_options});s.select("g").append("g").attr("class","context").append("clipPath").attr("id",this.uuid+"clip_context").append("rect").attr("x",0).attr("y",0).attr("width",l.plot_width).attr("height",l.plot_height),s.select(".context").attr("clip-path","url(#"+this.uuid+"clip_context)"),s.select("g").append("rect").attr("x",-1).attr("y",-1).attr("width",l.plot_width+2).attr("height",l.plot_height+2).attr("fill","none").attr("stroke","#666").attr("stroke-width",1).style("z-index",200);var c=new o(s.select("g"),u,{font:b.font,context_width:l.plot_width,context_height:l.plot_height,context_margin:{top:l.plot_x,left:l.plot_y,bottom:b.margin.bottom,right:b.margin.right}});return b.legend&&(s.append("g").attr("class","legend_area").attr("transform","translate("+l.legend_x+","+l.legend_y+")"),this.legend_area=new i(s.select(".legend_area"),{width:b.legend_width,height:b.legend_height,stroke_color:b.legend_stroke_color,stroke_width:b.legend_stroke_width})),this.diagrams=[],this.tooltip=c,this.context=s.select(".context").append("g").attr("class","context_child"),this.model=s,this.scales=u,this.options=b,this.filter=null,this}return g.prototype.addDiagram=function(n,i,o){r.extend(o,{uuid:t.v4(),tooltip:this.tooltip});var g=new e[n](this.context,this.scales,i,o);if(this.options.legend){var a=this.legend_area,b=g.getLegend();r.isArray(b)?r.each(b,function(r){a.add(r)}):this.legend_area.add(b)}this.diagrams.push(g)},g.prototype.addFilter=function(t,e){var i=this.diagrams,o=function(t){r.each(i,function(r){r.checkSelectedData(t)})};this.filter=new n(this.context,this.scales,o,e)},g.prototype.update=function(){var t=this.options.font;r.each(this.diagrams,function(r){r.update()}),this.model.selectAll("text").style("font-family",t)},g}),e("view/components/axis",["underscore","core/manager"],function(r,t){function e(e,n,i){var o={width:0,height:0,margin:{top:0,bottom:0,left:0,right:0},stroke_color:"#fff",stroke_width:1,x_label:"X",y_label:"Y",grid:!0,zoom:!1,zoom_range:[.5,5],rotate_x_label:0,rotate_y_label:0,pane_uuid:null,z_index:0};arguments.length>2&&r.extend(o,i);var g=d3.svg.axis().scale(n.raw.x).orient("bottom"),a=d3.svg.axis().scale(n.raw.y).orient("left");e.append("g").attr("class","x_axis"),e.append("g").attr("class","y_axis"),e.append("text").attr("x",o.width/2).attr("y",o.height+o.margin.bottom/1.5).attr("text-anchor","middle").attr("fill","rgb(50,50,50)").attr("font-size",22).text(o.x_label),e.append("text").attr("x",-o.margin.left/1.5).attr("y",o.height/2).attr("text-anchor","middle").attr("fill","rgb(50,50,50)").attr("font-size",22).attr("transform","rotate(-90,"+-o.margin.left/1.5+","+o.height/2+")").text(o.y_label);var b=function(){e.select(".x_axis").call(g),e.select(".y_axis").call(a),e.selectAll(".x_axis, .y_axis").selectAll("path, line").style("z-index",o.z_index).style("fill","none").style("stroke",o.stroke_color).style("stroke-width",o.stroke_width),e.selectAll(".x_axis, .y_axis").selectAll("text").attr("fill","rgb(50,50,50)"),e.selectAll(".x_axis").attr("transform","translate(0,"+(o.height+4)+")"),e.selectAll(".y_axis").attr("transform","translate(-4,0)"),0!=o.rotate_x_label&&e.selectAll(".x_axis").selectAll("text").style("text-anchor","end").attr("transform",function(){return"rotate("+o.rotate_x_label+")"}),0!=o.rotate_y_label&&e.selectAll(".y_axis").selectAll("text").style("text-anchor","end").attr("transform",function(){return"rotate("+o.rotate_y_label+")"}),t.update(o.pane_uuid)};if(o.grid&&(g.tickSize(-1*o.height),a.tickSize(-1*o.width)),o.zoom){var s=d3.behavior.zoom().x(n.raw.x).y(n.raw.y).scaleExtent(o.zoom_range).on("zoom",b);e.call(s),e.on("dblclick.zoom",null)}return b(),this.model=e,this}return e}),e("view/components/scale",["underscore"],function(r){function t(t,e,n){var i={linear:"linear"};arguments.length>1&&r.extend(i,n);var o={};return r.each(["x","y"],function(n){if(r.some(t[n],function(t){return r.isString(t)}))o[n]=d3.scale.ordinal().domain(t[n]).rangeBands(e[n]);else{var g=d3.scale[i.linear]();o[n]=g.domain(t[n]).range(e[n])}}),this.scales=o,this.raw=o,this}return t.prototype.get=function(r,t){return{x:this.scales.x(r),y:this.scales.y(t)}},t.prototype.domain=function(){return{x:this.scales.x.domain(),y:this.scales.y.domain()}},t.prototype.range=function(){return{x:this.scales.x.range(),y:this.scales.y.range()}},t}),e("core/stl",["require","exports","module","view/pane","view/components/axis","view/components/scale"],function(r){var t={};return t.pane=r("view/pane"),t.axis=r("view/components/axis"),t.scale=r("view/components/scale"),t}),e("core/extension",["underscore","core/stl","view/diagrams/diagrams"],function(r,t,e){var n={},i={};return n.load=function(n){if("undefined"!=typeof window[n]&&"undefined"!=typeof window[n].Nya){var o=window[n].Nya;r.each(["pane","scale","axis"],function(r){"undefined"==typeof o[r]&&(o[r]=t[r])}),"undefined"!=typeof o.diagrams&&r.each(o.diagrams,function(r,t){e.add(t,r)}),i[n]=o}},n.get=function(r){return i[r]},n}),e("utils/dataframe",["underscore"],function(r){function t(t,e){if(e instanceof String&&/url(.+)/g.test(e)){var n=e.match(/url\((.+)\)/)[1],i=this;d3.json(n,function(r,t){i.raw=JSON.parse(t)}),this.raw={}}else this.raw=e;var o=r.keys(e[0]),g=r.zip.apply(this,r.map(e,function(t){return r.toArray(t)})),a=r.filter(g,function(t){return r.all(t,function(t){return r.isArray(t)})});return this.nested=1==a.length?o[g.indexOf(a[0])]:!1,this.filters={},this}return t.prototype.row=function(r){return this.raw[r]},t.prototype.column=function(t){var e=[],n=this.raw;return r.each(n,function(r){e.push(r[t])}),e},t.prototype.scale=function(t,e){if(this.isContinuous(t)){var n=this.columnRange(t);return n=r.range(n.min,n.max+1,(n.max-n.min)/(e.length-1)),d3.scale.linear().domain(n).range(e)}return d3.scale.ordinal().domain(r.uniq(this.column(t))).range(e)},t.prototype.isContinuous=function(t){return r.every(this.column(t),function(t){return r.isNumber(t)})},t.prototype.addFilter=function(r,t,e){this.filters[r]={func:t,excepts:e}},t.prototype.columnWithFilters=function(t,e){var n=this.raw.concat();return r.each(this.filters,function(e,i){(-1==e.excepts.indexOf("self")||i!=t)&&(t in e.excepts||(n=r.filter(n,e.func)))}),r.map(n,function(r){return r[e]})},t.prototype.pickUpCells=function(t,e){var n=this.column(t);return r.map(e,function(r){return n[r]})},t.prototype.getPartialDf=function(t){return r.map(this.raw,function(e){return r.reduce(t,function(r,t){return r[t]=e[t],r},{})})},t.prototype.nested_column=function(r,e){if(!this.nested)throw"Recieved dataframe is not nested.";var n=new t("",this.row(r)[this.nested]);return n.column(e)},t.prototype.columnRange=function(r){var t=this.column(r);return{max:d3.max(t,function(r){return r}),min:d3.min(t,function(r){return r})}},t}),e("core/parse",["underscore","core/manager","core/extension","core/stl","utils/dataframe"],function(r,t,e,n,i){function o(t,n){var i=d3.select(n);"undefined"!=typeof t.extension&&(r.isArray(t.extension)?r.each(t.extension,function(r){e.load(r)}):e.load(t.extension)),g(t,i)}function g(o,g){r.each(o.data,function(r,e){t.addData(e,new i(e,r))}),r.each(o.panes,function(i){var o,a,b,s;if("undefined"!=typeof i.extension){var l=e.get(i.extension);a=l.pane,b=l.axis,s=l.scale}else a=n.pane,b=n.axis,s=n.scale;o=new a(g,s,b,i.options);var u=[];if(r.each(i.diagrams,function(r){o.addDiagram(r.type,r.data,r.options||{}),u.push(r.data)}),void 0!==i.filter){var c=i.filter;o.addFilter(c.type,c.options||{})}t.addPane({pane:o,data:u,uuid:o.uuid}),t.update(o.uuid)})}return o}),e("main",["require","exports","module","core/parse","core/stl","core/manager","node-uuid","underscore"],function(r){var t={};return t.core={},t.core.parse=r("core/parse"),t.STL=r("core/stl"),t.Manager=r("core/manager"),t.uuid=r("node-uuid"),t._=r("underscore"),t}),t("main")}); \ No newline at end of file diff --git a/src/view/diagrams/scatter.js b/src/view/diagrams/scatter.js index 12fa1e6..b7409e6 100644 --- a/src/view/diagrams/scatter.js +++ b/src/view/diagrams/scatter.js @@ -101,7 +101,7 @@ define([ var scale = df.scale(options[info.column], options[info.val]); columns.push(_.map(df.column(options[info.column]), function(val){return scale(val);})); }else{ - columns.push(_.map(_.range(1, length, 1), function(d){ + columns.push(_.map(_.range(1, length+1, 1), function(d){ if(_.isArray(options[info.val]))return options[info.val][0]; else return options[info.val]; })); diff --git a/src/view/diagrams/vectors.js b/src/view/diagrams/vectors.js index 7446f9c..5377fa1 100644 --- a/src/view/diagrams/vectors.js +++ b/src/view/diagrams/vectors.js @@ -92,7 +92,7 @@ define([ var scale = df.scale(options[info.column], options[info.val]); columns.push(_.map(df.column(options[info.column]), function(val){return scale(val);})); }else{ - columns.push(_.map(_.range(1, length, 1), function(d){ + columns.push(_.map(_.range(1, length+1, 1), function(d){ if(_.isArray(options[info.val]))return options[info.val][0]; else return options[info.val]; }));