diff --git a/dist/charting.css b/dist/charting.css index 85f8a432..b48dd185 100644 --- a/dist/charting.css +++ b/dist/charting.css @@ -1940,7 +1940,7 @@ body { .legendables .open-toggle:after { transform: rotate(45deg) scale(0.6); } .legendables .open-toggle:hover:before, .legendables .open-toggle:hover:after { - background: #22A7F0; } + background: #22a7f0; } .legendables.show-ticks .tick { display: block; } .legendables .tick { @@ -1963,14 +1963,22 @@ body { top: 8px; left: 8px; } .legendables .tick:hover:after { - border-color: #22A7F0; } + border-color: #22a7f0; } + .legendables .sort { + position: absolute; + right: 14px; + top: 4px; + fill: #a7a7a7; + cursor: pointer; } + .legendables .sort:hover { + fill: #22a7f0; } .legendables .header { color: #a7a7a7; font-weight: bold; margin: 0 4px 0 4px; position: relative; height: 24px; - padding-right: 24px; + padding-right: 32px; border-bottom: 1px solid #e2e2e2; } .legendables .title-text { text-overflow: ellipsis; @@ -1983,8 +1991,10 @@ body { border: none; } .legendables .legend:nth-child(2) .tick { right: 16px; } + .legendables .legend:nth-child(2) .sort { + right: 34px; } .legendables .legend:nth-child(2) .header { - padding-right: 36px; } + padding-right: 52px; } .legendables.nominal-legend { max-height: 50%; } .legendables.gradient-legend { @@ -2110,7 +2120,7 @@ body { .gradient-legend .range:hover .block:not(:hover) .extent { display: none; } .gradient-legend .range:hover .block:not(:hover) .color { - opacity: .4; } + opacity: 0.4; } .gradient-legend .block input { display: none; } .gradient-legend .block:hover .extent { diff --git a/dist/charting.js b/dist/charting.js index c3dcf4af..f7a67ab5 100644 --- a/dist/charting.js +++ b/dist/charting.js @@ -8031,7 +8031,6 @@ function lastFilteredSize(crossfilterId) { return _lastFilteredSize[crossfilterId]; } function setLastFilteredSize(crossfilterId, value) { - console.log("setLastFilteredSize", value); _lastFilteredSize[crossfilterId] = value; } function resetState() { @@ -11904,6 +11903,8 @@ function createParser() { function colorMixin(_chart) { var _colors = __WEBPACK_IMPORTED_MODULE_0_d3___default.a.scale.category20c(); var _defaultAccessor = true; + var _customDomain = []; + var _customRange = []; var _colorAccessor = function _colorAccessor(d) { return _chart.keyAccessor()(d); }; @@ -12047,7 +12048,24 @@ function colorMixin(_chart) { } var range = _chart.colors().range(); var middleColor = range[Math.floor(range.length / 2)]; - return _colors(_colorAccessor.call(this, data, index)) || middleColor; + var value = _colorAccessor.call(this, data, index); + var color = typeof value === "string" ? _chart.determineColorByValue(value, range) : _colors(_colorAccessor.call(this, data, index)) || middleColor; + var customColor = _chart.customRange().length > 0 ? _chart.customRange()[index] : null; + return customColor !== null && customColor !== void 0 ? customColor : color; + }; + _chart.customDomain = function (domain) { + if (!arguments.length) { + return _customDomain; + } + _customDomain = domain; + return _chart; + }; + _chart.customRange = function (range) { + if (!arguments.length) { + return _customRange; + } + _customRange = range; + return _chart; }; /** @@ -12065,6 +12083,28 @@ function colorMixin(_chart) { _chart.getColor = colorCalculator; return _chart; }; + var cyrb53 = function cyrb53(str) { + var seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + var h1 = 0xdeadbeef ^ seed; + var h2 = 0x41c6ce57 ^ seed; + for (var i = 0, ch; i < str.length; i++) { + ch = str.charCodeAt(i); + h1 = Math.imul(h1 ^ ch, 2654435761); + h2 = Math.imul(h2 ^ ch, 1597334677); + } + h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909); + h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909); + return 4294967296 * (2097151 & h2) + (h1 >>> 0); + }; + _chart.determineColorByValue = function (measureColor, colors) { + if (typeof measureColor === "string") { + var hash = cyrb53(measureColor); + var _colorIndex = hash % colors.length; + return colors[_colorIndex]; + } + var colorIndex = measureColor % colors.length; + return colors[colorIndex]; + }; return _chart; } @@ -60701,7 +60741,8 @@ var LatLonPolyLine = /*#__PURE__*/function (_Draw$PolyLine) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return LEGEND_POSITIONS; }); /* harmony export (immutable) */ __webpack_exports__["b"] = getLegendStateFromChart; -/* harmony export (immutable) */ __webpack_exports__["g"] = handleLegendToggle; +/* harmony export (immutable) */ __webpack_exports__["h"] = handleLegendToggle; +/* harmony export (immutable) */ __webpack_exports__["g"] = handleLegendSort; /* harmony export (immutable) */ __webpack_exports__["c"] = handleLegendDoneRender; /* harmony export (immutable) */ __webpack_exports__["f"] = handleLegendOpen; /* harmony export (immutable) */ __webpack_exports__["e"] = handleLegendLock; @@ -60742,6 +60783,7 @@ var LEGEND_POSITIONS = { TOP_RIGHT: "top-right", BOTTOM_LEFT: "bottom-left" }; +var OTHER_KEY = "Other"; var hasLegendOpenProp = function hasLegendOpenProp(color) { return _typeof(color.legend) === "object" && color.legend.hasOwnProperty("open"); }; @@ -60819,7 +60861,7 @@ function getTopValues(_x, _x2, _x3) { } function _getTopValues() { _getTopValues = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(layer, layerName, size) { - var _layer$crossfilter, _layer$getState3, _layer$getState3$enco, _layer$getState3$enco2, _layer$crossfilter2; + var _layer$crossfilter, _layer$getState4, _layer$getState4$enco, _layer$getState4$enco2, _layer$crossfilter2; var OFFSET, chartId, dimension, newCf; return _regeneratorRuntime().wrap(function _callee$(_context) { while (1) { @@ -60827,7 +60869,7 @@ function _getTopValues() { case 0: OFFSET = 0; chartId = layer === null || layer === void 0 ? void 0 : (_layer$crossfilter = layer.crossfilter()) === null || _layer$crossfilter === void 0 ? void 0 : _layer$crossfilter.chartId; - dimension = layer === null || layer === void 0 ? void 0 : (_layer$getState3 = layer.getState()) === null || _layer$getState3 === void 0 ? void 0 : (_layer$getState3$enco = _layer$getState3.encoding) === null || _layer$getState3$enco === void 0 ? void 0 : (_layer$getState3$enco2 = _layer$getState3$enco.color) === null || _layer$getState3$enco2 === void 0 ? void 0 : _layer$getState3$enco2.field; + dimension = layer === null || layer === void 0 ? void 0 : (_layer$getState4 = layer.getState()) === null || _layer$getState4 === void 0 ? void 0 : (_layer$getState4$enco = _layer$getState4.encoding) === null || _layer$getState4$enco === void 0 ? void 0 : (_layer$getState4$enco2 = _layer$getState4$enco.color) === null || _layer$getState4$enco2 === void 0 ? void 0 : _layer$getState4$enco2.field; newCf = layer === null || layer === void 0 ? void 0 : (_layer$crossfilter2 = layer.crossfilter()) === null || _layer$crossfilter2 === void 0 ? void 0 : _layer$crossfilter2.cloneWithChartId(chartId, layerName); if (!(chartId && dimension && newCf)) { _context.next = 8; @@ -60931,7 +60973,7 @@ function _getLegendStateFromChart() { color = layer.getState().encoding.color; color_legend_descriptor = null; if (!((layers.length > 1 || __WEBPACK_IMPORTED_MODULE_0_lodash__["isEqual"](selectedLayer, layerState)) && typeof color !== "undefined")) { - _context2.next = 38; + _context2.next = 39; break; } if (!(_typeof(color.scale) === "object" && color.scale.domain === "auto")) { @@ -60943,7 +60985,7 @@ function _getLegendStateFromChart() { domain: layer.colorDomain() }) }); - _context2.next = 36; + _context2.next = 37; break; case 21: if (!(typeof color.scale === "undefined" && color.domain === "auto")) { @@ -60953,11 +60995,11 @@ function _getLegendStateFromChart() { color_legend_descriptor = _objectSpread(_objectSpread({}, color), {}, { domain: layer.colorDomain() }); - _context2.next = 36; + _context2.next = 37; break; case 25: if (!(color.type === "ordinal")) { - _context2.next = 35; + _context2.next = 36; break; } _context2.next = 28; @@ -60971,24 +61013,30 @@ function _getLegendStateFromChart() { } else if (!color.hideOther) { color.otherActive = true; } + layer.setState(setColorState(function () { + return { + filteredDomain: newDomain, + filteredRange: newRange + }; + })); color_legend_descriptor = newDomain && newRange ? _objectSpread(_objectSpread({}, color), {}, { domain: newDomain, range: newRange }) : _objectSpread({}, color); - _context2.next = 36; + _context2.next = 37; break; - case 35: - color_legend_descriptor = _objectSpread({}, color); case 36: - _context2.next = 39; - break; - case 38: color_legend_descriptor = _objectSpread({}, color); + case 37: + _context2.next = 40; + break; case 39: + color_legend_descriptor = _objectSpread({}, color); + case 40: return _context2.abrupt("return", _objectSpread(_objectSpread({}, color_legend_descriptor), {}, { version: 1.0 })); - case 40: + case 41: case "end": return _context2.stop(); } @@ -61030,6 +61078,53 @@ function handleLegendToggle() { open: !this.legend().state.open })); } +function handleLegendSort() { + var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; + var legend = this.legend(); + var legendState = legend.state; + // handles stacked legend; only layer being sorted should be updated + var legendLayerState = legendState.list ? legendState.list[index] : null; + var layer = this.getLayers()[index]; + var _layer$getState = layer.getState(), + color = _layer$getState.encoding.color; + var domain = color.domain, + filteredDomain = color.filteredDomain, + range = color.range, + filteredRange = color.filteredRange, + sorted = color.sorted, + defaultOtherRange = color.defaultOtherRange, + otherActive = color.otherActive; + var currentDomain = filteredDomain !== null && filteredDomain !== void 0 ? filteredDomain : domain; + var currentRange = filteredRange !== null && filteredRange !== void 0 ? filteredRange : range; + var sortedDomain = currentDomain.filter(function (d) { + return d !== OTHER_KEY; + }).sort(function (a, b) { + return sorted === "asc" ? b.localeCompare(a) : a.localeCompare(b); + }); + color.sorted = sorted === "asc" ? "desc" : "asc"; + var _getUpdatedDomainRang = getUpdatedDomainRange(sortedDomain, currentDomain, currentRange, defaultOtherRange), + newDomain = _getUpdatedDomainRang.newDomain, + newRange = _getUpdatedDomainRang.newRange; + layer.setState(setColorState(function () { + return { + filteredDomain: newDomain, + filteredRange: newRange + }; + })); + if (otherActive) { + newDomain.push(OTHER_KEY); + newRange.push(defaultOtherRange); + } + if (legendLayerState) { + legendLayerState.domain = newDomain; + legendLayerState.range = newRange; + legendState.list[index] = legendLayerState; + } else { + legendState.domain = newDomain; + legendState.range = newRange; + } + this.legend().setState(legendState); +} function handleLegendDoneRender() { var _this2 = this; this.root().classed("horizontal-lasso-tools", function () { @@ -61052,22 +61147,22 @@ function handleLegendOpen() { }); } function handleLegendLock(_ref) { - var _layer$getState, - _layer$getState$encod, + var _layer$getState2, + _layer$getState2$enco, _this4 = this; var locked = _ref.locked, _ref$index = _ref.index, index = _ref$index === void 0 ? 0 : _ref$index; var layer = this.getLayers()[index]; - if (layer !== null && layer !== void 0 && (_layer$getState = layer.getState()) !== null && _layer$getState !== void 0 && (_layer$getState$encod = _layer$getState.encoding) !== null && _layer$getState$encod !== void 0 && _layer$getState$encod.color) { + if (layer !== null && layer !== void 0 && (_layer$getState2 = layer.getState()) !== null && _layer$getState2 !== void 0 && (_layer$getState2$enco = _layer$getState2.encoding) !== null && _layer$getState2$enco !== void 0 && _layer$getState2$enco.color) { var _color$scale; layer.setState(setLegendState(function (color) { return { locked: typeof locked === "undefined" ? true : !locked }; })); - var _layer$getState2 = layer.getState(), - color = _layer$getState2.encoding.color; + var _layer$getState3 = layer.getState(), + color = _layer$getState3.encoding.color; var redraw = false; if (_typeof(color.scale) === "object" && (color !== null && color !== void 0 && (_color$scale = color.scale) !== null && _color$scale !== void 0 && _color$scale.domain || typeof layer.colorDomain === "function")) { // this if or raster-layer-heatmap-mixin.js @@ -61131,10 +61226,10 @@ function isQuantitativeType(type_string) { // Taken from: https://github.com/mrblueblue/legendables/blob/master/src/legend.ts#L47 var commafy = function commafy(d) { - return Object(__WEBPACK_IMPORTED_MODULE_3_d3_format__["format"])(",")(parseFloat(d.toFixed(2))); + return Object(__WEBPACK_IMPORTED_MODULE_3_d3_format__["a" /* format */])(",")(parseFloat(d.toFixed(2))); }; var formatNumber = function formatNumber(d) { - return String(d).length > 4 ? Object(__WEBPACK_IMPORTED_MODULE_3_d3_format__["format"])(".2s")(d) : commafy(d); + return String(d).length > 4 ? Object(__WEBPACK_IMPORTED_MODULE_3_d3_format__["a" /* format */])(".2s")(d) : commafy(d); }; var color_literal_alpha_regex = /^\s*[a-z,A-Z]{3}[aA]\s*\([\d.]+,[\d.]+,[\d.]+,([\d.]+)\)$/i; @@ -61154,7 +61249,7 @@ function legendState_v1(state, useMap) { // 2. If the Other toggle is disabled, we don't include color swatch for the Other domain range: !state.hideOther && state.hasOwnProperty("showOther") && state.showOther && state.otherActive ? state.range.concat([state.defaultOtherRange]) // When Other is toggled OFF, don't show color swatch in legend : state.range, - domain: state.hideOther || !state.otherActive ? state.domain : state.domain.concat(["Other"]), + domain: state.hideOther || !state.otherActive ? state.domain : state.domain.concat([OTHER_KEY]), position: position }; } else if (state.type === "quantitative" && state.domain && isNullLegend(state.domain)) { @@ -61223,7 +61318,7 @@ function legendState_v2(state, useMap) { // For it's color swatch, we have two options: // 1. When the Other toggle is enabled, we show color swatch (color defined from color palette in chart editor) for the Other category range, // 2. If the Other toggle is disabled, we don't include color swatch for the Other domain - extra_domain.push("Other"); + extra_domain.push(OTHER_KEY); extra_range.push(state.defaultOtherRange); } else if (state.hasOwnProperty("default")) { var alpha_val = 1; @@ -61232,7 +61327,7 @@ function legendState_v2(state, useMap) { alpha_val = Number(match[1]); } if (alpha_val > 0) { - extra_domain.push("Other"); + extra_domain.push(OTHER_KEY); extra_range.push(state["default"]); } } @@ -61385,22 +61480,21 @@ function isNullLegend() { /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__defaultLocale_js__ = __webpack_require__(323); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "formatDefaultLocale", function() { return __WEBPACK_IMPORTED_MODULE_0__defaultLocale_js__["a"]; }); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "format", function() { return __WEBPACK_IMPORTED_MODULE_0__defaultLocale_js__["b"]; }); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "formatPrefix", function() { return __WEBPACK_IMPORTED_MODULE_0__defaultLocale_js__["c"]; }); +/* unused harmony reexport formatDefaultLocale */ +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __WEBPACK_IMPORTED_MODULE_0__defaultLocale_js__["a"]; }); +/* unused harmony reexport formatPrefix */ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__locale_js__ = __webpack_require__(225); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "formatLocale", function() { return __WEBPACK_IMPORTED_MODULE_1__locale_js__["a"]; }); +/* unused harmony reexport formatLocale */ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__formatSpecifier_js__ = __webpack_require__(226); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "formatSpecifier", function() { return __WEBPACK_IMPORTED_MODULE_2__formatSpecifier_js__["b"]; }); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "FormatSpecifier", function() { return __WEBPACK_IMPORTED_MODULE_2__formatSpecifier_js__["a"]; }); +/* unused harmony reexport formatSpecifier */ +/* unused harmony reexport FormatSpecifier */ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__precisionFixed_js__ = __webpack_require__(330); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "precisionFixed", function() { return __WEBPACK_IMPORTED_MODULE_3__precisionFixed_js__["a"]; }); +/* unused harmony reexport precisionFixed */ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__precisionPrefix_js__ = __webpack_require__(331); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "precisionPrefix", function() { return __WEBPACK_IMPORTED_MODULE_4__precisionPrefix_js__["a"]; }); +/* unused harmony reexport precisionPrefix */ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__precisionRound_js__ = __webpack_require__(332); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "precisionRound", function() { return __WEBPACK_IMPORTED_MODULE_5__precisionRound_js__["a"]; }); +/* unused harmony reexport precisionRound */ @@ -61445,7 +61539,7 @@ var map = Array.prototype.map, nan = locale.nan === undefined ? "NaN" : locale.nan + ""; function newFormat(specifier) { - specifier = Object(__WEBPACK_IMPORTED_MODULE_3__formatSpecifier_js__["b" /* default */])(specifier); + specifier = Object(__WEBPACK_IMPORTED_MODULE_3__formatSpecifier_js__["a" /* default */])(specifier); var fill = specifier.fill, align = specifier.align, @@ -61556,7 +61650,7 @@ var map = Array.prototype.map, } function formatPrefix(specifier, value) { - var f = newFormat((specifier = Object(__WEBPACK_IMPORTED_MODULE_3__formatSpecifier_js__["b" /* default */])(specifier), specifier.type = "f", specifier)), + var f = newFormat((specifier = Object(__WEBPACK_IMPORTED_MODULE_3__formatSpecifier_js__["a" /* default */])(specifier), specifier.type = "f", specifier)), e = Math.max(-8, Math.min(8, Math.floor(Object(__WEBPACK_IMPORTED_MODULE_0__exponent_js__["a" /* default */])(value) / 3))) * 3, k = Math.pow(10, -e), prefix = prefixes[8 + e / 3]; @@ -61577,8 +61671,8 @@ var map = Array.prototype.map, /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony export (immutable) */ __webpack_exports__["b"] = formatSpecifier; -/* harmony export (immutable) */ __webpack_exports__["a"] = FormatSpecifier; +/* harmony export (immutable) */ __webpack_exports__["a"] = formatSpecifier; +/* unused harmony export FormatSpecifier */ // [[fill]align][sign][symbol][0][width][,][.precision][~][type] var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; @@ -81834,9 +81928,34 @@ function bubbleChart(parent, chartGroup) { return __WEBPACK_IMPORTED_MODULE_0_d3___default.a.descending(radiusAccessor(a), radiusAccessor(b)); }); } + var domain = _chart.customDomain(); + var range = _chart.customRange(); + var filteredData = data; + if (domain.length === 0 && range.length === 0) { + var newDomain = data.map(function (d) { + return d.key0; + }); + var newRange = data.map(function (d, i) { + return _chart.getColor(d, i); + }); + _chart.customDomain(newDomain); + _chart.customRange(newRange); + } else if (domain.length > 0 && range.length === 0) { + filteredData = data.filter(function (d) { + return domain.includes(d.key0); + }); + var _newRange = filteredData.map(function (d, i) { + return _chart.getColor(d, i); + }); + _chart.customRange(_newRange); + } else if (domain.length > 0) { + filteredData = data.filter(function (d) { + return domain.includes(d.key0); + }); + } var bubbleG = _chart.chartBodyG().selectAll("g." + _chart.BUBBLE_NODE_CLASS) - /* OVERRIDE -----------------------------------------------------------------*/.data(data); + /* OVERRIDE -----------------------------------------------------------------*/.data(filteredData); /* --------------------------------------------------------------------------*/ if (_sortBubbleSize) { @@ -87942,9 +88061,17 @@ function pieChart(parent, chartGroup) { var pie = pieLayout(); var chartData = _chart.data(); var pieData; + if (_chart.customDomain().length > 0 && chartData) { + pieData = chartData.filter(function (d) { + return _chart.customDomain().includes(d.key0); + }); + } else if (chartData) { + pieData = chartData; + } + // if we have data... - if (chartData && __WEBPACK_IMPORTED_MODULE_3_d3___default.a.sum(chartData, _chart.valueAccessor())) { - pieData = pie(__WEBPACK_IMPORTED_MODULE_8__utils_utils__["l" /* utils */].maybeFormatInfinity(_chart.data())); + if (pieData && __WEBPACK_IMPORTED_MODULE_3_d3___default.a.sum(pieData, _chart.valueAccessor())) { + pieData = pie(__WEBPACK_IMPORTED_MODULE_8__utils_utils__["l" /* utils */].maybeFormatInfinity(pieData)); _g.classed(_emptyCssClass, false); } else { // otherwise we'd be getting NaNs, so override @@ -88139,9 +88266,39 @@ function pieChart(parent, chartGroup) { }); } function updateElements(pieData, arc) { - updateSlicePaths(pieData, arc); - updateLabels(pieData, arc); - updateTitles(pieData); + var domain = _chart.customDomain(); + var range = _chart.customRange(); + var filteredData = pieData; + + // if custom domain is empty, generate it from the pieData + if (domain.length === 0 && range.length === 0) { + var newDomain = pieData.map(function (d) { + return d.data.key0; + }); + var newRange = pieData.map(function (d, i) { + return _chart.getColor(d.data, i); + }); + _chart.customDomain(newDomain); + _chart.customRange(newRange); + } else if (domain.length > 0 && range.length === 0) { + // if we have a domain but no range, palette was changed + // filter feched data and set new range + filteredData = pieData.filter(function (d) { + return domain.includes(d.data.key0); + }); + var _newRange = filteredData.map(function (d, i) { + return _chart.getColor(d.data, i); + }); + _chart.customRange(_newRange); + } else if (domain.length > 0) { + // if we have custom domain and range, filter fetched data + filteredData = pieData.filter(function (d) { + return domain.includes(d.data.key0); + }); + } + updateSlicePaths(filteredData, arc); + updateLabels(filteredData, arc); + updateTitles(filteredData); } function updateSlicePaths(pieData, arc) { var slicePaths = _g.selectAll("g." + _sliceCssClass).data(pieData).classed("all-others", function (d) { @@ -89279,7 +89436,6 @@ function numberChart(parent, chartGroup) { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__mixins_base_mixin__ = __webpack_require__(8); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__mixins_scatter_mixin__ = __webpack_require__(237); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_legendables__ = __webpack_require__(353); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_legendables___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_legendables__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_lodash__ = __webpack_require__(31); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7_lodash__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__constants_paused__ = __webpack_require__(369); @@ -89623,10 +89779,7 @@ function rasterChart(parent, useMap, chartGroup, _mapboxgl) { _chart._getPixelRatio = function () { return _pixelRatio; }; - - // why is this different from the other setsample? _chart.setSample = function () { - console.log("raster-chart setSample"); _layers.forEach(function (layerName) { var layer = _layerNames[layerName]; if (layer && typeof layer.setSample === "function") { @@ -90092,11 +90245,12 @@ function rasterChart(parent, useMap, chartGroup, _mapboxgl) { }; var anchored = _chart.anchor(parent, chartGroup); var legend = anchored.root().append("div").attr("class", "legend"); - _legend = new __WEBPACK_IMPORTED_MODULE_6_legendables__["Legend"](legend.node()); + _legend = new __WEBPACK_IMPORTED_MODULE_6_legendables__["a" /* Legend */](legend.node()); _legend.on("open", __WEBPACK_IMPORTED_MODULE_1__chart_addons_stacked_legend__["f" /* handleLegendOpen */].bind(_chart)); _legend.on("lock", __WEBPACK_IMPORTED_MODULE_1__chart_addons_stacked_legend__["e" /* handleLegendLock */].bind(_chart)); _legend.on("input", __WEBPACK_IMPORTED_MODULE_1__chart_addons_stacked_legend__["d" /* handleLegendInput */].bind(_chart)); - _legend.on("toggle", __WEBPACK_IMPORTED_MODULE_1__chart_addons_stacked_legend__["g" /* handleLegendToggle */].bind(_chart)); + _legend.on("toggle", __WEBPACK_IMPORTED_MODULE_1__chart_addons_stacked_legend__["h" /* handleLegendToggle */].bind(_chart)); + _legend.on("sort", __WEBPACK_IMPORTED_MODULE_1__chart_addons_stacked_legend__["g" /* handleLegendSort */].bind(_chart)); _legend.on("doneRender", __WEBPACK_IMPORTED_MODULE_1__chart_addons_stacked_legend__["c" /* handleLegendDoneRender */].bind(_chart)); _legend.on("doneRender", function (state) { // Sometimes the legend gets disconnected from the DOM? @@ -90499,9 +90653,9 @@ function stringify (gj) { /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return format; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return formatPrefix; }); -/* harmony export (immutable) */ __webpack_exports__["a"] = defaultLocale; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return format; }); +/* unused harmony export formatPrefix */ +/* unused harmony export default */ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__locale_js__ = __webpack_require__(225); @@ -90648,7 +90802,7 @@ function defaultLocale(definition) { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__exponent_js__ = __webpack_require__(43); -/* harmony default export */ __webpack_exports__["a"] = (function(step) { +/* unused harmony default export */ var _unused_webpack_default_export = (function(step) { return Math.max(0, -Object(__WEBPACK_IMPORTED_MODULE_0__exponent_js__["a" /* default */])(Math.abs(step))); }); @@ -90661,7 +90815,7 @@ function defaultLocale(definition) { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__exponent_js__ = __webpack_require__(43); -/* harmony default export */ __webpack_exports__["a"] = (function(step, value) { +/* unused harmony default export */ var _unused_webpack_default_export = (function(step, value) { return Math.max(0, Math.max(-8, Math.min(8, Math.floor(Object(__WEBPACK_IMPORTED_MODULE_0__exponent_js__["a" /* default */])(value) / 3))) * 3 - Object(__WEBPACK_IMPORTED_MODULE_0__exponent_js__["a" /* default */])(Math.abs(step))); }); @@ -90674,7 +90828,7 @@ function defaultLocale(definition) { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__exponent_js__ = __webpack_require__(43); -/* harmony default export */ __webpack_exports__["a"] = (function(step, max) { +/* unused harmony default export */ var _unused_webpack_default_export = (function(step, max) { step = Math.abs(step), max = Math.abs(max) - step; return Math.max(0, Object(__WEBPACK_IMPORTED_MODULE_0__exponent_js__["a" /* default */])(max) - Object(__WEBPACK_IMPORTED_MODULE_0__exponent_js__["a" /* default */])(step)) + 1; }); @@ -92610,44 +92764,61 @@ module.exports = function spread(callback) { /***/ }), /* 353 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_legend__ = __webpack_require__(354); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __WEBPACK_IMPORTED_MODULE_0__src_legend__["a"]; }); -Object.defineProperty(exports, "__esModule", { value: true }); -var legend_1 = __webpack_require__(354); -exports.Legend = legend_1.default; //# sourceMappingURL=index.js.map /***/ }), /* 354 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; +/* unused harmony export renderGradientLegend */ +/* unused harmony export renderNominalLegend */ +/* unused harmony export renderStackedLegend */ +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_snabbdom_h__ = __webpack_require__(355); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_snabbdom_h__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__vdom__ = __webpack_require__(358); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_d3_dispatch__ = __webpack_require__(367); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_d3_format__ = __webpack_require__(224); +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; -var __assign = (this && this.__assign) || Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; + + + +var commafy = function (d) { + return typeof d === "number" ? Object(__WEBPACK_IMPORTED_MODULE_3_d3_format__["a" /* format */])(",")(parseFloat(d.toFixed(2))) : d; }; -Object.defineProperty(exports, "__esModule", { value: true }); -var h_1 = __webpack_require__(355); -var vdom_1 = __webpack_require__(358); -var d3_dispatch_1 = __webpack_require__(367); -var d3_format_1 = __webpack_require__(224); -var commafy = function (d) { return typeof d === "number" ? d3_format_1.format(",")(parseFloat(d.toFixed(2))) : d; }; var formatNumber = function (d) { if (String(d).length <= 4) { return commafy(d); } else if (d < 0.0001) { - return d3_format_1.format(".2")(d); + return Object(__WEBPACK_IMPORTED_MODULE_3_d3_format__["a" /* format */])(".2")(d); } else { - return d3_format_1.format(".2s")(d); + return Object(__WEBPACK_IMPORTED_MODULE_3_d3_format__["a" /* format */])(".2s")(d); } }; function rangeStep(domain, index, bins) { @@ -92673,11 +92844,13 @@ function validateNumericalInput(previousValue, nextValue) { } function renderTickIcon(state, dispatch) { var _this = this; - return h_1.default("div.tick", { on: { click: function () { return dispatch.call("open", _this, state.index); } } }); + return __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.tick", { + on: { click: function () { return dispatch.call("open", _this, state.index); } } + }); } function renderToggleIcon(state, dispatch) { var _this = this; - return h_1.default("div.open-toggle", { + return __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.open-toggle", { on: { click: function () { dispatch.call("toggle", _this, state); @@ -92687,10 +92860,10 @@ function renderToggleIcon(state, dispatch) { } function renderLockIcon(locked, index, dispatch) { var _this = this; - return h_1.default("div.lock" + (locked ? ".locked" : ".unlocked"), { on: { click: function () { return dispatch.call("lock", _this, { locked: locked, index: index }); } } }, [ - h_1.default("svg", { attrs: { viewBox: [0, 0, 48, 48] } }, [ - h_1.default("g", { style: { stroke: "white" } }, [ - h_1.default("path", { + return __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.lock" + (locked ? ".locked" : ".unlocked"), { on: { click: function () { return dispatch.call("lock", _this, { locked: locked, index: index }); } } }, [ + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("svg", { attrs: { viewBox: [0, 0, 48, 48] } }, [ + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("g", { style: { stroke: "white" } }, [ + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("path", { attrs: { d: locked ? "M34,20v-4c0-5.5-4.5-10-10-10c-5.5,0-10,4.5-10,10v4H8v20h32V20H34z M18,16c0-3.3,2.7-6,6-6s6,2.7,6,6v4H18V16z" @@ -92701,9 +92874,46 @@ function renderLockIcon(locked, index, dispatch) { ]) ]); } +function renderSortIcon(state, dispatch) { + var _this = this; + return __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.sort", { + on: { click: function () { return dispatch.call("sort", _this, state.index); } } + }, [ + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("svg", { + attrs: { + width: 22, + height: 10, + viewBox: "0 0 22 12", + class: "sort-icon" + } + }, [ + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("svg", { + attrs: { + viewBox: "0 0 512 512", + xmlns: "http://www.w3.org/2000/svg" + } + }, [ + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("g", {}, [ + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("g", {}, [ + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("path", { + attrs: { + d: "M261.294,326.102c-8.3-7.3-21.8-6.2-29.1,2.1l-77,86.8v-346.9c0-11.4-9.4-20.8-20.8-20.8s-20.8,9.4-20.8,20.8v346.9l-77-86.8c-8.3-8.3-20.8-9.4-29.1-2.1c-8.3,8.3-9.4,20.8-2.1,29.1l113.4,126.9c8.5,10.5,23.5,8.9,30.2,0l114.4-126.9C270.694,347.002,269.694,333.402,261.294,326.102z" + } + }), + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("path", { + attrs: { + d: "M483.994,134.702l-112.4-126.9c-10-10.1-22.5-10.7-31.2,0l-114.4,126.9c-7.3,8.3-6.2,21.8,2.1,29.1c12.8,10.2,25.7,3.2,29.1-2.1l77-86.8v345.9c0,11.4,9.4,20.8,20.8,20.8s20.8-8.3,20.8-19.8v-346.8l77,86.8c8.3,8.3,20.8,9.4,29.1,2.1C490.194,155.502,491.294,143.002,483.994,134.702z" + } + }) + ]) + ]) + ]) + ]) + ]); +} function renderInput(state, domain, dispatch) { var _this = this; - return h_1.default("input", { + return __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("input", { hook: { update: function (prevNode, nextNode) { nextNode.elm.value = domain.value; @@ -92734,61 +92944,78 @@ function renderInput(state, domain, dispatch) { } function renderGradientLegend(state, dispatch) { var stacked = typeof state.index === "number"; - return h_1.default("div.legend.gradient-legend" + (stacked ? ".with-header" : ".legendables") + (state.open ? ".open" : ".collapsed") + (state.position ? "." + state.position : ""), [ - stacked ? - h_1.default("div.header", [h_1.default("div.title-text", state.title), renderTickIcon(state, dispatch)]) : h_1.default("div"), + return __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.legend.gradient-legend" + (stacked ? ".with-header" : ".legendables") + (state.open ? ".open" : ".collapsed") + (state.position ? "." + state.position : ""), [ + stacked + ? __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.header", [ + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.title-text", state.title), + renderTickIcon(state, dispatch) + ]) + : __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div"), state.open - ? h_1.default("div.range", state.range.map(function (color, index) { + ? __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.range", __spreadArrays(state.range.map(function (color, index) { var isMinMax = index === 0 || index === state.range.length - 1; - var step = Array.isArray(state.domain) ? formatNumber(rangeStep(state.domain, index, state.range.length)) : null; - var domain = Array.isArray(state.domain) ? state.domain : [null, null]; + var step = Array.isArray(state.domain) + ? formatNumber(rangeStep(state.domain, index, state.range.length)) + : null; + var domain = Array.isArray(state.domain) + ? state.domain + : [null, null]; var min = domain[0], max = domain[1]; - return h_1.default("div.block", [ - h_1.default("div.color", { style: { background: color } }), - h_1.default("div.text." + (isMinMax ? "extent" : "step"), [h_1.default("span", "" + (domain.length > 2 ? domain[index] : step))].concat(isMinMax + return __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.block", [ + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.color", { style: { background: color } }), + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.text." + (isMinMax ? "extent" : "step"), [ + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("span", "" + (domain.length > 2 ? domain[index] : step)) + ].concat(isMinMax ? [ - renderInput(state, { value: domain.length === 2 ? domain[index === 0 ? 0 : 1] : domain[index], index: index }, dispatch) + renderInput(state, { + value: domain.length === 2 + ? domain[index === 0 ? 0 : 1] + : domain[index], + index: index + }, dispatch) ] : [])) ]); - }).slice()) - : h_1.default("div"), - state.open ? - renderLockIcon(state.locked, state.index, dispatch) : h_1.default("div") + }))) + : __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div"), + state.open + ? renderLockIcon(state.locked, state.index, dispatch) + : __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div") ]); } -exports.renderGradientLegend = renderGradientLegend; function renderNominalLegend(state, dispatch) { var _this = this; var stacked = typeof state.index === "number"; - return h_1.default("div.legend.nominal-legend" + (stacked ? "" : ".legendables") + (state.open ? ".open" : ".collapsed") + (state.position ? "." + state.position : ""), [ - !stacked ? renderToggleIcon(state, dispatch) : h_1.default("div"), + return __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.legend.nominal-legend" + (stacked ? "" : ".legendables") + (state.open ? ".open" : ".collapsed") + (state.position ? "." + state.position : ""), [ + !stacked ? renderToggleIcon(state, dispatch) : __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div"), state.title && - h_1.default("div.header", [h_1.default("div.title-text", state.title), renderTickIcon(state, dispatch)]), + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.header", [ + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.title-text", state.title), + renderSortIcon(state, dispatch), + renderTickIcon(state, dispatch) + ]), state.open - ? h_1.default("div.body", state.domain.map(function (value, index) { - return h_1.default("div.legend-row", { on: { click: function () { return dispatch.call("filter", _this, value); } } }, [ - h_1.default("div.color", { + ? __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.body", state.domain.map(function (value, index) { + return __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.legend-row", { on: { click: function () { return dispatch.call("filter", _this, value); } } }, [ + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.color", { style: { background: state.range[index] } }), - h_1.default("div.text", "" + value) + __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.text", "" + value) ]); })) - : h_1.default("div") + : __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div") ]); } -exports.renderNominalLegend = renderNominalLegend; function renderStackedLegend(state, dispatch) { - return h_1.default("div.legendables" + (state.open ? ".open" : ".collapsed") + (state.list.length > 1 ? ".show-ticks" : ""), { style: { maxHeight: state.maxHeight + "px" } }, [renderToggleIcon(state, dispatch)].concat(state.list.map(function (legend, index) { + return __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div.legendables" + (state.open ? ".open" : ".collapsed") + (state.list.length > 1 ? ".show-ticks" : ""), { style: { maxHeight: state.maxHeight + "px" } }, [renderToggleIcon(state, dispatch)].concat(state.list.map(function (legend, index) { if (legend.type === "gradient") { - return renderGradientLegend(__assign({}, legend, { index: index }), dispatch); + return renderGradientLegend(__assign(__assign({}, legend), { index: index }), dispatch); } else if (legend.type === "nominal") { - return renderNominalLegend(__assign({}, legend, { index: index }), dispatch); + return renderNominalLegend(__assign(__assign({}, legend), { index: index }), dispatch); } }))); } -exports.renderStackedLegend = renderStackedLegend; var Legend = /** @class */ (function () { function Legend(node) { var _this = this; @@ -92810,14 +93037,14 @@ var Legend = /** @class */ (function () { vnode = renderStackedLegend(_this.state, _this.dispatch); } else { - vnode = h_1.default("div"); + vnode = __WEBPACK_IMPORTED_MODULE_0_snabbdom_h___default()("div"); } - _this.node = vdom_1.patch(_this.node, vnode); + _this.node = Object(__WEBPACK_IMPORTED_MODULE_1__vdom__["a" /* patch */])(_this.node, vnode); _this.dispatch.call("doneRender", _this, state); return _this.node; }; this.node = node; - this.dispatch = d3_dispatch_1.dispatch("filter", "input", "open", "lock", "toggle", "doneRender"); + this.dispatch = Object(__WEBPACK_IMPORTED_MODULE_2_d3_dispatch__["a" /* dispatch */])("filter", "input", "open", "lock", "toggle", "doneRender", "sort"); this.state = null; } Legend.prototype.on = function (event, callback) { @@ -92825,7 +93052,7 @@ var Legend = /** @class */ (function () { }; return Legend; }()); -exports.default = Legend; +/* harmony default export */ __webpack_exports__["a"] = (Legend); //# sourceMappingURL=legend.js.map /***/ }), @@ -92925,23 +93152,33 @@ exports.primitive = primitive; /***/ }), /* 358 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return patch; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_snabbdom__ = __webpack_require__(359); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_snabbdom_modules_attributes__ = __webpack_require__(362); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_snabbdom_modules_attributes___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_snabbdom_modules_attributes__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_snabbdom_modules_class__ = __webpack_require__(363); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_snabbdom_modules_class___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_snabbdom_modules_class__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_snabbdom_modules_props__ = __webpack_require__(364); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_snabbdom_modules_props___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_snabbdom_modules_props__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_snabbdom_modules_style__ = __webpack_require__(365); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_snabbdom_modules_style___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_snabbdom_modules_style__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_snabbdom_modules_eventlisteners__ = __webpack_require__(366); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_snabbdom_modules_eventlisteners___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_snabbdom_modules_eventlisteners__); -Object.defineProperty(exports, "__esModule", { value: true }); -var snabbdom_1 = __webpack_require__(359); -var attributes_1 = __webpack_require__(362); -var class_1 = __webpack_require__(363); -var props_1 = __webpack_require__(364); -var style_1 = __webpack_require__(365); -var eventlisteners_1 = __webpack_require__(366); -exports.patch = snabbdom_1.init([ - class_1.default, - props_1.default, - style_1.default, - attributes_1.default, - eventlisteners_1.default + + + + + +var patch = Object(__WEBPACK_IMPORTED_MODULE_0_snabbdom__["a" /* init */])([ + __WEBPACK_IMPORTED_MODULE_2_snabbdom_modules_class___default.a, + __WEBPACK_IMPORTED_MODULE_3_snabbdom_modules_props___default.a, + __WEBPACK_IMPORTED_MODULE_4_snabbdom_modules_style___default.a, + __WEBPACK_IMPORTED_MODULE_1_snabbdom_modules_attributes___default.a, + __WEBPACK_IMPORTED_MODULE_5_snabbdom_modules_eventlisteners___default.a ]); //# sourceMappingURL=vdom.js.map @@ -92950,15 +93187,14 @@ exports.patch = snabbdom_1.init([ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony export (immutable) */ __webpack_exports__["init"] = init; +/* harmony export (immutable) */ __webpack_exports__["a"] = init; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__vnode__ = __webpack_require__(238); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is__ = __webpack_require__(239); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__htmldomapi__ = __webpack_require__(360); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__h__ = __webpack_require__(240); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return __WEBPACK_IMPORTED_MODULE_3__h__["a"]; }); +/* unused harmony reexport h */ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__thunk__ = __webpack_require__(361); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "thunk", function() { return __WEBPACK_IMPORTED_MODULE_4__thunk__["a"]; }); +/* unused harmony reexport thunk */ @@ -93340,7 +93576,7 @@ var htmlDomApi = { /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return thunk; }); +/* unused harmony export thunk */ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__h__ = __webpack_require__(240); function copyToThunk(vnode, thunk) { @@ -93719,9 +93955,8 @@ exports.default = exports.eventListenersModule; /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dispatch_js__ = __webpack_require__(368); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "dispatch", function() { return __WEBPACK_IMPORTED_MODULE_0__dispatch_js__["a"]; }); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __WEBPACK_IMPORTED_MODULE_0__dispatch_js__["a"]; }); @@ -102605,10 +102840,9 @@ function rasterMixin(_chart) { return _chart; }; _chart.setSample = function () { - console.log("raster-mixin setSample"); if (_sampling) { var id = _chart.dimension().getCrossfilterId(); - var filterSize = Object(__WEBPACK_IMPORTED_MODULE_1__core_core_async__["g" /* lastFilteredSize */])(id); // TODO does this need to be replaced... + var filterSize = Object(__WEBPACK_IMPORTED_MODULE_1__core_core_async__["g" /* lastFilteredSize */])(id); if (filterSize == undefined) { _chart.dimension().samplingRatio(null); } else { diff --git a/src/charts/bubble-chart.js b/src/charts/bubble-chart.js index 37924600..69572d9d 100644 --- a/src/charts/bubble-chart.js +++ b/src/charts/bubble-chart.js @@ -464,12 +464,30 @@ export default function bubbleChart(parent, chartGroup) { const radiusAccessor = _chart.radiusValueAccessor() data.sort((a, b) => d3.descending(radiusAccessor(a), radiusAccessor(b))) } + + const domain = _chart.customDomain() + const range = _chart.customRange() + let filteredData = data + + if (domain.length === 0 && range.length === 0) { + const newDomain = data.map(d => d.key0) + const newRange = data.map((d, i) => _chart.getColor(d, i)) + _chart.customDomain(newDomain) + _chart.customRange(newRange) + } else if (domain.length > 0 && range.length === 0) { + filteredData = data.filter(d => domain.includes(d.key0)) + const newRange = filteredData.map((d, i) => _chart.getColor(d, i)) + _chart.customRange(newRange) + } else if (domain.length > 0) { + filteredData = data.filter(d => domain.includes(d.key0)) + } + const bubbleG = _chart .chartBodyG() .selectAll("g." + _chart.BUBBLE_NODE_CLASS) /* OVERRIDE -----------------------------------------------------------------*/ - .data(data) + .data(filteredData) /* --------------------------------------------------------------------------*/ if (_sortBubbleSize) { diff --git a/src/charts/pie-chart.js b/src/charts/pie-chart.js index 520f04f0..91bc99f4 100644 --- a/src/charts/pie-chart.js +++ b/src/charts/pie-chart.js @@ -182,9 +182,15 @@ export default function pieChart(parent, chartGroup) { const chartData = _chart.data() let pieData + if (_chart.customDomain().length > 0 && chartData) { + pieData = chartData.filter(d => _chart.customDomain().includes(d.key0)) + } else if (chartData) { + pieData = chartData + } + // if we have data... - if (chartData && d3.sum(chartData, _chart.valueAccessor())) { - pieData = pie(utils.maybeFormatInfinity(_chart.data())) + if (pieData && d3.sum(pieData, _chart.valueAccessor())) { + pieData = pie(utils.maybeFormatInfinity(pieData)) _g.classed(_emptyCssClass, false) } else { // otherwise we'd be getting NaNs, so override @@ -464,9 +470,31 @@ export default function pieChart(parent, chartGroup) { } function updateElements(pieData, arc) { - updateSlicePaths(pieData, arc) - updateLabels(pieData, arc) - updateTitles(pieData) + const domain = _chart.customDomain() + const range = _chart.customRange() + + let filteredData = pieData + + // if custom domain is empty, generate it from the pieData + if (domain.length === 0 && range.length === 0) { + const newDomain = pieData.map(d => d.data.key0) + const newRange = pieData.map((d, i) => _chart.getColor(d.data, i)) + _chart.customDomain(newDomain) + _chart.customRange(newRange) + } else if (domain.length > 0 && range.length === 0) { + // if we have a domain but no range, palette was changed + // filter feched data and set new range + filteredData = pieData.filter(d => domain.includes(d.data.key0)) + const newRange = filteredData.map((d, i) => _chart.getColor(d.data, i)) + _chart.customRange(newRange) + } else if (domain.length > 0) { + // if we have custom domain and range, filter fetched data + filteredData = pieData.filter(d => domain.includes(d.data.key0)) + } + + updateSlicePaths(filteredData, arc) + updateLabels(filteredData, arc) + updateTitles(filteredData) } function updateSlicePaths(pieData, arc) { diff --git a/src/mixins/color-mixin.js b/src/mixins/color-mixin.js index f4084feb..70927bd2 100644 --- a/src/mixins/color-mixin.js +++ b/src/mixins/color-mixin.js @@ -12,6 +12,8 @@ import d3 from "d3" export default function colorMixin(_chart) { let _colors = d3.scale.category20c() let _defaultAccessor = true + let _customDomain = [] + let _customRange = [] let _colorAccessor = function(d) { return _chart.keyAccessor()(d) @@ -168,9 +170,31 @@ export default function colorMixin(_chart) { const value = _colorAccessor.call(this, data, index) - return typeof value === "string" - ? _chart.determineColorByValue(value, range) - : _colors(_colorAccessor.call(this, data, index)) || middleColor + const color = + typeof value === "string" + ? _chart.determineColorByValue(value, range) + : _colors(_colorAccessor.call(this, data, index)) || middleColor + + const customColor = + _chart.customRange().length > 0 ? _chart.customRange()[index] : null + + return customColor ?? color + } + + _chart.customDomain = function(domain) { + if (!arguments.length) { + return _customDomain + } + _customDomain = domain + return _chart + } + + _chart.customRange = function(range) { + if (!arguments.length) { + return _customRange + } + _customRange = range + return _chart } /**