Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

1189 lines
107KB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="generator" content="pandoc" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
  7. <title>widget_demo.utf8</title>
  8. <style>
  9. code{white-space: pre-wrap;}
  10. span.smallcaps{font-variant: small-caps;}
  11. span.underline{text-decoration: underline;}
  12. div.column{display: inline-block; vertical-align: top; width: 50%;}
  13. </style>
  14. <style type="text/css">
  15. html {
  16. line-height: 1.15;
  17. -webkit-text-size-adjust: 100%;
  18. }
  19. body {
  20. margin: 0;
  21. }
  22. main {
  23. display: block;
  24. }
  25. h1 {
  26. font-size: 2em;
  27. margin: 0.67em 0;
  28. }
  29. hr {
  30. box-sizing: content-box;
  31. height: 0;
  32. overflow: visible;
  33. }
  34. pre {
  35. font-family: monospace, monospace;
  36. font-size: 1em;
  37. }
  38. a {
  39. background-color: transparent;
  40. }
  41. abbr[title] {
  42. border-bottom: none;
  43. text-decoration: underline;
  44. text-decoration: underline dotted;
  45. }
  46. b,
  47. strong {
  48. font-weight: bolder;
  49. }
  50. code,
  51. kbd,
  52. samp {
  53. font-family: monospace, monospace;
  54. font-size: 1em;
  55. }
  56. small {
  57. font-size: 80%;
  58. }
  59. sub,
  60. sup {
  61. font-size: 75%;
  62. line-height: 0;
  63. position: relative;
  64. vertical-align: baseline;
  65. }
  66. sub {
  67. bottom: -0.25em;
  68. }
  69. sup {
  70. top: -0.5em;
  71. }
  72. img {
  73. border-style: none;
  74. }
  75. button,
  76. input,
  77. optgroup,
  78. select,
  79. textarea {
  80. font-family: inherit;
  81. font-size: 100%;
  82. line-height: 1.15;
  83. margin: 0;
  84. }
  85. button,
  86. input {
  87. overflow: visible;
  88. }
  89. button,
  90. select {
  91. text-transform: none;
  92. }
  93. button,
  94. [type="button"],
  95. [type="reset"],
  96. [type="submit"] {
  97. -webkit-appearance: button;
  98. }
  99. button::-moz-focus-inner,
  100. [type="button"]::-moz-focus-inner,
  101. [type="reset"]::-moz-focus-inner,
  102. [type="submit"]::-moz-focus-inner {
  103. border-style: none;
  104. padding: 0;
  105. }
  106. button:-moz-focusring,
  107. [type="button"]:-moz-focusring,
  108. [type="reset"]:-moz-focusring,
  109. [type="submit"]:-moz-focusring {
  110. outline: 1px dotted ButtonText;
  111. }
  112. fieldset {
  113. padding: 0.35em 0.75em 0.625em;
  114. }
  115. legend {
  116. box-sizing: border-box;
  117. color: inherit;
  118. display: table;
  119. max-width: 100%;
  120. padding: 0;
  121. white-space: normal;
  122. }
  123. progress {
  124. vertical-align: baseline;
  125. }
  126. textarea {
  127. overflow: auto;
  128. }
  129. [type="checkbox"],
  130. [type="radio"] {
  131. box-sizing: border-box;
  132. padding: 0;
  133. }
  134. [type="number"]::-webkit-inner-spin-button,
  135. [type="number"]::-webkit-outer-spin-button {
  136. height: auto;
  137. }
  138. [type="search"] {
  139. -webkit-appearance: textfield;
  140. outline-offset: -2px;
  141. }
  142. [type="search"]::-webkit-search-decoration {
  143. -webkit-appearance: none;
  144. }
  145. ::-webkit-file-upload-button {
  146. -webkit-appearance: button;
  147. font: inherit;
  148. }
  149. details {
  150. display: block;
  151. }
  152. summary {
  153. display: list-item;
  154. }
  155. template {
  156. display: none;
  157. }
  158. [hidden] {
  159. display: none;
  160. }
  161. </style>
  162. <script>(function() {
  163. // If window.HTMLWidgets is already defined, then use it; otherwise create a
  164. // new object. This allows preceding code to set options that affect the
  165. // initialization process (though none currently exist).
  166. window.HTMLWidgets = window.HTMLWidgets || {};
  167. // See if we're running in a viewer pane. If not, we're in a web browser.
  168. var viewerMode = window.HTMLWidgets.viewerMode =
  169. /\bviewer_pane=1\b/.test(window.location);
  170. // See if we're running in Shiny mode. If not, it's a static document.
  171. // Note that static widgets can appear in both Shiny and static modes, but
  172. // obviously, Shiny widgets can only appear in Shiny apps/documents.
  173. var shinyMode = window.HTMLWidgets.shinyMode =
  174. typeof(window.Shiny) !== "undefined" && !!window.Shiny.outputBindings;
  175. // We can't count on jQuery being available, so we implement our own
  176. // version if necessary.
  177. function querySelectorAll(scope, selector) {
  178. if (typeof(jQuery) !== "undefined" && scope instanceof jQuery) {
  179. return scope.find(selector);
  180. }
  181. if (scope.querySelectorAll) {
  182. return scope.querySelectorAll(selector);
  183. }
  184. }
  185. function asArray(value) {
  186. if (value === null)
  187. return [];
  188. if ($.isArray(value))
  189. return value;
  190. return [value];
  191. }
  192. // Implement jQuery's extend
  193. function extend(target /*, ... */) {
  194. if (arguments.length == 1) {
  195. return target;
  196. }
  197. for (var i = 1; i < arguments.length; i++) {
  198. var source = arguments[i];
  199. for (var prop in source) {
  200. if (source.hasOwnProperty(prop)) {
  201. target[prop] = source[prop];
  202. }
  203. }
  204. }
  205. return target;
  206. }
  207. // IE8 doesn't support Array.forEach.
  208. function forEach(values, callback, thisArg) {
  209. if (values.forEach) {
  210. values.forEach(callback, thisArg);
  211. } else {
  212. for (var i = 0; i < values.length; i++) {
  213. callback.call(thisArg, values[i], i, values);
  214. }
  215. }
  216. }
  217. // Replaces the specified method with the return value of funcSource.
  218. //
  219. // Note that funcSource should not BE the new method, it should be a function
  220. // that RETURNS the new method. funcSource receives a single argument that is
  221. // the overridden method, it can be called from the new method. The overridden
  222. // method can be called like a regular function, it has the target permanently
  223. // bound to it so "this" will work correctly.
  224. function overrideMethod(target, methodName, funcSource) {
  225. var superFunc = target[methodName] || function() {};
  226. var superFuncBound = function() {
  227. return superFunc.apply(target, arguments);
  228. };
  229. target[methodName] = funcSource(superFuncBound);
  230. }
  231. // Add a method to delegator that, when invoked, calls
  232. // delegatee.methodName. If there is no such method on
  233. // the delegatee, but there was one on delegator before
  234. // delegateMethod was called, then the original version
  235. // is invoked instead.
  236. // For example:
  237. //
  238. // var a = {
  239. // method1: function() { console.log('a1'); }
  240. // method2: function() { console.log('a2'); }
  241. // };
  242. // var b = {
  243. // method1: function() { console.log('b1'); }
  244. // };
  245. // delegateMethod(a, b, "method1");
  246. // delegateMethod(a, b, "method2");
  247. // a.method1();
  248. // a.method2();
  249. //
  250. // The output would be "b1", "a2".
  251. function delegateMethod(delegator, delegatee, methodName) {
  252. var inherited = delegator[methodName];
  253. delegator[methodName] = function() {
  254. var target = delegatee;
  255. var method = delegatee[methodName];
  256. // The method doesn't exist on the delegatee. Instead,
  257. // call the method on the delegator, if it exists.
  258. if (!method) {
  259. target = delegator;
  260. method = inherited;
  261. }
  262. if (method) {
  263. return method.apply(target, arguments);
  264. }
  265. };
  266. }
  267. // Implement a vague facsimilie of jQuery's data method
  268. function elementData(el, name, value) {
  269. if (arguments.length == 2) {
  270. return el["htmlwidget_data_" + name];
  271. } else if (arguments.length == 3) {
  272. el["htmlwidget_data_" + name] = value;
  273. return el;
  274. } else {
  275. throw new Error("Wrong number of arguments for elementData: " +
  276. arguments.length);
  277. }
  278. }
  279. // http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
  280. function escapeRegExp(str) {
  281. return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
  282. }
  283. function hasClass(el, className) {
  284. var re = new RegExp("\\b" + escapeRegExp(className) + "\\b");
  285. return re.test(el.className);
  286. }
  287. // elements - array (or array-like object) of HTML elements
  288. // className - class name to test for
  289. // include - if true, only return elements with given className;
  290. // if false, only return elements *without* given className
  291. function filterByClass(elements, className, include) {
  292. var results = [];
  293. for (var i = 0; i < elements.length; i++) {
  294. if (hasClass(elements[i], className) == include)
  295. results.push(elements[i]);
  296. }
  297. return results;
  298. }
  299. function on(obj, eventName, func) {
  300. if (obj.addEventListener) {
  301. obj.addEventListener(eventName, func, false);
  302. } else if (obj.attachEvent) {
  303. obj.attachEvent(eventName, func);
  304. }
  305. }
  306. function off(obj, eventName, func) {
  307. if (obj.removeEventListener)
  308. obj.removeEventListener(eventName, func, false);
  309. else if (obj.detachEvent) {
  310. obj.detachEvent(eventName, func);
  311. }
  312. }
  313. // Translate array of values to top/right/bottom/left, as usual with
  314. // the "padding" CSS property
  315. // https://developer.mozilla.org/en-US/docs/Web/CSS/padding
  316. function unpackPadding(value) {
  317. if (typeof(value) === "number")
  318. value = [value];
  319. if (value.length === 1) {
  320. return {top: value[0], right: value[0], bottom: value[0], left: value[0]};
  321. }
  322. if (value.length === 2) {
  323. return {top: value[0], right: value[1], bottom: value[0], left: value[1]};
  324. }
  325. if (value.length === 3) {
  326. return {top: value[0], right: value[1], bottom: value[2], left: value[1]};
  327. }
  328. if (value.length === 4) {
  329. return {top: value[0], right: value[1], bottom: value[2], left: value[3]};
  330. }
  331. }
  332. // Convert an unpacked padding object to a CSS value
  333. function paddingToCss(paddingObj) {
  334. return paddingObj.top + "px " + paddingObj.right + "px " + paddingObj.bottom + "px " + paddingObj.left + "px";
  335. }
  336. // Makes a number suitable for CSS
  337. function px(x) {
  338. if (typeof(x) === "number")
  339. return x + "px";
  340. else
  341. return x;
  342. }
  343. // Retrieves runtime widget sizing information for an element.
  344. // The return value is either null, or an object with fill, padding,
  345. // defaultWidth, defaultHeight fields.
  346. function sizingPolicy(el) {
  347. var sizingEl = document.querySelector("script[data-for='" + el.id + "'][type='application/htmlwidget-sizing']");
  348. if (!sizingEl)
  349. return null;
  350. var sp = JSON.parse(sizingEl.textContent || sizingEl.text || "{}");
  351. if (viewerMode) {
  352. return sp.viewer;
  353. } else {
  354. return sp.browser;
  355. }
  356. }
  357. // @param tasks Array of strings (or falsy value, in which case no-op).
  358. // Each element must be a valid JavaScript expression that yields a
  359. // function. Or, can be an array of objects with "code" and "data"
  360. // properties; in this case, the "code" property should be a string
  361. // of JS that's an expr that yields a function, and "data" should be
  362. // an object that will be added as an additional argument when that
  363. // function is called.
  364. // @param target The object that will be "this" for each function
  365. // execution.
  366. // @param args Array of arguments to be passed to the functions. (The
  367. // same arguments will be passed to all functions.)
  368. function evalAndRun(tasks, target, args) {
  369. if (tasks) {
  370. forEach(tasks, function(task) {
  371. var theseArgs = args;
  372. if (typeof(task) === "object") {
  373. theseArgs = theseArgs.concat([task.data]);
  374. task = task.code;
  375. }
  376. var taskFunc = tryEval(task);
  377. if (typeof(taskFunc) !== "function") {
  378. throw new Error("Task must be a function! Source:\n" + task);
  379. }
  380. taskFunc.apply(target, theseArgs);
  381. });
  382. }
  383. }
  384. // Attempt eval() both with and without enclosing in parentheses.
  385. // Note that enclosing coerces a function declaration into
  386. // an expression that eval() can parse
  387. // (otherwise, a SyntaxError is thrown)
  388. function tryEval(code) {
  389. var result = null;
  390. try {
  391. result = eval(code);
  392. } catch(error) {
  393. if (!error instanceof SyntaxError) {
  394. throw error;
  395. }
  396. try {
  397. result = eval("(" + code + ")");
  398. } catch(e) {
  399. if (e instanceof SyntaxError) {
  400. throw error;
  401. } else {
  402. throw e;
  403. }
  404. }
  405. }
  406. return result;
  407. }
  408. function initSizing(el) {
  409. var sizing = sizingPolicy(el);
  410. if (!sizing)
  411. return;
  412. var cel = document.getElementById("htmlwidget_container");
  413. if (!cel)
  414. return;
  415. if (typeof(sizing.padding) !== "undefined") {
  416. document.body.style.margin = "0";
  417. document.body.style.padding = paddingToCss(unpackPadding(sizing.padding));
  418. }
  419. if (sizing.fill) {
  420. document.body.style.overflow = "hidden";
  421. document.body.style.width = "100%";
  422. document.body.style.height = "100%";
  423. document.documentElement.style.width = "100%";
  424. document.documentElement.style.height = "100%";
  425. if (cel) {
  426. cel.style.position = "absolute";
  427. var pad = unpackPadding(sizing.padding);
  428. cel.style.top = pad.top + "px";
  429. cel.style.right = pad.right + "px";
  430. cel.style.bottom = pad.bottom + "px";
  431. cel.style.left = pad.left + "px";
  432. el.style.width = "100%";
  433. el.style.height = "100%";
  434. }
  435. return {
  436. getWidth: function() { return cel.offsetWidth; },
  437. getHeight: function() { return cel.offsetHeight; }
  438. };
  439. } else {
  440. el.style.width = px(sizing.width);
  441. el.style.height = px(sizing.height);
  442. return {
  443. getWidth: function() { return el.offsetWidth; },
  444. getHeight: function() { return el.offsetHeight; }
  445. };
  446. }
  447. }
  448. // Default implementations for methods
  449. var defaults = {
  450. find: function(scope) {
  451. return querySelectorAll(scope, "." + this.name);
  452. },
  453. renderError: function(el, err) {
  454. var $el = $(el);
  455. this.clearError(el);
  456. // Add all these error classes, as Shiny does
  457. var errClass = "shiny-output-error";
  458. if (err.type !== null) {
  459. // use the classes of the error condition as CSS class names
  460. errClass = errClass + " " + $.map(asArray(err.type), function(type) {
  461. return errClass + "-" + type;
  462. }).join(" ");
  463. }
  464. errClass = errClass + " htmlwidgets-error";
  465. // Is el inline or block? If inline or inline-block, just display:none it
  466. // and add an inline error.
  467. var display = $el.css("display");
  468. $el.data("restore-display-mode", display);
  469. if (display === "inline" || display === "inline-block") {
  470. $el.hide();
  471. if (err.message !== "") {
  472. var errorSpan = $("<span>").addClass(errClass);
  473. errorSpan.text(err.message);
  474. $el.after(errorSpan);
  475. }
  476. } else if (display === "block") {
  477. // If block, add an error just after the el, set visibility:none on the
  478. // el, and position the error to be on top of the el.
  479. // Mark it with a unique ID and CSS class so we can remove it later.
  480. $el.css("visibility", "hidden");
  481. if (err.message !== "") {
  482. var errorDiv = $("<div>").addClass(errClass).css("position", "absolute")
  483. .css("top", el.offsetTop)
  484. .css("left", el.offsetLeft)
  485. // setting width can push out the page size, forcing otherwise
  486. // unnecessary scrollbars to appear and making it impossible for
  487. // the element to shrink; so use max-width instead
  488. .css("maxWidth", el.offsetWidth)
  489. .css("height", el.offsetHeight);
  490. errorDiv.text(err.message);
  491. $el.after(errorDiv);
  492. // Really dumb way to keep the size/position of the error in sync with
  493. // the parent element as the window is resized or whatever.
  494. var intId = setInterval(function() {
  495. if (!errorDiv[0].parentElement) {
  496. clearInterval(intId);
  497. return;
  498. }
  499. errorDiv
  500. .css("top", el.offsetTop)
  501. .css("left", el.offsetLeft)
  502. .css("maxWidth", el.offsetWidth)
  503. .css("height", el.offsetHeight);
  504. }, 500);
  505. }
  506. }
  507. },
  508. clearError: function(el) {
  509. var $el = $(el);
  510. var display = $el.data("restore-display-mode");
  511. $el.data("restore-display-mode", null);
  512. if (display === "inline" || display === "inline-block") {
  513. if (display)
  514. $el.css("display", display);
  515. $(el.nextSibling).filter(".htmlwidgets-error").remove();
  516. } else if (display === "block"){
  517. $el.css("visibility", "inherit");
  518. $(el.nextSibling).filter(".htmlwidgets-error").remove();
  519. }
  520. },
  521. sizing: {}
  522. };
  523. // Called by widget bindings to register a new type of widget. The definition
  524. // object can contain the following properties:
  525. // - name (required) - A string indicating the binding name, which will be
  526. // used by default as the CSS classname to look for.
  527. // - initialize (optional) - A function(el) that will be called once per
  528. // widget element; if a value is returned, it will be passed as the third
  529. // value to renderValue.
  530. // - renderValue (required) - A function(el, data, initValue) that will be
  531. // called with data. Static contexts will cause this to be called once per
  532. // element; Shiny apps will cause this to be called multiple times per
  533. // element, as the data changes.
  534. window.HTMLWidgets.widget = function(definition) {
  535. if (!definition.name) {
  536. throw new Error("Widget must have a name");
  537. }
  538. if (!definition.type) {
  539. throw new Error("Widget must have a type");
  540. }
  541. // Currently we only support output widgets
  542. if (definition.type !== "output") {
  543. throw new Error("Unrecognized widget type '" + definition.type + "'");
  544. }
  545. // TODO: Verify that .name is a valid CSS classname
  546. // Support new-style instance-bound definitions. Old-style class-bound
  547. // definitions have one widget "object" per widget per type/class of
  548. // widget; the renderValue and resize methods on such widget objects
  549. // take el and instance arguments, because the widget object can't
  550. // store them. New-style instance-bound definitions have one widget
  551. // object per widget instance; the definition that's passed in doesn't
  552. // provide renderValue or resize methods at all, just the single method
  553. // factory(el, width, height)
  554. // which returns an object that has renderValue(x) and resize(w, h).
  555. // This enables a far more natural programming style for the widget
  556. // author, who can store per-instance state using either OO-style
  557. // instance fields or functional-style closure variables (I guess this
  558. // is in contrast to what can only be called C-style pseudo-OO which is
  559. // what we required before).
  560. if (definition.factory) {
  561. definition = createLegacyDefinitionAdapter(definition);
  562. }
  563. if (!definition.renderValue) {
  564. throw new Error("Widget must have a renderValue function");
  565. }
  566. // For static rendering (non-Shiny), use a simple widget registration
  567. // scheme. We also use this scheme for Shiny apps/documents that also
  568. // contain static widgets.
  569. window.HTMLWidgets.widgets = window.HTMLWidgets.widgets || [];
  570. // Merge defaults into the definition; don't mutate the original definition.
  571. var staticBinding = extend({}, defaults, definition);
  572. overrideMethod(staticBinding, "find", function(superfunc) {
  573. return function(scope) {
  574. var results = superfunc(scope);
  575. // Filter out Shiny outputs, we only want the static kind
  576. return filterByClass(results, "html-widget-output", false);
  577. };
  578. });
  579. window.HTMLWidgets.widgets.push(staticBinding);
  580. if (shinyMode) {
  581. // Shiny is running. Register the definition with an output binding.
  582. // The definition itself will not be the output binding, instead
  583. // we will make an output binding object that delegates to the
  584. // definition. This is because we foolishly used the same method
  585. // name (renderValue) for htmlwidgets definition and Shiny bindings
  586. // but they actually have quite different semantics (the Shiny
  587. // bindings receive data that includes lots of metadata that it
  588. // strips off before calling htmlwidgets renderValue). We can't
  589. // just ignore the difference because in some widgets it's helpful
  590. // to call this.renderValue() from inside of resize(), and if
  591. // we're not delegating, then that call will go to the Shiny
  592. // version instead of the htmlwidgets version.
  593. // Merge defaults with definition, without mutating either.
  594. var bindingDef = extend({}, defaults, definition);
  595. // This object will be our actual Shiny binding.
  596. var shinyBinding = new Shiny.OutputBinding();
  597. // With a few exceptions, we'll want to simply use the bindingDef's
  598. // version of methods if they are available, otherwise fall back to
  599. // Shiny's defaults. NOTE: If Shiny's output bindings gain additional
  600. // methods in the future, and we want them to be overrideable by
  601. // HTMLWidget binding definitions, then we'll need to add them to this
  602. // list.
  603. delegateMethod(shinyBinding, bindingDef, "getId");
  604. delegateMethod(shinyBinding, bindingDef, "onValueChange");
  605. delegateMethod(shinyBinding, bindingDef, "onValueError");
  606. delegateMethod(shinyBinding, bindingDef, "renderError");
  607. delegateMethod(shinyBinding, bindingDef, "clearError");
  608. delegateMethod(shinyBinding, bindingDef, "showProgress");
  609. // The find, renderValue, and resize are handled differently, because we
  610. // want to actually decorate the behavior of the bindingDef methods.
  611. shinyBinding.find = function(scope) {
  612. var results = bindingDef.find(scope);
  613. // Only return elements that are Shiny outputs, not static ones
  614. var dynamicResults = results.filter(".html-widget-output");
  615. // It's possible that whatever caused Shiny to think there might be
  616. // new dynamic outputs, also caused there to be new static outputs.
  617. // Since there might be lots of different htmlwidgets bindings, we
  618. // schedule execution for later--no need to staticRender multiple
  619. // times.
  620. if (results.length !== dynamicResults.length)
  621. scheduleStaticRender();
  622. return dynamicResults;
  623. };
  624. // Wrap renderValue to handle initialization, which unfortunately isn't
  625. // supported natively by Shiny at the time of this writing.
  626. shinyBinding.renderValue = function(el, data) {
  627. Shiny.renderDependencies(data.deps);
  628. // Resolve strings marked as javascript literals to objects
  629. if (!(data.evals instanceof Array)) data.evals = [data.evals];
  630. for (var i = 0; data.evals && i < data.evals.length; i++) {
  631. window.HTMLWidgets.evaluateStringMember(data.x, data.evals[i]);
  632. }
  633. if (!bindingDef.renderOnNullValue) {
  634. if (data.x === null) {
  635. el.style.visibility = "hidden";
  636. return;
  637. } else {
  638. el.style.visibility = "inherit";
  639. }
  640. }
  641. if (!elementData(el, "initialized")) {
  642. initSizing(el);
  643. elementData(el, "initialized", true);
  644. if (bindingDef.initialize) {
  645. var result = bindingDef.initialize(el, el.offsetWidth,
  646. el.offsetHeight);
  647. elementData(el, "init_result", result);
  648. }
  649. }
  650. bindingDef.renderValue(el, data.x, elementData(el, "init_result"));
  651. evalAndRun(data.jsHooks.render, elementData(el, "init_result"), [el, data.x]);
  652. };
  653. // Only override resize if bindingDef implements it
  654. if (bindingDef.resize) {
  655. shinyBinding.resize = function(el, width, height) {
  656. // Shiny can call resize before initialize/renderValue have been
  657. // called, which doesn't make sense for widgets.
  658. if (elementData(el, "initialized")) {
  659. bindingDef.resize(el, width, height, elementData(el, "init_result"));
  660. }
  661. };
  662. }
  663. Shiny.outputBindings.register(shinyBinding, bindingDef.name);
  664. }
  665. };
  666. var scheduleStaticRenderTimerId = null;
  667. function scheduleStaticRender() {
  668. if (!scheduleStaticRenderTimerId) {
  669. scheduleStaticRenderTimerId = setTimeout(function() {
  670. scheduleStaticRenderTimerId = null;
  671. window.HTMLWidgets.staticRender();
  672. }, 1);
  673. }
  674. }
  675. // Render static widgets after the document finishes loading
  676. // Statically render all elements that are of this widget's class
  677. window.HTMLWidgets.staticRender = function() {
  678. var bindings = window.HTMLWidgets.widgets || [];
  679. forEach(bindings, function(binding) {
  680. var matches = binding.find(document.documentElement);
  681. forEach(matches, function(el) {
  682. var sizeObj = initSizing(el, binding);
  683. if (hasClass(el, "html-widget-static-bound"))
  684. return;
  685. el.className = el.className + " html-widget-static-bound";
  686. var initResult;
  687. if (binding.initialize) {
  688. initResult = binding.initialize(el,
  689. sizeObj ? sizeObj.getWidth() : el.offsetWidth,
  690. sizeObj ? sizeObj.getHeight() : el.offsetHeight
  691. );
  692. elementData(el, "init_result", initResult);
  693. }
  694. if (binding.resize) {
  695. var lastSize = {
  696. w: sizeObj ? sizeObj.getWidth() : el.offsetWidth,
  697. h: sizeObj ? sizeObj.getHeight() : el.offsetHeight
  698. };
  699. var resizeHandler = function(e) {
  700. var size = {
  701. w: sizeObj ? sizeObj.getWidth() : el.offsetWidth,
  702. h: sizeObj ? sizeObj.getHeight() : el.offsetHeight
  703. };
  704. if (size.w === 0 && size.h === 0)
  705. return;
  706. if (size.w === lastSize.w && size.h === lastSize.h)
  707. return;
  708. lastSize = size;
  709. binding.resize(el, size.w, size.h, initResult);
  710. };
  711. on(window, "resize", resizeHandler);
  712. // This is needed for cases where we're running in a Shiny
  713. // app, but the widget itself is not a Shiny output, but
  714. // rather a simple static widget. One example of this is
  715. // an rmarkdown document that has runtime:shiny and widget
  716. // that isn't in a render function. Shiny only knows to
  717. // call resize handlers for Shiny outputs, not for static
  718. // widgets, so we do it ourselves.
  719. if (window.jQuery) {
  720. window.jQuery(document).on(
  721. "shown.htmlwidgets shown.bs.tab.htmlwidgets shown.bs.collapse.htmlwidgets",
  722. resizeHandler
  723. );
  724. window.jQuery(document).on(
  725. "hidden.htmlwidgets hidden.bs.tab.htmlwidgets hidden.bs.collapse.htmlwidgets",
  726. resizeHandler
  727. );
  728. }
  729. // This is needed for the specific case of ioslides, which
  730. // flips slides between display:none and display:block.
  731. // Ideally we would not have to have ioslide-specific code
  732. // here, but rather have ioslides raise a generic event,
  733. // but the rmarkdown package just went to CRAN so the
  734. // window to getting that fixed may be long.
  735. if (window.addEventListener) {
  736. // It's OK to limit this to window.addEventListener
  737. // browsers because ioslides itself only supports
  738. // such browsers.
  739. on(document, "slideenter", resizeHandler);
  740. on(document, "slideleave", resizeHandler);
  741. }
  742. }
  743. var scriptData = document.querySelector("script[data-for='" + el.id + "'][type='application/json']");
  744. if (scriptData) {
  745. var data = JSON.parse(scriptData.textContent || scriptData.text);
  746. // Resolve strings marked as javascript literals to objects
  747. if (!(data.evals instanceof Array)) data.evals = [data.evals];
  748. for (var k = 0; data.evals && k < data.evals.length; k++) {
  749. window.HTMLWidgets.evaluateStringMember(data.x, data.evals[k]);
  750. }
  751. binding.renderValue(el, data.x, initResult);
  752. evalAndRun(data.jsHooks.render, initResult, [el, data.x]);
  753. }
  754. });
  755. });
  756. invokePostRenderHandlers();
  757. }
  758. function has_jQuery3() {
  759. if (!window.jQuery) {
  760. return false;
  761. }
  762. var $version = window.jQuery.fn.jquery;
  763. var $major_version = parseInt($version.split(".")[0]);
  764. return $major_version >= 3;
  765. }
  766. /*
  767. / Shiny 1.4 bumped jQuery from 1.x to 3.x which means jQuery's
  768. / on-ready handler (i.e., $(fn)) is now asyncronous (i.e., it now
  769. / really means $(setTimeout(fn)).
  770. / https://jquery.com/upgrade-guide/3.0/#breaking-change-document-ready-handlers-are-now-asynchronous
  771. /
  772. / Since Shiny uses $() to schedule initShiny, shiny>=1.4 calls initShiny
  773. / one tick later than it did before, which means staticRender() is
  774. / called renderValue() earlier than (advanced) widget authors might be expecting.
  775. / https://github.com/rstudio/shiny/issues/2630
  776. /
  777. / For a concrete example, leaflet has some methods (e.g., updateBounds)
  778. / which reference Shiny methods registered in initShiny (e.g., setInputValue).
  779. / Since leaflet is privy to this life-cycle, it knows to use setTimeout() to
  780. / delay execution of those methods (until Shiny methods are ready)
  781. / https://github.com/rstudio/leaflet/blob/18ec981/javascript/src/index.js#L266-L268
  782. /
  783. / Ideally widget authors wouldn't need to use this setTimeout() hack that
  784. / leaflet uses to call Shiny methods on a staticRender(). In the long run,
  785. / the logic initShiny should be broken up so that method registration happens
  786. / right away, but binding happens later.
  787. */
  788. function maybeStaticRenderLater() {
  789. if (shinyMode && has_jQuery3()) {
  790. window.jQuery(window.HTMLWidgets.staticRender);
  791. } else {
  792. window.HTMLWidgets.staticRender();
  793. }
  794. }
  795. if (document.addEventListener) {
  796. document.addEventListener("DOMContentLoaded", function() {
  797. document.removeEventListener("DOMContentLoaded", arguments.callee, false);
  798. maybeStaticRenderLater();
  799. }, false);
  800. } else if (document.attachEvent) {
  801. document.attachEvent("onreadystatechange", function() {
  802. if (document.readyState === "complete") {
  803. document.detachEvent("onreadystatechange", arguments.callee);
  804. maybeStaticRenderLater();
  805. }
  806. });
  807. }
  808. window.HTMLWidgets.getAttachmentUrl = function(depname, key) {
  809. // If no key, default to the first item
  810. if (typeof(key) === "undefined")
  811. key = 1;
  812. var link = document.getElementById(depname + "-" + key + "-attachment");
  813. if (!link) {
  814. throw new Error("Attachment " + depname + "/" + key + " not found in document");
  815. }
  816. return link.getAttribute("href");
  817. };
  818. window.HTMLWidgets.dataframeToD3 = function(df) {
  819. var names = [];
  820. var length;
  821. for (var name in df) {
  822. if (df.hasOwnProperty(name))
  823. names.push(name);
  824. if (typeof(df[name]) !== "object" || typeof(df[name].length) === "undefined") {
  825. throw new Error("All fields must be arrays");
  826. } else if (typeof(length) !== "undefined" && length !== df[name].length) {
  827. throw new Error("All fields must be arrays of the same length");
  828. }
  829. length = df[name].length;
  830. }
  831. var results = [];
  832. var item;
  833. for (var row = 0; row < length; row++) {
  834. item = {};
  835. for (var col = 0; col < names.length; col++) {
  836. item[names[col]] = df[names[col]][row];
  837. }
  838. results.push(item);
  839. }
  840. return results;
  841. };
  842. window.HTMLWidgets.transposeArray2D = function(array) {
  843. if (array.length === 0) return array;
  844. var newArray = array[0].map(function(col, i) {
  845. return array.map(function(row) {
  846. return row[i]
  847. })
  848. });
  849. return newArray;
  850. };
  851. // Split value at splitChar, but allow splitChar to be escaped
  852. // using escapeChar. Any other characters escaped by escapeChar
  853. // will be included as usual (including escapeChar itself).
  854. function splitWithEscape(value, splitChar, escapeChar) {
  855. var results = [];
  856. var escapeMode = false;
  857. var currentResult = "";
  858. for (var pos = 0; pos < value.length; pos++) {
  859. if (!escapeMode) {
  860. if (value[pos] === splitChar) {
  861. results.push(currentResult);
  862. currentResult = "";
  863. } else if (value[pos] === escapeChar) {
  864. escapeMode = true;
  865. } else {
  866. currentResult += value[pos];
  867. }
  868. } else {
  869. currentResult += value[pos];
  870. escapeMode = false;
  871. }
  872. }
  873. if (currentResult !== "") {
  874. results.push(currentResult);
  875. }
  876. return results;
  877. }
  878. // Function authored by Yihui/JJ Allaire
  879. window.HTMLWidgets.evaluateStringMember = function(o, member) {
  880. var parts = splitWithEscape(member, '.', '\\');
  881. for (var i = 0, l = parts.length; i < l; i++) {
  882. var part = parts[i];
  883. // part may be a character or 'numeric' member name
  884. if (o !== null && typeof o === "object" && part in o) {
  885. if (i == (l - 1)) { // if we are at the end of the line then evalulate
  886. if (typeof o[part] === "string")
  887. o[part] = tryEval(o[part]);
  888. } else { // otherwise continue to next embedded object
  889. o = o[part];
  890. }
  891. }
  892. }
  893. };
  894. // Retrieve the HTMLWidget instance (i.e. the return value of an
  895. // HTMLWidget binding's initialize() or factory() function)
  896. // associated with an element, or null if none.
  897. window.HTMLWidgets.getInstance = function(el) {
  898. return elementData(el, "init_result");
  899. };
  900. // Finds the first element in the scope that matches the selector,
  901. // and returns the HTMLWidget instance (i.e. the return value of
  902. // an HTMLWidget binding's initialize() or factory() function)
  903. // associated with that element, if any. If no element matches the
  904. // selector, or the first matching element has no HTMLWidget
  905. // instance associated with it, then null is returned.
  906. //
  907. // The scope argument is optional, and defaults to window.document.
  908. window.HTMLWidgets.find = function(scope, selector) {
  909. if (arguments.length == 1) {
  910. selector = scope;
  911. scope = document;
  912. }
  913. var el = scope.querySelector(selector);
  914. if (el === null) {
  915. return null;
  916. } else {
  917. return window.HTMLWidgets.getInstance(el);
  918. }
  919. };
  920. // Finds all elements in the scope that match the selector, and
  921. // returns the HTMLWidget instances (i.e. the return values of
  922. // an HTMLWidget binding's initialize() or factory() function)
  923. // associated with the elements, in an array. If elements that
  924. // match the selector don't have an associated HTMLWidget
  925. // instance, the returned array will contain nulls.
  926. //
  927. // The scope argument is optional, and defaults to window.document.
  928. window.HTMLWidgets.findAll = function(scope, selector) {
  929. if (arguments.length == 1) {
  930. selector = scope;
  931. scope = document;
  932. }
  933. var nodes = scope.querySelectorAll(selector);
  934. var results = [];
  935. for (var i = 0; i < nodes.length; i++) {
  936. results.push(window.HTMLWidgets.getInstance(nodes[i]));
  937. }
  938. return results;
  939. };
  940. var postRenderHandlers = [];
  941. function invokePostRenderHandlers() {
  942. while (postRenderHandlers.length) {
  943. var handler = postRenderHandlers.shift();
  944. if (handler) {
  945. handler();
  946. }
  947. }
  948. }
  949. // Register the given callback function to be invoked after the
  950. // next time static widgets are rendered.
  951. window.HTMLWidgets.addPostRenderHandler = function(callback) {
  952. postRenderHandlers.push(callback);
  953. };
  954. // Takes a new-style instance-bound definition, and returns an
  955. // old-style class-bound definition. This saves us from having
  956. // to rewrite all the logic in this file to accomodate both
  957. // types of definitions.
  958. function createLegacyDefinitionAdapter(defn) {
  959. var result = {
  960. name: defn.name,
  961. type: defn.type,
  962. initialize: function(el, width, height) {
  963. return defn.factory(el, width, height);
  964. },
  965. renderValue: function(el, x, instance) {
  966. return instance.renderValue(x);
  967. },
  968. resize: function(el, width, height, instance) {
  969. return instance.resize(width, height);
  970. }
  971. };
  972. if (defn.find)
  973. result.find = defn.find;
  974. if (defn.renderError)
  975. result.renderError = defn.renderError;
  976. if (defn.clearError)
  977. result.clearError = defn.clearError;
  978. return result;
  979. }
  980. })();
  981. </script>
  982. <script>var frappe=function(){"use strict";function t(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function e(t){var e=t.getBoundingClientRect();return{top:e.top+(document.documentElement.scrollTop||document.body.scrollTop),left:e.left+(document.documentElement.scrollLeft||document.body.scrollLeft)}}function i(t){var e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function n(t){var e=window.getComputedStyle(t),i=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight);return t.clientWidth-i}function a(t,e,i){var n=document.createEvent("HTMLEvents");n.initEvent(e,!0,!0);for(var a in i)n[a]=i[a];return t.dispatchEvent(n)}function s(t){return t.titleHeight+t.margins.top+t.paddings.top}function r(t){return t.margins.left+t.paddings.left}function o(t){return t.margins.top+t.margins.bottom+t.paddings.top+t.paddings.bottom+t.titleHeight+t.legendHeight}function l(t){return t.margins.left+t.margins.right+t.paddings.left+t.paddings.right}function u(t){return parseFloat(t.toFixed(2))}function h(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i||(i=n?t[0]:t[t.length-1]);var a=new Array(Math.abs(e)).fill(i);return t=n?a.concat(t):t.concat(a)}function c(t,e){return(t+"").length*e}function d(t,e){return{x:Math.sin(t*Jt)*e,y:Math.cos(t*Jt)*e}}function p(t,e){var i=void 0,n=void 0;return t<=e?(i=e-t,n=t):(i=t-e,n=e),[i,n]}function f(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length-t.length;return i>0?t=h(t,i):e=h(e,i),[t,e]}function v(t,e){if(t)return t.length>e?t.slice(0,e-3)+"...":t}function g(t){var e=void 0;if("number"==typeof t)e=t;else if("string"==typeof t&&(e=Number(t),Number.isNaN(e)))return t;var i=Math.floor(Math.log10(Math.abs(e)));if(i<=2)return e;var n=Math.floor(i/3),a=Math.pow(10,i-3*n)*+(e/Math.pow(10,i)).toFixed(1);return Math.round(100*a)/100+" "+["","K","M","B","T"][n]}function y(t,e){for(var i=[],n=0;n<t.length;n++)i.push([t[n],e[n]]);var a=function(t,e){var i=e[0]-t[0],n=e[1]-t[1];return{length:Math.sqrt(Math.pow(i,2)+Math.pow(n,2)),angle:Math.atan2(n,i)}},s=function(t,e,i,n){var s=a(e||t,i||t),r=s.angle+(n?Math.PI:0),o=.2*s.length;return[t[0]+Math.cos(r)*o,t[1]+Math.sin(r)*o]};return function(t,e){return t.reduce(function(t,i,n,a){return 0===n?i[0]+","+i[1]:t+" "+e(i,n,a)},"")}(i,function(t,e,i){var n=s(i[e-1],i[e-2],t),a=s(t,i[e-1],i[e+1],!0);return"C "+n[0]+","+n[1]+" "+a[0]+","+a[1]+" "+t[0]+","+t[1]})}function m(t){return t>255?255:t<0?0:t}function b(t,e){var i=Qt(t),n=!1;"#"==i[0]&&(i=i.slice(1),n=!0);var a=parseInt(i,16),s=m((a>>16)+e),r=m((a>>8&255)+e),o=m((255&a)+e);return(n?"#":"")+(o|r<<8|s<<16).toString(16)}function x(t){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)}function k(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function w(t,e){var i=document.createElementNS("http://www.w3.org/2000/svg",t);for(var n in e){var a=e[n];if("inside"===n)k(a).appendChild(i);else if("around"===n){var s=k(a);s.parentNode.insertBefore(i,s),i.appendChild(s)}else"styles"===n?"object"===(void 0===a?"undefined":_t(a))&&Object.keys(a).map(function(t){i.style[t]=a[t]}):("className"===n&&(n="class"),"innerHTML"===n?i.textContent=a:i.setAttribute(n,a))}return i}function A(t,e){return w("linearGradient",{inside:t,id:e,x1:0,x2:0,y1:0,y2:1})}function P(t,e,i,n){return w("stop",{inside:t,style:"stop-color: "+i,offset:e,"stop-opacity":n})}function L(t,e,i,n){return w("svg",{className:e,inside:t,width:i,height:n})}function T(t){return w("defs",{inside:t})}function M(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,n={className:t,transform:e};return i&&(n.inside=i),w("g",n)}function C(t){return w("path",{className:arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",d:t,styles:{stroke:arguments.length>2&&void 0!==arguments[2]?arguments[2]:"none",fill:arguments.length>3&&void 0!==arguments[3]?arguments[3]:"none","stroke-width":arguments.length>4&&void 0!==arguments[4]?arguments[4]:2}})}function O(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,r=i.x+t.x,o=i.y+t.y,l=i.x+e.x,u=i.y+e.y;return"M"+i.x+" "+i.y+"\n\t\tL"+r+" "+o+"\n\t\tA "+n+" "+n+" 0 "+s+" "+(a?1:0)+"\n\t\t"+l+" "+u+" z"}function D(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,r=i.x+t.x,o=i.y+t.y,l=i.x+e.x,u=2*i.y,h=i.y+e.y;return"M"+i.x+" "+i.y+"\n\t\tL"+r+" "+o+"\n\t\tA "+n+" "+n+" 0 "+s+" "+(a?1:0)+"\n\t\t"+l+" "+u+" z\n\t\tL"+r+" "+u+"\n\t\tA "+n+" "+n+" 0 "+s+" "+(a?1:0)+"\n\t\t"+l+" "+h+" z"}function N(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,r=i.x+t.x,o=i.y+t.y,l=i.x+e.x,u=i.y+e.y;return"M"+r+" "+o+"\n\t\tA "+n+" "+n+" 0 "+s+" "+(a?1:0)+"\n\t\t"+l+" "+u}function S(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,r=i.x+t.x,o=i.y+t.y,l=i.x+e.x,u=2*n+o,h=i.y+t.y;return"M"+r+" "+o+"\n\t\tA "+n+" "+n+" 0 "+s+" "+(a?1:0)+"\n\t\t"+l+" "+u+"\n\t\tM"+r+" "+u+"\n\t\tA "+n+" "+n+" 0 "+s+" "+(a?1:0)+"\n\t\t"+l+" "+h}function E(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n="path-fill-gradient-"+e+"-"+(i?"lighter":"default"),a=A(t,n),s=[1,.6,.2];return i&&(s=[.4,.2,0]),P(a,"0%",e,s[0]),P(a,"50%",e,s[1]),P(a,"100%",e,s[2]),n}function _(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Ut,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"none";return w("rect",{className:"percentage-bar",x:t,y:e,width:i,height:n,fill:s,styles:{stroke:b(s,-25),"stroke-dasharray":"0, "+(n+i)+", "+i+", "+n,"stroke-width":a}})}function z(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"none",s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},r={className:t,x:e,y:i,width:n,height:n,fill:a};return Object.keys(s).map(function(t){r[t]=s[t]}),w("rect",r)}function W(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"none",a=arguments[4];a=arguments.length>5&&void 0!==arguments[5]&&arguments[5]?v(a,ee):a;var s={className:"legend-bar",x:0,y:0,width:i,height:"2px",fill:n},r=w("text",{className:"legend-dataset-text",x:0,y:0,dy:2*ie+"px","font-size":1.2*ie+"px","text-anchor":"start",fill:ae,innerHTML:a}),o=w("g",{transform:"translate("+t+", "+e+")"});return o.appendChild(w("rect",s)),o.appendChild(r),o}function H(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"none",a=arguments[4];a=arguments.length>5&&void 0!==arguments[5]&&arguments[5]?v(a,ee):a;var s={className:"legend-dot",cx:0,cy:0,r:i,fill:n},r=w("text",{className:"legend-dataset-text",x:0,y:0,dx:ie+"px",dy:ie/3+"px","font-size":1.2*ie+"px","text-anchor":"start",fill:ae,innerHTML:a}),o=w("g",{transform:"translate("+t+", "+e+")"});return o.appendChild(w("circle",s)),o.appendChild(r),o}function F(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},s=a.fontSize||ie;return w("text",{className:t,x:e,y:i,dy:(void 0!==a.dy?a.dy:s/2)+"px","font-size":s+"px",fill:a.fill||ae,"text-anchor":a.textAnchor||"start",innerHTML:n})}function j(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};a.stroke||(a.stroke=ne);var s=w("line",{className:"line-vertical "+a.className,x1:0,x2:0,y1:i,y2:n,styles:{stroke:a.stroke}}),r=w("text",{x:0,y:i>n?i+te:i-te-ie,dy:ie+"px","font-size":ie+"px","text-anchor":"middle",innerHTML:e+""}),o=w("g",{transform:"translate("+t+", 0)"});return o.appendChild(s),o.appendChild(r),o}function I(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};a.stroke||(a.stroke=ne),a.lineType||(a.lineType=""),a.shortenNumbers&&(e=g(e));var s=w("line",{className:"line-horizontal "+a.className+("dashed"===a.lineType?"dashed":""),x1:i,x2:n,y1:0,y2:0,styles:{stroke:a.stroke}}),r=w("text",{x:i<n?i-te:i+te,y:0,dy:ie/2-2+"px","font-size":ie+"px","text-anchor":i<n?"end":"start",innerHTML:e+""}),o=w("g",{transform:"translate(0, "+t+")","stroke-opacity":1});return 0!==r&&"0"!==r||(o.style.stroke="rgba(27, 31, 35, 0.6)"),o.appendChild(s),o.appendChild(r),o}function R(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};n.pos||(n.pos="left"),n.offset||(n.offset=0),n.mode||(n.mode="span"),n.stroke||(n.stroke=ne),n.className||(n.className="");var a=-1*Zt,s="span"===n.mode?i+Zt:0;return"tick"===n.mode&&"right"===n.pos&&(a=i+Zt,s=i),a+=n.offset,s+=n.offset,I(t,e,a,s,{stroke:n.stroke,className:n.className,lineType:n.lineType,shortenNumbers:n.shortenNumbers})}function Y(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};n.pos||(n.pos="bottom"),n.offset||(n.offset=0),n.mode||(n.mode="span"),n.stroke||(n.stroke=ne),n.className||(n.className="");var a=i+Zt,s="span"===n.mode?-1*Zt:i;return"tick"===n.mode&&"top"===n.pos&&(a=-1*Zt,s=0),j(t,e,a,s,{stroke:n.stroke,className:n.className,lineType:n.lineType})}function B(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};n.labelPos||(n.labelPos="right");var a=w("text",{className:"chart-label",x:"left"===n.labelPos?te:i-c(e,5)-te,y:0,dy:ie/-2+"px","font-size":ie+"px","text-anchor":"start",innerHTML:e+""}),s=I(t,"",0,i,{stroke:n.stroke||ne,className:n.className||"",lineType:n.lineType});return s.appendChild(a),s}function V(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},s=t-e,r=w("rect",{className:"bar mini",styles:{fill:"rgba(228, 234, 239, 0.49)",stroke:ne,"stroke-dasharray":i+", "+s},x:0,y:0,width:i,height:s});a.labelPos||(a.labelPos="right");var o=w("text",{className:"chart-label",x:"left"===a.labelPos?te:i-c(n+"",4.5)-te,y:0,dy:ie/-2+"px","font-size":ie+"px","text-anchor":"start",innerHTML:n+""}),l=w("g",{transform:"translate(0, "+e+")"});return l.appendChild(r),l.appendChild(o),l}function U(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,o=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},l=p(e,o.zeroLine),u=It(l,2),h=u[0],c=u[1];c-=r,0===h&&(h=o.minHeight,c-=o.minHeight);var d=w("rect",{className:"bar mini",style:"fill: "+n,"data-point-index":s,x:t,y:c,width:i,height:h});if((a+="")||a.length){d.setAttribute("y",0),d.setAttribute("x",0);var f=w("text",{className:"data-point-value",x:i/2,y:0,dy:ie/2*-1+"px","font-size":ie+"px","text-anchor":"middle",innerHTML:a}),v=w("g",{"data-point-index":s,transform:"translate("+t+", "+c+")"});return v.appendChild(d),v.appendChild(f),v}return d}function G(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,r=w("circle",{style:"fill: "+n,"data-point-index":s,cx:t,cy:e,r:i});if((a+="")||a.length){r.setAttribute("cy",0),r.setAttribute("cx",0);var o=w("text",{className:"data-point-value",x:0,y:0,dy:ie/2*-1-i+"px","font-size":ie+"px","text-anchor":"middle",innerHTML:a}),l=w("g",{"data-point-index":s,transform:"translate("+t+", "+e+")"});return l.appendChild(r),l.appendChild(o),l}return r}function q(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},s=e.map(function(e,i){return t[i]+","+e}).join("L");n.spline&&(s=y(t,e));var r=C("M"+s,"line-graph-path",i);if(n.heatline){var o=E(a.svgDefs,i);r.style.stroke="url(#"+o+")"}var l={path:r};if(n.regionFill){var u=E(a.svgDefs,i,!0),h="M"+t[0]+","+a.zeroLine+"L"+s+"L"+t.slice(-1)[0]+","+a.zeroLine;l.region=C(h,"region-fill","none","url(#"+u+")")}return l}function X(t,e,i,n){var a="string"==typeof e?e:e.join(", ");return[t,{transform:i.join(", ")},n,ce,"translate",{transform:a}]}function J(t,e,i){return X(t,[i,0],[e,0],ue)}function K(t,e,i){return X(t,[0,i],[0,e],ue)}function $(t,e,i,n){var a=e-i,s=t.childNodes[0];return[[s,{height:a,"stroke-dasharray":s.getAttribute("width")+", "+a},ue,ce],X(t,[0,n],[0,i],ue)]}function Q(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=p(i,(arguments.length>5&&void 0!==arguments[5]?arguments[5]:{}).zeroLine),r=It(s,2),o=r[0],l=r[1];return l-=a,"rect"!==t.nodeName?[[t.childNodes[0],{width:n,height:o},oe,ce],X(t,t.getAttribute("transform").split("(")[1].slice(0,-1),[e,l],ue)]:[[t,{width:n,height:o,x:e,y:l},oe,ce]]}function Z(t,e,i){return"circle"!==t.nodeName?[X(t,t.getAttribute("transform").split("(")[1].slice(0,-1),[e,i],ue)]:[[t,{cx:e,cy:i},oe,ce]]}function tt(t,e,i,n,a){var s=[],r=i.map(function(t,i){return e[i]+","+t}).join("L");a&&(r=y(e,i));var o=[t.path,{d:"M"+r},le,ce];if(s.push(o),t.region){var l=e[0]+","+n+"L",u="L"+e.slice(-1)[0]+", "+n,h=[t.region,{d:"M"+l+r+u},le,ce];s.push(h)}return s}function et(t,e){return[t,{d:e},oe,ce]}function it(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"linear",a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},r=t.cloneNode(!0),o=t.cloneNode(!0);for(var l in e){var u=void 0;u="transform"===l?document.createElementNS("http://www.w3.org/2000/svg","animateTransform"):document.createElementNS("http://www.w3.org/2000/svg","animate");var h=s[l]||t.getAttribute(l),c=e[l],d={attributeName:l,from:h,to:c,begin:"0s",dur:i/1e3+"s",values:h+";"+c,keySplines:de[n],keyTimes:"0;1",calcMode:"spline",fill:"freeze"};a&&(d.type=a);for(var p in d)u.setAttribute(p,d[p]);r.appendChild(u),a?o.setAttribute(l,"translate("+c+")"):o.setAttribute(l,c)}return[r,o]}function nt(t,e){t.style.transform=e,t.style.webkitTransform=e,t.style.msTransform=e,t.style.mozTransform=e,t.style.oTransform=e}function at(t,e){var i=[],n=[];e.map(function(t){var e=t[0],a=e.parentNode,s=void 0,r=void 0;t[0]=e;var o=it.apply(void 0,Rt(t)),l=It(o,2);s=l[0],r=l[1],i.push(r),n.push([s,a]),a.replaceChild(s,e)});var a=t.cloneNode(!0);return n.map(function(t,n){t[1].replaceChild(i[n],t[0]),e[n][0]=i[n]}),a}function st(t,e,i){if(0!==i.length){var n=at(e,i);e.parentNode==t&&(t.removeChild(e),t.appendChild(n)),setTimeout(function(){n.parentNode==t&&(t.removeChild(n),t.appendChild(e))},he)}}function rt(t,e){var i=document.createElement("a");i.style="display: none";var n=new Blob(e,{type:"image/svg+xml; charset=utf-8"}),a=window.URL.createObjectURL(n);i.href=a,i.download=t,document.body.appendChild(i),i.click(),setTimeout(function(){document.body.removeChild(i),window.URL.revokeObjectURL(a)},300)}function ot(e){var i=e.cloneNode(!0);i.classList.add("chart-container"),i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");var n=t.create("style",{innerHTML:pe});i.insertBefore(n,i.firstChild);var a=t.create("div");return a.appendChild(i),a.innerHTML}function lt(t){var e=new Date(t);return e.setMinutes(e.getMinutes()-e.getTimezoneOffset()),e}function ut(t){var e=t.getDate(),i=t.getMonth()+1;return[t.getFullYear(),(i>9?"":"0")+i,(e>9?"":"0")+e].join("-")}function ht(t){return new Date(t.getTime())}function ct(t,e){var i=gt(t);return Math.ceil(dt(i,e)/ge)}function dt(t,e){var i=me*ye;return(lt(e)-lt(t))/i}function pt(t,e){return t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}function ft(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=be[t];return e?i.slice(0,3):i}function vt(t,e){return new Date(e,t+1,0)}function gt(t){var e=ht(t),i=e.getDay();return 0!==i&&yt(e,-1*i),e}function yt(t,e){t.setDate(t.getDate()+e)}function mt(t,e,i){var n=Object.keys(we).filter(function(e){return t.includes(e)}),a=we[n[0]];return Object.assign(a,{constants:e,getData:i}),new ke(a)}function bt(t){if(0===t)return[0,0];if(isNaN(t))return{mantissa:-6755399441055744,exponent:972};var e=t>0?1:-1;if(!isFinite(t))return{mantissa:4503599627370496*e,exponent:972};t=Math.abs(t);var i=Math.floor(Math.log10(t));return[e*(t/Math.pow(10,i)),i]}function xt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=Math.ceil(t),n=Math.floor(e),a=i-n,s=a,r=1;a>5&&(a%2!=0&&(a=++i-n),s=a/2,r=2),a<=2&&(r=a/(s=4)),0===a&&(s=5,r=1);for(var o=[],l=0;l<=s;l++)o.push(n+r*l);return o}function kt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=bt(t),n=It(i,2),a=n[0],s=n[1],r=e?e/Math.pow(10,s):0,o=xt(a=a.toFixed(6),r);return o=o.map(function(t){return t*Math.pow(10,s)})}function wt(t){function e(t,e){for(var i=kt(t),n=i[1]-i[0],a=0,s=1;a<e;s++)a+=n,i.unshift(-1*a);return i}var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=Math.max.apply(Math,Rt(t)),a=Math.min.apply(Math,Rt(t)),s=[];if(n>=0&&a>=0)bt(n)[1],s=i?kt(n,a):kt(n);else if(n>0&&a<0){var r=Math.abs(a);n>=r?(bt(n)[1],s=e(n,r)):(bt(r)[1],s=e(r,n).map(function(t){return-1*t}))}else if(n<=0&&a<=0){var o=Math.abs(a),l=Math.abs(n);bt(o)[1],s=(s=i?kt(o,l):kt(o)).reverse().map(function(t){return-1*t})}return s}function At(t){var e=Pt(t);return t.indexOf(0)>=0?t.indexOf(0):t[0]>0?-1*t[0]/e:-1*t[t.length-1]/e+(t.length-1)}function Pt(t){return t[1]-t[0]}function Lt(t){return t[t.length-1]-t[0]}function Tt(t,e){return u(e.zeroLine-t*e.scaleMultiplier)}function Mt(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=e.reduce(function(e,i){return Math.abs(i-t)<Math.abs(e-t)?i:e},[]);return i?e.indexOf(n):n}function Ct(t,e){for(var i=Math.max.apply(Math,Rt(t)),n=1/(e-1),a=[],s=0;s<e;s++){var r=i*(n*s);a.push(r)}return a}function Ot(t,e){return e.filter(function(e){return e<t}).length}function Dt(t,e){t.labels=t.labels||[];var i=t.labels.length,n=t.datasets,a=new Array(i).fill(0);return n||(n=[{values:a}]),n.map(function(t){if(t.values){var n=t.values;n=(n=n.map(function(t){return isNaN(t)?0:t})).length>i?n.slice(0,i):h(n,i-n.length,0)}else t.values=a;t.chartType||(Vt.includes(e),t.chartType=e)}),t.yRegions&&t.yRegions.map(function(t){if(t.end<t.start){var e=[t.end,t.start];t.start=e[0],t.end=e[1]}}),t}function Nt(t){var e=t.labels.length,i=new Array(e).fill(0),n={labels:t.labels.slice(0,-1),datasets:t.datasets.map(function(t){return{name:"",values:i.slice(0,-1),chartType:t.chartType}})};return t.yMarkers&&(n.yMarkers=[{value:0,label:""}]),t.yRegions&&(n.yRegions=[{start:0,end:0,label:""}]),n}function St(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=t/e.length;n<=0&&(n=1);var a=n/Gt;return e.map(function(t,e){return(t+="").length>a&&(i?e%Math.ceil(t.length/a)!=0&&(t=""):t=a-3>0?t.slice(0,a-3)+" ...":t.slice(0,a)+".."),t})}function Et(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"line",e=arguments[1],i=arguments[2];return"axis-mixed"===t?(i.type="line",new Te(e,i)):Ce[t]?new Ce[t](e,i):void console.error("Undefined chart type: "+t)}!function(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===i&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=t:a.appendChild(document.createTextNode(t))}}('.chart-container{position:relative;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif}.chart-container .axis,.chart-container .chart-label{fill:#555b51}.chart-container .axis line,.chart-container .chart-label line{stroke:#dadada}.chart-container .dataset-units circle{stroke:#fff;stroke-width:2}.chart-container .dataset-units path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container .dataset-path{stroke-width:2px}.chart-container .path-group path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container line.dashed{stroke-dasharray:5,3}.chart-container .axis-line .specific-value{text-anchor:start}.chart-container .axis-line .y-line{text-anchor:end}.chart-container .axis-line .x-line{text-anchor:middle}.chart-container .legend-dataset-text{fill:#6c7680;font-weight:600}.graph-svg-tip{position:absolute;z-index:99999;padding:10px;font-size:12px;color:#959da5;text-align:center;background:rgba(0,0,0,.8);border-radius:3px}.graph-svg-tip ol,.graph-svg-tip ul{padding-left:0;display:-webkit-box;display:-ms-flexbox;display:flex}.graph-svg-tip ul.data-point-list li{min-width:90px;-webkit-box-flex:1;-ms-flex:1;flex:1;font-weight:600}.graph-svg-tip strong{color:#dfe2e5;font-weight:600}.graph-svg-tip .svg-pointer{position:absolute;height:5px;margin:0 0 0 -5px;content:" ";border:5px solid transparent;border-top-color:rgba(0,0,0,.8)}.graph-svg-tip.comparison{padding:0;text-align:left;pointer-events:none}.graph-svg-tip.comparison .title{display:block;padding:10px;margin:0;font-weight:600;line-height:1;pointer-events:none}.graph-svg-tip.comparison ul{margin:0;white-space:nowrap;list-style:none}.graph-svg-tip.comparison li{display:inline-block;padding:5px 10px}');var _t="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},zt=(function(){function t(t){this.value=t}function e(e){function i(t,e){return new Promise(function(i,a){var o={key:t,arg:e,resolve:i,reject:a,next:null};r?r=r.next=o:(s=r=o,n(t,e))})}function n(i,s){try{var r=e[i](s),o=r.value;o instanceof t?Promise.resolve(o.value).then(function(t){n("next",t)},function(t){n("throw",t)}):a(r.done?"return":"normal",r.value)}catch(t){a("throw",t)}}function a(t,e){switch(t){case"return":s.resolve({value:e,done:!0});break;case"throw":s.reject(e);break;default:s.resolve({value:e,done:!1})}(s=s.next)?n(s.key,s.arg):r=null}var s,r;this._invoke=i,"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),Wt=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),Ht=function t(e,i,n){null===e&&(e=Function.prototype);var a=Object.getOwnPropertyDescriptor(e,i);if(void 0===a){var s=Object.getPrototypeOf(e);return null===s?void 0:t(s,i,n)}if("value"in a)return a.value;var r=a.get;if(void 0!==r)return r.call(n)},Ft=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},jt=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},It=function(){function t(t,e){var i=[],n=!0,a=!1,s=void 0;try{for(var r,o=t[Symbol.iterator]();!(n=(r=o.next()).done)&&(i.push(r.value),!e||i.length!==e);n=!0);}catch(t){a=!0,s=t}finally{try{!n&&o.return&&o.return()}finally{if(a)throw s}}return i}return function(e,i){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),Rt=function(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)};t.create=function(e,i){var n=document.createElement(e);for(var a in i){var s=i[a];if("inside"===a)t(s).appendChild(n);else if("around"===a){var r=t(s);r.parentNode.insertBefore(n,r),n.appendChild(r)}else"styles"===a?"object"===(void 0===s?"undefined":_t(s))&&Object.keys(s).map(function(t){n.style[t]=s[t]}):a in n?n[a]=s:n.setAttribute(a,s)}return n};var Yt={margins:{top:10,bottom:10,left:20,right:20},paddings:{top:20,bottom:40,left:30,right:10},baseHeight:240,titleHeight:20,legendHeight:30,titleFontSize:12},Bt=700,Vt=["line","bar"],Ut=2,Gt=7,qt=["light-blue","blue","violet","red","orange","yellow","green","light-green","purple","magenta","light-grey","dark-grey"],Xt={bar:qt,line:qt,pie:qt,percentage:qt,heatmap:["#ebedf0","#c6e48b","#7bc96f","#239a3b","#196127"],donut:qt},Jt=Math.PI/180,Kt=function(){function e(t){var i=t.parent,n=void 0===i?null:i,a=t.colors,s=void 0===a?[]:a;zt(this,e),this.parent=n,this.colors=s,this.titleName="",this.titleValue="",this.listValues=[],this.titleValueFirst=0,this.x=0,this.y=0,this.top=0,this.left=0,this.setup()}return Wt(e,[{key:"setup",value:function(){this.makeTooltip()}},{key:"refresh",value:function(){this.fill(),this.calcPosition()}},{key:"makeTooltip",value:function(){var e=this;this.container=t.create("div",{inside:this.parent,className:"graph-svg-tip comparison",innerHTML:'<span class="title"></span>\n\t\t\t\t<ul class="data-point-list"></ul>\n\t\t\t\t<div class="svg-pointer"></div>'}),this.hideTip(),this.title=this.container.querySelector(".title"),this.dataPointList=this.container.querySelector(".data-point-list"),this.parent.addEventListener("mouseleave",function(){e.hideTip()})}},{key:"fill",value:function(){var e=this,i=void 0;this.index&&this.container.setAttribute("data-point-index",this.index),i=this.titleValueFirst?"<strong>"+this.titleValue+"</strong>"+this.titleName:this.titleName+"<strong>"+this.titleValue+"</strong>",this.title.innerHTML=i,this.dataPointList.innerHTML="",this.listValues.map(function(i,n){var a=e.colors[n]||"black",s=0===i.formatted||i.formatted?i.formatted:i.value,r=t.create("li",{styles:{"border-top":"3px solid "+a},innerHTML:'<strong style="display: block;">'+(0===s||s?s:"")+"</strong>\n\t\t\t\t\t"+(i.title?i.title:"")});e.dataPointList.appendChild(r)})}},{key:"calcPosition",value:function(){var t=this.container.offsetWidth;this.top=this.y-this.container.offsetHeight-5,this.left=this.x-t/2;var e=this.parent.offsetWidth-t,i=this.container.querySelector(".svg-pointer");if(this.left<0)i.style.left="calc(50% - "+-1*this.left+"px)",this.left=0;else if(this.left>e){var n="calc(50% + "+(this.left-e)+"px)";i.style.left=n,this.left=e}else i.style.left="50%"}},{key:"setValues",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1;this.titleName=i.name,this.titleValue=i.value,this.listValues=n,this.x=t,this.y=e,this.titleValueFirst=i.valueFirst||0,this.index=a,this.refresh()}},{key:"hideTip",value:function(){this.container.style.top="0px",this.container.style.left="0px",this.container.style.opacity="0"}},{key:"showTip",value:function(){this.container.style.top=this.top+"px",this.container.style.left=this.left+"px",this.container.style.opacity="1"}}]),e}(),$t={"light-blue":"#7cd6fd",blue:"#5e64ff",violet:"#743ee2",red:"#ff5858",orange:"#ffa00a",yellow:"#feef72",green:"#28a745","light-green":"#98d85b",purple:"#b554ff",magenta:"#ffa3ef",black:"#36114C",grey:"#bdd3e6","light-grey":"#f0f4f7","dark-grey":"#b8c2cc"},Qt=function(t){return $t[t]||t},Zt=6,te=4,ee=15,ie=10,ne="#dadada",ae="#555b51",se={bar:function(t){var e=void 0;"rect"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);var i=t.cloneNode();return i.style.fill="#000000",i.style.opacity="0.4",e&&i.setAttribute("transform",e),i},dot:function(t){var e=void 0;"circle"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);var i=t.cloneNode(),n=t.getAttribute("r"),a=t.getAttribute("fill");return i.setAttribute("r",parseInt(n)+4),i.setAttribute("fill",a),i.style.opacity="0.6",e&&i.setAttribute("transform",e),i},heat_square:function(t){var e=void 0;"circle"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);var i=t.cloneNode(),n=t.getAttribute("r"),a=t.getAttribute("fill");return i.setAttribute("r",parseInt(n)+4),i.setAttribute("fill",a),i.style.opacity="0.6",e&&i.setAttribute("transform",e),i}},re={bar:function(t,e){var i=void 0;"rect"!==t.nodeName&&(i=t.getAttribute("transform"),t=t.childNodes[0]);var n=["x","y","width","height"];Object.values(t.attributes).filter(function(t){return n.includes(t.name)&&t.specified}).map(function(t){e.setAttribute(t.name,t.nodeValue)}),i&&e.setAttribute("transform",i)},dot:function(t,e){var i=void 0;"circle"!==t.nodeName&&(i=t.getAttribute("transform"),t=t.childNodes[0]);var n=["cx","cy"];Object.values(t.attributes).filter(function(t){return n.includes(t.name)&&t.specified}).map(function(t){e.setAttribute(t.name,t.nodeValue)}),i&&e.setAttribute("transform",i)},heat_square:function(t,e){var i=void 0;"circle"!==t.nodeName&&(i=t.getAttribute("transform"),t=t.childNodes[0]);var n=["cx","cy"];Object.values(t.attributes).filter(function(t){return n.includes(t.name)&&t.specified}).map(function(t){e.setAttribute(t.name,t.nodeValue)}),i&&e.setAttribute("transform",i)}},oe=350,le=350,ue=oe,he=250,ce="easein",de={ease:"0.25 0.1 0.25 1",linear:"0 0 1 1",easein:"0.1 0.8 0.2 1",easeout:"0 0 0.58 1",easeinout:"0.42 0 0.58 1"},pe=".chart-container{position:relative;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Roboto','Oxygen','Ubuntu','Cantarell','Fira Sans','Droid Sans','Helvetica Neue',sans-serif}.chart-container .axis,.chart-container .chart-label{fill:#555b51}.chart-container .axis line,.chart-container .chart-label line{stroke:#dadada}.chart-container .dataset-units circle{stroke:#fff;stroke-width:2}.chart-container .dataset-units path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container .dataset-path{stroke-width:2px}.chart-container .path-group path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container line.dashed{stroke-dasharray:5,3}.chart-container .axis-line .specific-value{text-anchor:start}.chart-container .axis-line .y-line{text-anchor:end}.chart-container .axis-line .x-line{text-anchor:middle}.chart-container .legend-dataset-text{fill:#6c7680;font-weight:600}.graph-svg-tip{position:absolute;z-index:99999;padding:10px;font-size:12px;color:#959da5;text-align:center;background:rgba(0,0,0,.8);border-radius:3px}.graph-svg-tip ul{padding-left:0;display:flex}.graph-svg-tip ol{padding-left:0;display:flex}.graph-svg-tip ul.data-point-list li{min-width:90px;flex:1;font-weight:600}.graph-svg-tip strong{color:#dfe2e5;font-weight:600}.graph-svg-tip .svg-pointer{position:absolute;height:5px;margin:0 0 0 -5px;content:' ';border:5px solid transparent;border-top-color:rgba(0,0,0,.8)}.graph-svg-tip.comparison{padding:0;text-align:left;pointer-events:none}.graph-svg-tip.comparison .title{display:block;padding:10px;margin:0;font-weight:600;line-height:1;pointer-events:none}.graph-svg-tip.comparison ul{margin:0;white-space:nowrap;list-style:none}.graph-svg-tip.comparison li{display:inline-block;padding:5px 10px}",fe=function(){function e(t,i){if(zt(this,e),this.parent="string"==typeof t?document.querySelector(t):t,!(this.parent instanceof HTMLElement))throw new Error("No `parent` element to render on was provided.");this.rawChartArgs=i,this.title=i.title||"",this.type=i.type||"",this.realData=this.prepareData(i.data),this.data=this.prepareFirstData(this.realData),this.colors=this.validateColors(i.colors,this.type),this.config={showTooltip:1,showLegend:1,isNavigable:i.isNavigable||0,animate:void 0!==i.animate?i.animate:1,truncateLegends:i.truncateLegends||0},this.measures=JSON.parse(JSON.stringify(Yt));var n=this.measures;this.setMeasures(i),this.title.length||(n.titleHeight=0),this.config.showLegend||(n.legendHeight=0),this.argHeight=i.height||n.baseHeight,this.state={},this.options={},this.initTimeout=Bt,this.config.isNavigable&&(this.overlays=[]),this.configure(i)}return Wt(e,[{key:"prepareData",value:function(t){return t}},{key:"prepareFirstData",value:function(t){return t}},{key:"validateColors",value:function(t,e){var i=[];return(t=(t||[]).concat(Xt[e])).forEach(function(t){var e=Qt(t);x(e)?i.push(e):console.warn('"'+t+'" is not a valid color.')}),i}},{key:"setMeasures",value:function(){}},{key:"configure",value:function(){var t=this,e=this.argHeight;this.baseHeight=e,this.height=e-o(this.measures),this.boundDrawFn=function(){return t.draw(!0)},window.addEventListener("resize",this.boundDrawFn),window.addEventListener("orientationchange",this.boundDrawFn)}},{key:"destroy",value:function(){window.removeEventListener("resize",this.boundDrawFn),window.removeEventListener("orientationchange",this.boundDrawFn)}},{key:"setup",value:function(){this.makeContainer(),this.updateWidth(),this.makeTooltip(),this.draw(!1,!0)}},{key:"makeContainer",value:function(){this.parent.innerHTML="";var e={inside:this.parent,className:"chart-container"};this.independentWidth&&(e.styles={width:this.independentWidth+"px"}),this.container=t.create("div",e)}},{key:"makeTooltip",value:function(){this.tip=new Kt({parent:this.container,colors:this.colors}),this.bindTooltip()}},{key:"bindTooltip",value:function(){}},{key:"draw",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.updateWidth(),this.calc(e),this.makeChartArea(),this.setupComponents(),this.components.forEach(function(e){return e.setup(t.drawArea)}),this.render(this.components,!1),i&&(this.data=this.realData,setTimeout(function(){t.update(t.data)},this.initTimeout)),this.renderLegend(),this.setupNavigation(i)}},{key:"calc",value:function(){}},{key:"updateWidth",value:function(){this.baseWidth=n(this.parent),this.width=this.baseWidth-l(this.measures)}},{key:"makeChartArea",value:function(){this.svg&&this.container.removeChild(this.svg);var t=this.measures;this.svg=L(this.container,"frappe-chart chart",this.baseWidth,this.baseHeight),this.svgDefs=T(this.svg),this.title.length&&(this.titleEL=F("title",t.margins.left,t.margins.top,this.title,{fontSize:t.titleFontSize,fill:"#666666",dy:t.titleFontSize}));var e=s(t);this.drawArea=M(this.type+"-chart chart-draw-area","translate("+r(t)+", "+e+")"),this.config.showLegend&&(e+=this.height+t.paddings.bottom,this.legendArea=M("chart-legend","translate("+r(t)+", "+e+")")),this.title.length&&this.svg.appendChild(this.titleEL),this.svg.appendChild(this.drawArea),this.config.showLegend&&this.svg.appendChild(this.legendArea),this.updateTipOffset(r(t),s(t))}},{key:"updateTipOffset",value:function(t,e){this.tip.offset={x:t,y:e}}},{key:"setupComponents",value:function(){this.components=new Map}},{key:"update",value:function(t){t||console.error("No data to update."),this.data=this.prepareData(t),this.calc(),this.render(this.components,this.config.animate)}},{key:"render",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.components,i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.config.isNavigable&&this.overlays.map(function(t){return t.parentNode.removeChild(t)});var n=[];e.forEach(function(t){n=n.concat(t.update(i))}),n.length>0?(st(this.container,this.svg,n),setTimeout(function(){e.forEach(function(t){return t.make()}),t.updateNav()},400)):(e.forEach(function(t){return t.make()}),this.updateNav())}},{key:"updateNav",value:function(){this.config.isNavigable&&(this.makeOverlay(),this.bindUnits())}},{key:"renderLegend",value:function(){}},{key:"setupNavigation",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.config.isNavigable&&e&&(this.bindOverlay(),this.keyActions={13:this.onEnterKey.bind(this),37:this.onLeftArrow.bind(this),38:this.onUpArrow.bind(this),39:this.onRightArrow.bind(this),40:this.onDownArrow.bind(this)},document.addEventListener("keydown",function(e){i(t.container)&&(e=e||window.event,t.keyActions[e.keyCode]&&t.keyActions[e.keyCode]())}))}},{key:"makeOverlay",value:function(){}},{key:"updateOverlay",value:function(){}},{key:"bindOverlay",value:function(){}},{key:"bindUnits",value:function(){}},{key:"onLeftArrow",value:function(){}},{key:"onRightArrow",value:function(){}},{key:"onUpArrow",value:function(){}},{key:"onDownArrow",value:function(){}},{key:"onEnterKey",value:function(){}},{key:"addDataPoint",value:function(){}},{key:"removeDataPoint",value:function(){}},{key:"getDataPoint",value:function(){}},{key:"setCurrentDataPoint",value:function(){}},{key:"updateDataset",value:function(){}},{key:"export",value:function(){var t=ot(this.svg);rt(this.title||"Chart",[t])}}]),e}(),ve=function(t){function e(t,i){return zt(this,e),jt(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,i))}return Ft(e,t),Wt(e,[{key:"configure",value:function(t){Ht(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"configure",this).call(this,t),this.config.maxSlices=t.maxSlices||20,this.config.maxLegendPoints=t.maxLegendPoints||20}},{key:"calc",value:function(){var t=this,e=this.state,i=this.config.maxSlices;e.sliceTotals=[];var n=this.data.labels.map(function(e,i){var n=0;return t.data.datasets.map(function(t){n+=t.values[i]}),[n,e]}).filter(function(t){return t[0]>=0}),a=n;if(n.length>i){n.sort(function(t,e){return e[0]-t[0]}),a=n.slice(0,i-1);var s=0;n.slice(i-1).map(function(t){s+=t[0]}),a.push([s,"Rest"]),this.colors[i-1]="grey"}e.labels=[],a.map(function(t){e.sliceTotals.push(t[0]),e.labels.push(t[1])}),e.grandTotal=e.sliceTotals.reduce(function(t,e){return t+e},0),this.center={x:this.width/2,y:this.height/2}}},{key:"renderLegend",value:function(){var t=this,e=this.state;this.legendArea.textContent="",this.legendTotals=e.sliceTotals.slice(0,this.config.maxLegendPoints);var i=0,n=0;this.legendTotals.map(function(a,s){var r=110,o=Math.floor((t.width-l(t.measures))/r);t.legendTotals.length<o&&(r=t.width/t.legendTotals.length),i>o&&(i=0,n+=20);var u=H(r*i+5,n,5,t.colors[s],e.labels[s]+": "+a,t.config.truncateLegends);t.legendArea.appendChild(u),i++})}}]),e}(fe),ge=7,ye=1e3,me=86400,be=["January","February","March","April","May","June","July","August","September","October","November","December"],xe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],ke=function(){function t(e){var i=e.layerClass,n=void 0===i?"":i,a=e.layerTransform,s=void 0===a?"":a,r=e.constants,o=e.getData,l=e.makeElements,u=e.animateElements;zt(this,t),this.layerTransform=s,this.constants=r,this.makeElements=l,this.getData=o,this.animateElements=u,this.store=[],this.labels=[],this.layerClass=n,this.layerClass="function"==typeof this.layerClass?this.layerClass():this.layerClass,this.refresh()}return Wt(t,[{key:"refresh",value:function(t){this.data=t||this.getData()}},{key:"setup",value:function(t){this.layer=M(this.layerClass,this.layerTransform,t)}},{key:"make",value:function(){this.render(this.data),this.oldData=this.data}},{key:"render",value:function(t){var e=this;this.store=this.makeElements(t),this.layer.textContent="",this.store.forEach(function(t){e.layer.appendChild(t)}),this.labels.forEach(function(t){e.layer.appendChild(t)})}},{key:"update",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.refresh();var e=[];return t&&(e=this.animateElements(this.data)||[]),e}}]),t}(),we={donutSlices:{layerClass:"donut-slices",makeElements:function(t){return t.sliceStrings.map(function(e,i){var n=C(e,"donut-path",t.colors[i],"none",t.strokeWidth);return n.style.transition="transform .3s;",n})},animateElements:function(t){return this.store.map(function(e,i){return et(e,t.sliceStrings[i])})}},pieSlices:{layerClass:"pie-slices",makeElements:function(t){return t.sliceStrings.map(function(e,i){var n=C(e,"pie-path","none",t.colors[i]);return n.style.transition="transform .3s;",n})},animateElements:function(t){return this.store.map(function(e,i){return et(e,t.sliceStrings[i])})}},percentageBars:{layerClass:"percentage-bars",makeElements:function(t){var e=this;return t.xPositions.map(function(i,n){return _(i,0,t.widths[n],e.constants.barHeight,e.constants.barDepth,t.colors[n])})},animateElements:function(t){if(t)return[]}},yAxis:{layerClass:"y axis",makeElements:function(t){var e=this;return t.positions.map(function(i,n){return R(i,t.labels[n],e.constants.width,{mode:e.constants.mode,pos:e.constants.pos,shortenNumbers:e.constants.shortenNumbers})})},animateElements:function(t){var e=t.positions,i=t.labels,n=this.oldData.positions,a=this.oldData.labels,s=f(n,e),r=It(s,2);n=r[0],e=r[1];var o=f(a,i),l=It(o,2);return a=l[0],i=l[1],this.render({positions:n,labels:i}),this.store.map(function(t,i){return K(t,e[i],n[i])})}},xAxis:{layerClass:"x axis",makeElements:function(t){var e=this;return t.positions.map(function(i,n){return Y(i,t.calcLabels[n],e.constants.height,{mode:e.constants.mode,pos:e.constants.pos})})},animateElements:function(t){var e=t.positions,i=t.calcLabels,n=this.oldData.positions,a=this.oldData.calcLabels,s=f(n,e),r=It(s,2);n=r[0],e=r[1];var o=f(a,i),l=It(o,2);return a=l[0],i=l[1],this.render({positions:n,calcLabels:i}),this.store.map(function(t,i){return J(t,e[i],n[i])})}},yMarkers:{layerClass:"y-markers",makeElements:function(t){var e=this;return t.map(function(t){return B(t.position,t.label,e.constants.width,{labelPos:t.options.labelPos,mode:"span",lineType:"dashed"})})},animateElements:function(t){var e=f(this.oldData,t),i=It(e,2);this.oldData=i[0];var n=(t=i[1]).map(function(t){return t.position}),a=t.map(function(t){return t.label}),s=t.map(function(t){return t.options}),r=this.oldData.map(function(t){return t.position});return this.render(r.map(function(t,e){return{position:r[e],label:a[e],options:s[e]}})),this.store.map(function(t,e){return K(t,n[e],r[e])})}},yRegions:{layerClass:"y-regions",makeElements:function(t){var e=this;return t.map(function(t){return V(t.startPos,t.endPos,e.constants.width,t.label,{labelPos:t.options.labelPos})})},animateElements:function(t){var e=f(this.oldData,t),i=It(e,2);this.oldData=i[0];var n=(t=i[1]).map(function(t){return t.endPos}),a=t.map(function(t){return t.label}),s=t.map(function(t){return t.startPos}),r=t.map(function(t){return t.options}),o=this.oldData.map(function(t){return t.endPos}),l=this.oldData.map(function(t){return t.startPos});this.render(o.map(function(t,e){return{startPos:l[e],endPos:o[e],label:a[e],options:r[e]}}));var u=[];return this.store.map(function(t,e){u=u.concat($(t,s[e],n[e],o[e]))}),u}},heatDomain:{layerClass:function(){return"heat-domain domain-"+this.constants.index},makeElements:function(t){var e=this,i=this.constants,n=i.index,a=i.colWidth,s=i.rowHeight,r=i.squareSize,o=i.xTranslate,l=0;return this.serializedSubDomains=[],t.cols.map(function(t,i){1===i&&e.labels.push(F("domain-name",o,-12,ft(n,!0).toUpperCase(),{fontSize:9})),t.map(function(t,i){if(t.fill){var n={"data-date":t.yyyyMmDd,"data-value":t.dataValue,"data-day":i},a=z("day",o,l,r,t.fill,n);e.serializedSubDomains.push(a)}l+=s}),l=0,o+=a}),this.serializedSubDomains},animateElements:function(t){if(t)return[]}},barGraph:{layerClass:function(){return"dataset-units dataset-bars dataset-"+this.constants.index},makeElements:function(t){var e=this.constants;return this.unitType="bar",this.units=t.yPositions.map(function(i,n){return U(t.xPositions[n],i,t.barWidth,e.color,t.labels[n],n,t.offsets[n],{zeroLine:t.zeroLine,barsWidth:t.barsWidth,minHeight:e.minHeight})}),this.units},animateElements:function(t){var e=t.xPositions,i=t.yPositions,n=t.offsets,a=t.labels,s=this.oldData.xPositions,r=this.oldData.yPositions,o=this.oldData.offsets,l=this.oldData.labels,u=f(s,e),h=It(u,2);s=h[0],e=h[1];var c=f(r,i),d=It(c,2);r=d[0],i=d[1];var p=f(o,n),v=It(p,2);o=v[0],n=v[1];var g=f(l,a),y=It(g,2);l=y[0],a=y[1],this.render({xPositions:s,yPositions:r,offsets:o,labels:a,zeroLine:this.oldData.zeroLine,barsWidth:this.oldData.barsWidth,barWidth:this.oldData.barWidth});var m=[];return this.store.map(function(a,s){m=m.concat(Q(a,e[s],i[s],t.barWidth,n[s],{zeroLine:t.zeroLine}))}),m}},lineGraph:{layerClass:function(){return"dataset-units dataset-line dataset-"+this.constants.index},makeElements:function(t){var e=this.constants;return this.unitType="dot",this.paths={},e.hideLine||(this.paths=q(t.xPositions,t.yPositions,e.color,{heatline:e.heatline,regionFill:e.regionFill,spline:e.spline},{svgDefs:e.svgDefs,zeroLine:t.zeroLine})),this.units=[],e.hideDots||(this.units=t.yPositions.map(function(i,n){return G(t.xPositions[n],i,t.radius,e.color,e.valuesOverPoints?t.values[n]:"",n)})),Object.values(this.paths).concat(this.units)},animateElements:function(t){var e=t.xPositions,i=t.yPositions,n=t.values,a=this.oldData.xPositions,s=this.oldData.yPositions,r=this.oldData.values,o=f(a,e),l=It(o,2);a=l[0],e=l[1];var u=f(s,i),h=It(u,2);s=h[0],i=h[1];var c=f(r,n),d=It(c,2);r=d[0],n=d[1],this.render({xPositions:a,yPositions:s,values:n,zeroLine:this.oldData.zeroLine,radius:this.oldData.radius});var p=[];return Object.keys(this.paths).length&&(p=p.concat(tt(this.paths,e,i,t.zeroLine,this.constants.spline))),this.units.length&&this.units.map(function(t,n){p=p.concat(Z(t,e[n],i[n]))}),p}}},Ae=function(t){function i(t,e){zt(this,i);var n=jt(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t,e));return n.type="percentage",n.setup(),n}return Ft(i,t),Wt(i,[{key:"setMeasures",value:function(t){var e=this.measures;this.barOptions=t.barOptions||{};var i=this.barOptions;i.height=i.height||20,i.depth=i.depth||Ut,e.paddings.right=30,e.legendHeight=60,e.baseHeight=8*(i.height+.5*i.depth)}},{key:"setupComponents",value:function(){var t=this.state,e=[["percentageBars",{barHeight:this.barOptions.height,barDepth:this.barOptions.depth},function(){return{xPositions:t.xPositions,widths:t.widths,colors:this.colors}}.bind(this)]];this.components=new Map(e.map(function(t){var e=mt.apply(void 0,Rt(t));return[t[0],e]}))}},{key:"calc",value:function(){var t=this;Ht(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"calc",this).call(this);var e=this.state;e.xPositions=[],e.widths=[];var n=0;e.sliceTotals.map(function(i){var a=t.width*i/e.grandTotal;e.widths.push(a),e.xPositions.push(n),n+=a})}},{key:"makeDataByIndex",value:function(){}},{key:"bindTooltip",value:function(){var t=this,i=this.state;this.container.addEventListener("mousemove",function(n){var a=t.components.get("percentageBars").store,s=n.target;if(a.includes(s)){var r=a.indexOf(s),o=e(t.container),l=e(s),u=l.left-o.left+parseInt(s.getAttribute("width"))/2,h=l.top-o.top,c=(t.formattedLabels&&t.formattedLabels.length>0?t.formattedLabels[r]:t.state.labels[r])+": ",d=i.sliceTotals[r]/i.grandTotal;t.tip.setValues(u,h,{name:c,value:(100*d).toFixed(1)+"%"}),t.tip.showTip()}})}}]),i}(ve),Pe=function(t){function i(t,e){zt(this,i);var n=jt(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t,e));return n.type="pie",n.initTimeout=0,n.init=1,n.setup(),n}return Ft(i,t),Wt(i,[{key:"configure",value:function(t){Ht(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"configure",this).call(this,t),this.mouseMove=this.mouseMove.bind(this),this.mouseLeave=this.mouseLeave.bind(this),this.hoverRadio=t.hoverRadio||.1,this.config.startAngle=t.startAngle||0,this.clockWise=t.clockWise||!1}},{key:"calc",value:function(){var t=this;Ht(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"calc",this).call(this);var e=this.state;this.radius=this.height>this.width?this.center.x:this.center.y;var n=this.radius,a=this.clockWise,s=e.slicesProperties||[];e.sliceStrings=[],e.slicesProperties=[];var r=180-this.config.startAngle;e.sliceTotals.map(function(i,o){var l=r,u=i/e.grandTotal*360,h=u>180?1:0,c=a?-u:u,p=r+=c,f=d(l,n),v=d(p,n),g=t.init&&s[o],y=void 0,m=void 0;t.init?(y=g?g.startPosition:f,m=g?g.endPosition:f):(y=f,m=v);var b=360===u?D(y,m,t.center,t.radius,a,h):O(y,m,t.center,t.radius,a,h);e.sliceStrings.push(b),e.slicesProperties.push({startPosition:f,endPosition:v,value:i,total:e.grandTotal,startAngle:l,endAngle:p,angle:c})}),this.init=0}},{key:"setupComponents",value:function(){var t=this.state,e=[["pieSlices",{},function(){return{sliceStrings:t.sliceStrings,colors:this.colors}}.bind(this)]];this.components=new Map(e.map(function(t){var e=mt.apply(void 0,Rt(t));return[t[0],e]}))}},{key:"calTranslateByAngle",value:function(t){var e=this.radius,i=this.hoverRadio,n=d(t.startAngle+t.angle/2,e);return"translate3d("+n.x*i+"px,"+n.y*i+"px,0)"}},{key:"hoverSlice",value:function(t,i,n,a){if(t){var s=this.colors[i];if(n){nt(t,this.calTranslateByAngle(this.state.slicesProperties[i])),t.style.fill=b(s,50);var r=e(this.svg),o=a.pageX-r.left+10,l=a.pageY-r.top-10,u=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[i]:this.state.labels[i])+": ",h=(100*this.state.sliceTotals[i]/this.state.grandTotal).toFixed(1);this.tip.setValues(o,l,{name:u,value:h+"%"}),this.tip.showTip()}else nt(t,"translate3d(0,0,0)"),this.tip.hideTip(),t.style.fill=s}}},{key:"bindTooltip",value:function(){this.container.addEventListener("mousemove",this.mouseMove),this.container.addEventListener("mouseleave",this.mouseLeave)}},{key:"mouseMove",value:function(t){var e=t.target,i=this.components.get("pieSlices").store,n=this.curActiveSliceIndex,a=this.curActiveSlice;if(i.includes(e)){var s=i.indexOf(e);this.hoverSlice(a,n,!1),this.curActiveSlice=e,this.curActiveSliceIndex=s,this.hoverSlice(e,s,!0,t)}else this.mouseLeave()}},{key:"mouseLeave",value:function(){this.hoverSlice(this.curActiveSlice,this.curActiveSliceIndex,!1)}}]),i}(ve),Le=function(t){function e(t,i){zt(this,e);var n=jt(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,i));n.type="heatmap",n.countLabel=i.countLabel||"";var a=["Sunday","Monday"],s=a.includes(i.startSubDomain)?i.startSubDomain:"Sunday";return n.startSubDomainIndex=a.indexOf(s),n.setup(),n}return Ft(e,t),Wt(e,[{key:"setMeasures",value:function(t){var e=this.measures;this.discreteDomains=0===t.discreteDomains?0:1,e.paddings.top=36,e.paddings.bottom=0,e.legendHeight=24,e.baseHeight=12*ge+o(e);var i=this.data,n=this.discreteDomains?12:0;this.independentWidth=12*(ct(i.start,i.end)+n)+l(e)}},{key:"updateWidth",value:function(){var t=this.discreteDomains?12:0,e=this.state.noOfWeeks?this.state.noOfWeeks:52;this.baseWidth=12*(e+t)+l(this.measures)}},{key:"prepareData",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.data;if(t.start&&t.end&&t.start>t.end)throw new Error("Start date cannot be greater than end date.");if(t.start||(t.start=new Date,t.start.setFullYear(t.start.getFullYear()-1)),t.end||(t.end=new Date),t.dataPoints=t.dataPoints||{},parseInt(Object.keys(t.dataPoints)[0])>1e5){var e={};Object.keys(t.dataPoints).forEach(function(i){var n=new Date(i*ye);e[ut(n)]=t.dataPoints[i]}),t.dataPoints=e}return t}},{key:"calc",value:function(){var t=this.state;t.start=ht(this.data.start),t.end=ht(this.data.end),t.firstWeekStart=ht(t.start),t.noOfWeeks=ct(t.start,t.end),t.distribution=Ct(Object.values(this.data.dataPoints),5),t.domainConfigs=this.getDomains()}},{key:"setupComponents",value:function(){var t=this,e=this.state,i=this.discreteDomains?0:1,n=e.domainConfigs.map(function(n,a){return["heatDomain",{index:n.index,colWidth:12,rowHeight:12,squareSize:10,xTranslate:12*e.domainConfigs.filter(function(t,e){return e<a}).map(function(t){return t.cols.length-i}).reduce(function(t,e){return t+e},0)},function(){return e.domainConfigs[a]}.bind(t)]});this.components=new Map(n.map(function(t,e){var i=mt.apply(void 0,Rt(t));return[t[0]+"-"+e,i]}));var a=0;xe.forEach(function(e,i){if([1,3,5].includes(i)){var n=F("subdomain-name",-6,a,e,{fontSize:10,dy:8,textAnchor:"end"});t.drawArea.appendChild(n)}a+=12})}},{key:"update",value:function(t){t||console.error("No data to update."),this.data=this.prepareData(t),this.draw(),this.bindTooltip()}},{key:"bindTooltip",value:function(){var t=this;this.container.addEventListener("mousemove",function(e){t.components.forEach(function(i){var n=i.store,a=e.target;if(n.includes(a)){var s=a.getAttribute("data-value"),r=a.getAttribute("data-date").split("-"),o=ft(parseInt(r[1])-1,!0),l=t.container.getBoundingClientRect(),u=a.getBoundingClientRect(),h=parseInt(e.target.getAttribute("width")),c=u.left-l.left+h/2,d=u.top-l.top,p=s+" "+t.countLabel,f=" on "+o+" "+r[0]+", "+r[2];t.tip.setValues(c,d,{name:f,value:p,valueFirst:1},[]),t.tip.showTip()}})})}},{key:"renderLegend",value:function(){var t=this;this.legendArea.textContent="";var e=0,i=F("subdomain-name",e,12,"Less",{fontSize:11,dy:9});e=30,this.legendArea.appendChild(i),this.colors.slice(0,5).map(function(i,n){var a=z("heatmap-legend-unit",e+15*n,12,10,i);t.legendArea.appendChild(a)});var n=F("subdomain-name",e+75+3,12,"More",{fontSize:11,dy:9});this.legendArea.appendChild(n)}},{key:"getDomains",value:function(){for(var t=this.state,e=[t.start.getMonth(),t.start.getFullYear()],i=e[0],n=e[1],a=[t.end.getMonth(),t.end.getFullYear()],s=a[0]-i+1+12*(a[1]-n),r=[],o=ht(t.start),l=0;l<s;l++){var u=t.end;if(!pt(o,t.end)){var h=[o.getMonth(),o.getFullYear()];u=vt(h[0],h[1])}r.push(this.getDomainConfig(o,u)),yt(u,1),o=u}return r}},{key:"getDomainConfig",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=[t.getMonth(),t.getFullYear()],n=i[0],a=i[1],s=gt(t),r={index:n,cols:[]};yt(e=ht(e)||vt(n,a),1);for(var o=ct(s,e),l=[],u=void 0,h=0;h<o;h++)u=this.getCol(s,n),l.push(u),yt(s=new Date(u[ge-1].yyyyMmDd),1);return void 0!==u[ge-1].dataValue&&(yt(s,1),l.push(this.getCol(s,n,!0))),r.cols=l,r}},{key:"getCol",value:function(t,e){for(var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=this.state,a=ht(t),s=[],r=0;r<ge;r++,yt(a,1)){var o={},l=a>=n.start&&a<=n.end;i||a.getMonth()!==e||!l?o.yyyyMmDd=ut(a):o=this.getSubDomainConfig(a),s.push(o)}return s}},{key:"getSubDomainConfig",value:function(t){var e=ut(t),i=this.data.dataPoints[e];return{yyyyMmDd:e,dataValue:i||0,fill:this.colors[Ot(i,this.state.distribution)]}}}]),e}(fe),Te=function(t){function i(t,e){zt(this,i);var n=jt(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t,e));return n.barOptions=e.barOptions||{},n.lineOptions=e.lineOptions||{},n.type=e.type||"line",n.init=1,n.setup(),n}return Ft(i,t),Wt(i,[{key:"setMeasures",value:function(){this.data.datasets.length<=1&&(this.config.showLegend=0,this.measures.paddings.bottom=30)}},{key:"configure",value:function(t){Ht(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"configure",this).call(this,t),t.axisOptions=t.axisOptions||{},t.tooltipOptions=t.tooltipOptions||{},this.config.xAxisMode=t.axisOptions.xAxisMode||"span",this.config.yAxisMode=t.axisOptions.yAxisMode||"span",this.config.xIsSeries=t.axisOptions.xIsSeries||0,this.config.shortenYAxisNumbers=t.axisOptions.shortenYAxisNumbers||0,this.config.formatTooltipX=t.tooltipOptions.formatTooltipX,this.config.formatTooltipY=t.tooltipOptions.formatTooltipY,this.config.valuesOverPoints=t.valuesOverPoints}},{key:"prepareData",value:function(){return Dt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.data,this.type)}},{key:"prepareFirstData",value:function(){return Nt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.data)}},{key:"calc",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.calcXPositions(),t||this.calcYAxisParameters(this.getAllYValues(),"line"===this.type),this.makeDataByIndex()}},{key:"calcXPositions",value:function(){var t=this.state,e=this.data.labels;t.datasetLength=e.length,t.unitWidth=this.width/t.datasetLength,t.xOffset=t.unitWidth/2,t.xAxis={labels:e,positions:e.map(function(e,i){return u(t.xOffset+i*t.unitWidth)})}}},{key:"calcYAxisParameters",value:function(t){var e=wt(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:"false"),i=this.height/Lt(e),n=Pt(e)*i,a=this.height-At(e)*n;this.state.yAxis={labels:e,positions:e.map(function(t){return a-t*i}),scaleMultiplier:i,zeroLine:a},this.calcDatasetPoints(),this.calcYExtremes(),this.calcYRegions()}},{key:"calcDatasetPoints",value:function(){var t=this.state,e=function(e){return e.map(function(e){return Tt(e,t.yAxis)})};t.datasets=this.data.datasets.map(function(t,i){var n=t.values,a=t.cumulativeYs||[];return{name:t.name,index:i,chartType:t.chartType,values:n,yPositions:e(n),cumulativeYs:a,cumulativeYPos:e(a)}})}},{key:"calcYExtremes",value:function(){var t=this.state;if(this.barOptions.stacked)return void(t.yExtremes=t.datasets[t.datasets.length-1].cumulativeYPos);t.yExtremes=new Array(t.datasetLength).fill(9999),t.datasets.map(function(e){e.yPositions.map(function(e,i){e<t.yExtremes[i]&&(t.yExtremes[i]=e)})})}},{key:"calcYRegions",value:function(){var t=this.state;this.data.yMarkers&&(this.state.yMarkers=this.data.yMarkers.map(function(e){return e.position=Tt(e.value,t.yAxis),e.options||(e.options={}),e})),this.data.yRegions&&(this.state.yRegions=this.data.yRegions.map(function(e){return e.startPos=Tt(e.start,t.yAxis),e.endPos=Tt(e.end,t.yAxis),e.options||(e.options={}),e}))}},{key:"getAllYValues",value:function(){var t,e=this,i="values";if(this.barOptions.stacked){i="cumulativeYs";var n=new Array(this.state.datasetLength).fill(0);this.data.datasets.map(function(t,a){var s=e.data.datasets[a].values;t[i]=n=n.map(function(t,e){return t+s[e]})})}var a=this.data.datasets.map(function(t){return t[i]});return this.data.yMarkers&&a.push(this.data.yMarkers.map(function(t){return t.value})),this.data.yRegions&&this.data.yRegions.map(function(t){a.push([t.end,t.start])}),(t=[]).concat.apply(t,Rt(a))}},{key:"setupComponents",value:function(){var t=this,e=[["yAxis",{mode:this.config.yAxisMode,width:this.width,shortenNumbers:this.config.shortenYAxisNumbers},function(){return this.state.yAxis}.bind(this)],["xAxis",{mode:this.config.xAxisMode,height:this.height},function(){var t=this.state;return t.xAxis.calcLabels=St(this.width,t.xAxis.labels,this.config.xIsSeries),t.xAxis}.bind(this)],["yRegions",{width:this.width,pos:"right"},function(){return this.state.yRegions}.bind(this)]],i=this.state.datasets.filter(function(t){return"bar"===t.chartType}),n=this.state.datasets.filter(function(t){return"line"===t.chartType}),a=i.map(function(e){var n=e.index;return["barGraph-"+e.index,{index:n,color:t.colors[n],stacked:t.barOptions.stacked,valuesOverPoints:t.config.valuesOverPoints,minHeight:0*t.height},function(){var t=this.state,e=t.datasets[n],a=this.barOptions.stacked,s=this.barOptions.spaceRatio||.5,r=t.unitWidth*(1-s),o=r/(a?1:i.length),l=t.xAxis.positions.map(function(t){return t-r/2});a||(l=l.map(function(t){return t+o*n}));var u=new Array(t.datasetLength).fill("");this.config.valuesOverPoints&&(u=a&&e.index===t.datasets.length-1?e.cumulativeYs:e.values);var h=new Array(t.datasetLength).fill(0);return a&&(h=e.yPositions.map(function(t,i){return t-e.cumulativeYPos[i]})),{xPositions:l,yPositions:e.yPositions,offsets:h,labels:u,zeroLine:t.yAxis.zeroLine,barsWidth:r,barWidth:o}}.bind(t)]}),s=n.map(function(e){var i=e.index;return["lineGraph-"+e.index,{index:i,color:t.colors[i],svgDefs:t.svgDefs,heatline:t.lineOptions.heatline,regionFill:t.lineOptions.regionFill,spline:t.lineOptions.spline,hideDots:t.lineOptions.hideDots,hideLine:t.lineOptions.hideLine,valuesOverPoints:t.config.valuesOverPoints},function(){var t=this.state,e=t.datasets[i],n=t.yAxis.positions[0]<t.yAxis.zeroLine?t.yAxis.positions[0]:t.yAxis.zeroLine;return{xPositions:t.xAxis.positions,yPositions:e.yPositions,values:e.values,zeroLine:n,radius:this.lineOptions.dotSize||4}}.bind(t)]}),r=[["yMarkers",{width:this.width,pos:"right"},function(){return this.state.yMarkers}.bind(this)]];e=e.concat(a,s,r);var o=["yMarkers","yRegions"];this.dataUnitComponents=[],this.components=new Map(e.filter(function(e){return!o.includes(e[0])||t.state[e[0]]}).map(function(e){var i=mt.apply(void 0,Rt(e));return(e[0].includes("lineGraph")||e[0].includes("barGraph"))&&t.dataUnitComponents.push(i),[e[0],i]}))}},{key:"makeDataByIndex",value:function(){var t=this;this.dataByIndex={};var e=this.state,i=this.config.formatTooltipX,n=this.config.formatTooltipY;e.xAxis.labels.map(function(a,s){var r=t.state.datasets.map(function(e,i){var a=e.values[s];return{title:e.name,value:a,yPos:e.yPositions[s],color:t.colors[i],formatted:n?n(a):a}});t.dataByIndex[s]={label:a,formattedLabel:i?i(a):a,xPos:e.xAxis.positions[s],values:r,yExtreme:e.yExtremes[s]}})}},{key:"bindTooltip",value:function(){var t=this;this.container.addEventListener("mousemove",function(i){var n=t.measures,a=e(t.container),o=i.pageX-a.left-r(n),l=i.pageY-a.top;l<t.height+s(n)&&l>s(n)?t.mapTooltipXPosition(o):t.tip.hideTip()})}},{key:"mapTooltipXPosition",value:function(t){var e=this.state;if(e.yExtremes){var i=Mt(t,e.xAxis.positions,!0),n=this.dataByIndex[i];this.tip.setValues(n.xPos+this.tip.offset.x,n.yExtreme+this.tip.offset.y,{name:n.formattedLabel,value:""},n.values,i),this.tip.showTip()}}},{key:"renderLegend",value:function(){var t=this,e=this.data;e.datasets.length>1&&(this.legendArea.textContent="",e.datasets.map(function(e,i){var n=W(100*i,"0",100,t.colors[i],e.name,t.config.truncateLegends);t.legendArea.appendChild(n)}))}},{key:"makeOverlay",value:function(){var t=this;if(this.init)return void(this.init=0);this.overlayGuides&&this.overlayGuides.forEach(function(t){var e=t.overlay;e.parentNode.removeChild(e)}),this.overlayGuides=this.dataUnitComponents.map(function(t){return{type:t.unitType,overlay:void 0,units:t.units}}),void 0===this.state.currentIndex&&(this.state.currentIndex=this.state.datasetLength-1),this.overlayGuides.map(function(e){var i=e.units[t.state.currentIndex];e.overlay=se[e.type](i),t.drawArea.appendChild(e.overlay)})}},{key:"updateOverlayGuides",value:function(){this.overlayGuides&&this.overlayGuides.forEach(function(t){var e=t.overlay;e.parentNode.removeChild(e)})}},{key:"bindOverlay",value:function(){var t=this;this.parent.addEventListener("data-select",function(){t.updateOverlay()})}},{key:"bindUnits",value:function(){var t=this;this.dataUnitComponents.map(function(e){e.units.map(function(e){e.addEventListener("click",function(){var i=e.getAttribute("data-point-index");t.setCurrentDataPoint(i)})})}),this.tip.container.addEventListener("click",function(){var e=t.tip.container.getAttribute("data-point-index");t.setCurrentDataPoint(e)})}},{key:"updateOverlay",value:function(){var t=this;this.overlayGuides.map(function(e){var i=e.units[t.state.currentIndex];re[e.type](i,e.overlay)})}},{key:"onLeftArrow",value:function(){this.setCurrentDataPoint(this.state.currentIndex-1)}},{key:"onRightArrow",value:function(){this.setCurrentDataPoint(this.state.currentIndex+1)}},{key:"getDataPoint",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state.currentIndex,e=this.state;return{index:t,label:e.xAxis.labels[t],values:e.datasets.map(function(e){return e.values[t]})}}},{key:"setCurrentDataPoint",value:function(t){var e=this.state;(t=parseInt(t))<0&&(t=0),t>=e.xAxis.labels.length&&(t=e.xAxis.labels.length-1),t!==e.currentIndex&&(e.currentIndex=t,a(this.parent,"data-select",this.getDataPoint()))}},{key:"addDataPoint",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.state.datasetLength;Ht(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"addDataPoint",this).call(this,t,e,n),this.data.labels.splice(n,0,t),this.data.datasets.map(function(t,i){t.values.splice(n,0,e[i])}),this.update(this.data)}},{key:"removeDataPoint",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state.datasetLength-1;this.data.labels.length<=1||(Ht(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"removeDataPoint",this).call(this,t),this.data.labels.splice(t,1),this.data.datasets.map(function(e){e.values.splice(t,1)}),this.update(this.data))}},{key:"updateDataset",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.data.datasets[e].values=t,this.update(this.data)}},{key:"updateDatasets",value:function(t){this.data.datasets.map(function(e,i){t[i]&&(e.values=t[i])}),this.update(this.data)}}]),i}(fe),Me=function(t){function i(t,e){zt(this,i);var n=jt(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t,e));return n.type="donut",n.initTimeout=0,n.init=1,n.setup(),n}return Ft(i,t),Wt(i,[{key:"configure",value:function(t){Ht(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"configure",this).call(this,t),this.mouseMove=this.mouseMove.bind(this),this.mouseLeave=this.mouseLeave.bind(this),this.hoverRadio=t.hoverRadio||.1,this.config.startAngle=t.startAngle||0,this.clockWise=t.clockWise||!1,this.strokeWidth=t.strokeWidth||30}},{key:"calc",value:function(){var t=this;Ht(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"calc",this).call(this);var e=this.state;this.radius=this.height>this.width?this.center.x-this.strokeWidth/2:this.center.y-this.strokeWidth/2;var n=this.radius,a=this.clockWise,s=e.slicesProperties||[];e.sliceStrings=[],e.slicesProperties=[];var r=180-this.config.startAngle;e.sliceTotals.map(function(i,o){var l=r,u=i/e.grandTotal*360,h=u>180?1:0,c=a?-u:u,p=r+=c,f=d(l,n),v=d(p,n),g=t.init&&s[o],y=void 0,m=void 0;t.init?(y=g?g.startPosition:f,m=g?g.endPosition:f):(y=f,m=v);var b=360===u?S(y,m,t.center,t.radius,t.clockWise,h):N(y,m,t.center,t.radius,t.clockWise,h);e.sliceStrings.push(b),e.slicesProperties.push({startPosition:f,endPosition:v,value:i,total:e.grandTotal,startAngle:l,endAngle:p,angle:c})}),this.init=0}},{key:"setupComponents",value:function(){var t=this.state,e=[["donutSlices",{},function(){return{sliceStrings:t.sliceStrings,colors:this.colors,strokeWidth:this.strokeWidth}}.bind(this)]];this.components=new Map(e.map(function(t){var e=mt.apply(void 0,Rt(t));return[t[0],e]}))}},{key:"calTranslateByAngle",value:function(t){var e=this.radius,i=this.hoverRadio,n=d(t.startAngle+t.angle/2,e);return"translate3d("+n.x*i+"px,"+n.y*i+"px,0)"}},{key:"hoverSlice",value:function(t,i,n,a){if(t){var s=this.colors[i];if(n){nt(t,this.calTranslateByAngle(this.state.slicesProperties[i])),t.style.stroke=b(s,50);var r=e(this.svg),o=a.pageX-r.left+10,l=a.pageY-r.top-10,u=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[i]:this.state.labels[i])+": ",h=(100*this.state.sliceTotals[i]/this.state.grandTotal).toFixed(1);this.tip.setValues(o,l,{name:u,value:h+"%"}),this.tip.showTip()}else nt(t,"translate3d(0,0,0)"),this.tip.hideTip(),t.style.stroke=s}}},{key:"bindTooltip",value:function(){this.container.addEventListener("mousemove",this.mouseMove),this.container.addEventListener("mouseleave",this.mouseLeave)}},{key:"mouseMove",value:function(t){var e=t.target,i=this.components.get("donutSlices").store,n=this.curActiveSliceIndex,a=this.curActiveSlice;if(i.includes(e)){var s=i.indexOf(e);this.hoverSlice(a,n,!1),this.curActiveSlice=e,this.curActiveSliceIndex=s,this.hoverSlice(e,s,!0,t)}else this.mouseLeave()}},{key:"mouseLeave",value:function(){this.hoverSlice(this.curActiveSlice,this.curActiveSliceIndex,!1)}}]),i}(ve),Ce={bar:Te,line:Te,percentage:Ae,heatmap:Le,pie:Pe,donut:Me},Oe=function t(e,i){return zt(this,t),Et(i.type,e,i)},De=Object.freeze({Chart:Oe,PercentageChart:Ae,PieChart:Pe,Heatmap:Le,AxisChart:Te}),Ne={};return Ne.NAME="Frappe Charts",Ne.VERSION="1.3.0",Ne=Object.assign({},Ne,De)}();
  983. //# sourceMappingURL=frappe-charts.min.iife.js.map
  984. </script>
  985. <script>HTMLWidgets.widget({
  986. name: 'frappeChart',
  987. type: 'output',
  988. factory: function(el, width, height) {
  989. // TODO: define shared variables for this instance
  990. return {
  991. renderValue: function(x) {
  992. const chartData = {labels: [], datasets: []}
  993. // Get keys of data, assume that first entry is for labels, the rest are data
  994. let labelColumn = Object.keys(x.data)[0]
  995. let columns = Object.keys(x.data).slice(1)
  996. // First column in x.data is the labels
  997. chartData.labels = x.data[labelColumn]
  998. // Create an appropriate object for each column, reformat data and add to chartData
  999. columns.forEach(function(col) {
  1000. chartData.datasets.push({name: col, values: x.data[col]})
  1001. })
  1002. x.data = chartData
  1003. const chart = new frappe.Chart(el, x)
  1004. },
  1005. resize: function(width, height) {
  1006. // TODO: code to re-render the widget with a new size
  1007. }
  1008. };
  1009. }
  1010. });
  1011. </script>
  1012. </head>
  1013. <body>
  1014. <div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" data-line-number="1"><span class="kw">library</span>(dplyr)</a>
  1015. <a class="sourceLine" id="cb1-2" data-line-number="2"><span class="kw">library</span>(tidyr)</a>
  1016. <a class="sourceLine" id="cb1-3" data-line-number="3"><span class="kw">library</span>(babynames)</a>
  1017. <a class="sourceLine" id="cb1-4" data-line-number="4"></a>
  1018. <a class="sourceLine" id="cb1-5" data-line-number="5">data &lt;-</a>
  1019. <a class="sourceLine" id="cb1-6" data-line-number="6"><span class="st"> </span>babynames <span class="op">%&gt;%</span><span class="st"> </span></a>
  1020. <a class="sourceLine" id="cb1-7" data-line-number="7"><span class="st"> </span><span class="kw">filter</span>(</a>
  1021. <a class="sourceLine" id="cb1-8" data-line-number="8"> name <span class="op">%in%</span><span class="st"> </span><span class="kw">c</span>(<span class="st">&quot;Ruth&quot;</span>, <span class="st">&quot;August&quot;</span>),</a>
  1022. <a class="sourceLine" id="cb1-9" data-line-number="9"> year <span class="op">&gt;=</span><span class="st"> </span><span class="dv">1980</span></a>
  1023. <a class="sourceLine" id="cb1-10" data-line-number="10"> ) <span class="op">%&gt;%</span><span class="st"> </span></a>
  1024. <a class="sourceLine" id="cb1-11" data-line-number="11"><span class="st"> </span><span class="kw">group_by</span>(year, name) <span class="op">%&gt;%</span><span class="st"> </span></a>
  1025. <a class="sourceLine" id="cb1-12" data-line-number="12"><span class="st"> </span><span class="kw">summarize</span>(<span class="dt">n =</span> <span class="kw">sum</span>(n)) <span class="op">%&gt;%</span><span class="st"> </span></a>
  1026. <a class="sourceLine" id="cb1-13" data-line-number="13"><span class="st"> </span><span class="kw">ungroup</span>() <span class="op">%&gt;%</span><span class="st"> </span></a>
  1027. <a class="sourceLine" id="cb1-14" data-line-number="14"><span class="st"> </span><span class="kw">pivot_wider</span>(year, name, <span class="dt">values_from =</span> n)</a>
  1028. <a class="sourceLine" id="cb1-15" data-line-number="15"></a>
  1029. <a class="sourceLine" id="cb1-16" data-line-number="16">frappeCharts<span class="op">::</span><span class="kw">frappeChart</span>(</a>
  1030. <a class="sourceLine" id="cb1-17" data-line-number="17"> data,</a>
  1031. <a class="sourceLine" id="cb1-18" data-line-number="18"> <span class="dt">title =</span> <span class="st">&quot;This. Is. Awwesome.&quot;</span>, </a>
  1032. <a class="sourceLine" id="cb1-19" data-line-number="19"> <span class="dt">elementId =</span> <span class="st">&quot;name-chart&quot;</span>,</a>
  1033. <a class="sourceLine" id="cb1-20" data-line-number="20"> <span class="dt">lineOptions =</span> <span class="kw">list</span>(<span class="dt">regionFill =</span> <span class="ot">TRUE</span>),</a>
  1034. <a class="sourceLine" id="cb1-21" data-line-number="21"> <span class="dt">axisOptions =</span> <span class="kw">list</span>(<span class="dt">xIsSeries =</span> <span class="ot">TRUE</span>),</a>
  1035. <a class="sourceLine" id="cb1-22" data-line-number="22"> <span class="dt">colors =</span> <span class="kw">c</span>(<span class="st">&quot;#466683&quot;</span>, <span class="st">&quot;#44bc96&quot;</span>),</a>
  1036. <a class="sourceLine" id="cb1-23" data-line-number="23"> <span class="dt">width =</span> <span class="st">&quot;100%&quot;</span>,</a>
  1037. <a class="sourceLine" id="cb1-24" data-line-number="24"> <span class="dt">tooltipOptions =</span> <span class="kw">list</span>(</a>
  1038. <a class="sourceLine" id="cb1-25" data-line-number="25"> <span class="dt">formatTooltipX =</span> htmlwidgets<span class="op">::</span><span class="kw">JS</span>(<span class="st">&quot;d =&gt; 'Year: ' + d&quot;</span>),</a>
  1039. <a class="sourceLine" id="cb1-26" data-line-number="26"> <span class="dt">formatTooltipY =</span> htmlwidgets<span class="op">::</span><span class="kw">JS</span>(<span class="st">&quot;d =&gt; d + ' babies'&quot;</span>)</a>
  1040. <a class="sourceLine" id="cb1-27" data-line-number="27"> )</a>
  1041. <a class="sourceLine" id="cb1-28" data-line-number="28">)</a></code></pre></div>
  1042. <div id="name-chart" style="width:100%;height:250px;" class="frappeChart html-widget"></div>
  1043. <script type="application/json" data-for="name-chart">{"x":{"title":"This. Is. Awwesome.","type":"line","height":250,"data":{"year":[1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017],"August":[149,137,130,135,142,146,155,145,147,181,169,183,194,211,255,327,316,377,425,368,409,387,378,376,375,431,470,512,690,760,758,837,1077,1170,1769,2331,2313,2295],"Ruth":[1262,1272,1193,1135,1174,1125,1096,1040,1012,997,913,990,853,863,880,858,801,856,850,870,903,943,900,888,905,906,889,958,929,912,929,901,926,986,1057,1102,1094,1194]},"isNavigable":true,"lineOptions":{"regionFill":true},"axisOptions":{"xIsSeries":true},"colors":["#466683","#44bc96"],"tooltipOptions":{"formatTooltipX":"d => 'Year: ' + d","formatTooltipY":"d => d + ' babies'"}},"evals":["tooltipOptions.formatTooltipX","tooltipOptions.formatTooltipY"],"jsHooks":[]}</script>
  1044. </body>
  1045. </html>