(function() { var callWithJQuery; callWithJQuery = function(pivotModule) { if (typeof exports === "object" && typeof module === "object") { return pivotModule(require("jquery"), require("plotly.js")); } else if (typeof define === "function" && define.amd) { return define(["jquery", "plotly.js"], pivotModule); } else { return pivotModule(jQuery, Plotly); } }; callWithJQuery(function($, Plotly) { var makePlotlyChart, makePlotlyScatterChart; makePlotlyChart = function(traceOptions, layoutOptions, transpose) { if (traceOptions == null) { traceOptions = {}; } if (layoutOptions == null) { layoutOptions = {}; } if (transpose == null) { transpose = false; } return function(pivotData, opts) { var colKeys, data, datumKeys, defaults, fullAggName, groupByTitle, hAxisTitle, layout, result, rowKeys, titleText, traceKeys; defaults = { localeStrings: { vs: "vs", by: "by" }, plotly: {} }; opts = $.extend(true, {}, defaults, opts); rowKeys = pivotData.getRowKeys(); colKeys = pivotData.getColKeys(); traceKeys = transpose ? colKeys : rowKeys; if (traceKeys.length === 0) { traceKeys.push([]); } datumKeys = transpose ? rowKeys : colKeys; if (datumKeys.length === 0) { datumKeys.push([]); } fullAggName = pivotData.aggregatorName; if (pivotData.valAttrs.length) { fullAggName += "(" + (pivotData.valAttrs.join(", ")) + ")"; } data = traceKeys.map(function(traceKey) { var datumKey, i, labels, len, trace, val, values; values = []; labels = []; for (i = 0, len = datumKeys.length; i < len; i++) { datumKey = datumKeys[i]; val = parseFloat(pivotData.getAggregator(transpose ? datumKey : traceKey, transpose ? traceKey : datumKey).value()); values.push(isFinite(val) ? val : null); labels.push(datumKey.join('-') || ' '); } trace = { name: traceKey.join('-') || fullAggName }; trace.x = transpose ? values : labels; trace.y = transpose ? labels : values; return $.extend(trace, traceOptions); }); if (transpose) { hAxisTitle = pivotData.rowAttrs.join("-"); groupByTitle = pivotData.colAttrs.join("-"); } else { hAxisTitle = pivotData.colAttrs.join("-"); groupByTitle = pivotData.rowAttrs.join("-"); } titleText = fullAggName; if (hAxisTitle !== "") { titleText += " " + opts.localeStrings.vs + " " + hAxisTitle; } if (groupByTitle !== "") { titleText += " " + opts.localeStrings.by + " " + groupByTitle; } layout = { title: titleText, hovermode: 'closest', width: window.innerWidth / 1.4, height: window.innerHeight / 1.4 - 50, xaxis: { title: transpose ? fullAggName : null, automargin: true }, yaxis: { title: transpose ? null : fullAggName, automargin: true } }; result = $("