mirror of
https://github.com/statbate/layout.git
synced 2026-08-11 03:12:42 +00:00
1 line
107 KiB
JavaScript
1 line
107 KiB
JavaScript
|
|
!function(t,e){"function"==typeof define&&define.amd?define(["d3"],e):"object"==typeof exports?module.exports=e(require("d3")):t.MG=e(t.d3)}(this,function(E){"use strict";var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};function k(){return"undefined"!=typeof jQuery||"undefined"!=typeof $}function i(t,e){return t[e.x_accessor]>=e.processed.min_x&&t[e.x_accessor]<=e.processed.max_x&&t[e.y_accessor]>=e.processed.min_y&&t[e.y_accessor]<=e.processed.max_y}function u(t){return"[object Array]"===Object.prototype.toString.call(t)}function a(t){var e=t.map(function(t){return!0===u(t)&&0<t.length});return E.sum(e)===t.length}function n(t){var e=t.map(function(t){return!0==(e=t,"[object Object]"===Object.prototype.toString.call(e));var e});return E.sum(e)===t.length}function e(t){return u(e=t)&&0===e.length||n(t);var e}function w(t){return t.height-t.bottom}function v(t){return w(t)-t.buffer}function M(t){return t.top}function b(t){return M(t)+t.buffer}function G(t){return t.left}function Y(t){return G(t)+t.buffer}function A(t){return t.width-t.right}function P(t){return A(t)-t.buffer}function _(t){t.exit().remove()}function D(t,e){t.selectAll(e).remove()}function S(t,e){return t.append("g").classed(e,!0)}function r(t,e){var r=O(t.target),a=h(t.data),n=r.selectAll("line."+e).data(a);return n.enter().append("line").attr("class",e).attr("opacity",.3),_(n),_(n),n}function m(t,e,r){e.color_accessor?(t.attr("stroke",e.scalefns.colorf),t.classed(r,!1)):(t.attr("stroke",null),t.classed(r,!0))}function l(t,e){e&&t.attr({dy:0,transform:function(){var t=E.select(this);return"rotate("+e+" "+t.attr("x")+","+t.attr("y")+")"}})}function g(t){if(!(t=t.node()))return!1;for(var e=0;e<t.length;e++)if(o(t[e],t))return!0;return!1}function o(t,e){for(var r=t.getBoundingClientRect(),a=0;a<e.length;a++)if(e[a]!=t){var n=e[a].getBoundingClientRect();if(r.top===n.top&&!(n.left>r.right||n.right<r.left))return!0}return!1}function s(t,e){var r=h(t.data);return"string"==typeof(r=r[0][t[e+"_accessor"]])?"categorical":"numerical"}function O(t){return E.select(t).select("svg")}function h(t){var e=[];return e.concat.apply(e,t)}function z(t){if("string"==typeof t)return F(t);if(t instanceof window.HTMLElement){var e=t.getAttribute("data-mg-uid");return e||(void 0===MG._next_elem_id&&(MG._next_elem_id=0),e="mg-"+MG._next_elem_id++,t.setAttribute("data-mg-uid",e)),e}return console.warn("The specified target should be a string or an HTMLElement.",t),F(t)}function F(t){return t.replace(/[^a-zA-Z0-9 _-]+/g,"").replace(/ +?/g,"")}function d(t,e){return Number(E.select(t).style(e).replace(/px/g,""))}function f(t){return d(t,"width")}("undefined"==typeof window?global:window).MG={version:"2.11"},MG.convert={},MG.convert.date=function(t,e,r){r=void 0===r?"%Y-%m-%d":r;var a=E.timeParse(r);return t=t.map(function(t){return t[e]=a(t[e].trim()),t})},MG.convert.number=function(t,e){return t=t.map(function(t){return t[e]=Number(t[e]),t})},MG.time_format=function(t,e){return t?E.utcFormat(e):E.timeFormat(e)};var t=function(t,e,r){var a={};if(null===t)return t;if(Array.prototype.forEach&&t.forEach===Array.prototype.forEach)t.forEach(e,r);else if(t.length===+t.length){for(var n=0,o=t.length;n<o;n++)if(e.call(r,t[n],n,t)===a)return}else for(var i in t)if(e.call(r,t[i],i,t)===a)return;return t};function p(r){return t(Array.prototype.slice.call(arguments,1),function(t){if(t)for(var e in t)void 0===r[e]&&(r[e]=t[e])}),r}function x(t){return"[object Date]"===Object.prototype.toString.call(t)}function y(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)}function C(t){return"[object Function]"===Object.prototype.toString.call(t)}function T(t,e){var r,a=[],n=[];for(r=0;r<e.length;r++)a[e[r]]=!0;for(r=0;r<t.length;r++)a[t[r]]||n.push(t[r]);return n}function R(t,e){console.warn("Deprecation: "+t+(e?". This feature will be removed in "+e+".":" the near future.")),console.trace()}function L(t,e,
|