Skip to content

Commit

Permalink
update D3, add new option for charts and fix minor bug
Browse files Browse the repository at this point in the history
- Update to D3 7.2.1
- add option to set threshold for pie, donut and gauge charts #3
- fix bug in custome tooltip in charts #2
- update license to 2022
  • Loading branch information
RonnyWeiss committed Dec 21, 2021
1 parent 2230986 commit 359d42d
Show file tree
Hide file tree
Showing 6 changed files with 4,542 additions and 4,473 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Ronny Weiss
Copyright (c) 2022 Ronny Weiss

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions apexplugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "APEX D3 Dashboard Charts",
"version": "2.6.6.17",
"version": "2.6.6.18",
"description": "Create with only one SQL statement one or more D3 charts with different configurations and different chart types. Possible are among other things: Bar, line, area, pie, gauge, donut, step and stack charts.\r\n\r\nAll things such as chart type, number of series, colors, size, data points and chart configurations can be adjusted at runtime by the SQL statement and reset again and again by refresh.<p><b>Important clarification: My work in the development team of Oracle APEX is in no way related to my open source projects or the plug-ins here on apex.world! All plug-ins are built in my spare time and are not supported by Oracle!</b></p>",
"keywords": ["oracle", "apex", "plugin", "charts", "region", "responsive", "d3"],
"homepage": "https://github.com/RonnyWeiss/APEX-D3-Dashboard-Charts",
Expand All @@ -22,7 +22,7 @@
"oracle": {
"versions": ["12.2.0.1", "18.4.0.0", "19.0.0.0.0", "19.2.0.0.19", "21.0.0.0.0", "21.1.0.0.0", "21.1.0.0.1"],
"apex": {
"versions": ["5.1.3", "18.1.0.00.45", "18.2.0.00.12", "19.1.0.00.15", "19.2.0.00.18", "20.1.0.00.13", "20.2.0.00.20", "21.1.0"],
"versions": ["18.1.0.00.45", "18.2.0.00.12", "19.1.0.00.15", "19.2.0.00.18", "20.1.0.00.13", "20.2.0.00.20", "21.1.0", "21.2.0"],
"plugin": {
"internalName": "APEX.D3.DASHBOARD.CHARTS",
"type": "region",
Expand Down
2 changes: 1 addition & 1 deletion build/d3dashboard.pkgd.min.js

Large diffs are not rendered by default.

90 changes: 80 additions & 10 deletions js/lib/d3.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// https://d3js.org v7.1.1 Copyright 2010-2021 Mike Bostock
// https://d3js.org v7.2.1 Copyright 2010-2021 Mike Bostock
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3 = global.d3 || {}));
})(this, (function (exports) { 'use strict';

var version = "7.1.1";
var version = "7.2.1";

function ascending$3(a, b) {
return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
Expand Down Expand Up @@ -13394,7 +13394,8 @@ function partition() {
}

var preroot = {depth: -1},
ambiguous = {};
ambiguous = {},
imputed = {};

function defaultId(d) {
return d.id;
Expand All @@ -13406,11 +13407,14 @@ function defaultParentId(d) {

function stratify() {
var id = defaultId,
parentId = defaultParentId;
parentId = defaultParentId,
path;

function stratify(data) {
var nodes = Array.from(data),
n = nodes.length,
currentId = id,
currentParentId = parentId,
n,
d,
i,
root,
Expand All @@ -13420,13 +13424,29 @@ function stratify() {
nodeKey,
nodeByKey = new Map;

for (i = 0; i < n; ++i) {
if (path != null) {
const I = nodes.map((d, i) => normalize$1(path(d, i, data)));
const P = I.map(parentof);
const S = new Set(I).add("");
for (const i of P) {
if (!S.has(i)) {
S.add(i);
I.push(i);
P.push(parentof(i));
nodes.push(imputed);
}
}
currentId = (_, i) => I[i];
currentParentId = (_, i) => P[i];
}

for (i = 0, n = nodes.length; i < n; ++i) {
d = nodes[i], node = nodes[i] = new Node$1(d);
if ((nodeId = id(d, i, data)) != null && (nodeId += "")) {
if ((nodeId = currentId(d, i, data)) != null && (nodeId += "")) {
nodeKey = node.id = nodeId;
nodeByKey.set(nodeKey, nodeByKey.has(nodeKey) ? ambiguous : node);
}
if ((nodeId = parentId(d, i, data)) != null && (nodeId += "")) {
if ((nodeId = currentParentId(d, i, data)) != null && (nodeId += "")) {
node.parent = nodeId;
}
}
Expand All @@ -13447,6 +13467,20 @@ function stratify() {
}

if (!root) throw new Error("no root");

// When imputing internal nodes, only introduce roots if needed.
// Then replace the imputed marker data with null.
if (path != null) {
while (root.data === imputed && root.children.length === 1) {
root = root.children[0], --n;
}
for (let i = nodes.length - 1; i >= 0; --i) {
node = nodes[i];
if (node.data !== imputed) break;
node.data = null;
}
}

root.parent = preroot;
root.eachBefore(function(node) { node.depth = node.parent.depth + 1; --n; }).eachBefore(computeHeight);
root.parent = null;
Expand All @@ -13456,16 +13490,52 @@ function stratify() {
}

stratify.id = function(x) {
return arguments.length ? (id = required(x), stratify) : id;
return arguments.length ? (id = optional(x), stratify) : id;
};

stratify.parentId = function(x) {
return arguments.length ? (parentId = required(x), stratify) : parentId;
return arguments.length ? (parentId = optional(x), stratify) : parentId;
};

stratify.path = function(x) {
return arguments.length ? (path = optional(x), stratify) : path;
};

return stratify;
}

// To normalize a path, we coerce to a string, strip the trailing slash if any
// (as long as the trailing slash is not immediately preceded by another slash),
// and add leading slash if missing.
function normalize$1(path) {
path = `${path}`;
let i = path.length;
if (slash(path, i - 1) && !slash(path, i - 2)) path = path.slice(0, -1);
return path[0] === "/" ? path : `/${path}`;
}

// Walk backwards to find the first slash that is not the leading slash, e.g.:
// "/foo/bar" ⇥ "/foo", "/foo" ⇥ "/", "/" ↦ "". (The root is special-cased
// because the id of the root must be a truthy value.)
function parentof(path) {
let i = path.length;
if (i < 2) return "";
while (--i > 1) if (slash(path, i)) break;
return path.slice(0, i);
}

// Slashes can be escaped; to determine whether a slash is a path delimiter, we
// count the number of preceding backslashes escaping the forward slash: an odd
// number indicates an escaped forward slash.
function slash(path, i) {
if (path[i] === "/") {
let k = 0;
while (i > 0 && path[--i] === "\\") ++k;
if ((k & 1) === 0) return true;
}
return false;
}

function defaultSeparation(a, b) {
return a.parent === b.parent ? 1 : 2;
}
Expand Down
16 changes: 10 additions & 6 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var apexDashboardChart = function (apex, $) {
var util = {
featureDetails: {
name: "APEX-D3Dashboard-Charts",
scriptVersion: "2.6.6.17",
scriptVersion: "2.6.6.19",
utilVersion: "1.4",
url: "https://github.com/RonnyWeiss",
url2: "https://ronnyweiss.app",
Expand Down Expand Up @@ -250,6 +250,7 @@ var apexDashboardChart = function (apex, $) {
"showDataLabels": false,
"showDataPoints": true,
"showAbsoluteValues": false,
"threshold": 0.05,
"tooltip": {
"grouped": true,
"show": true
Expand Down Expand Up @@ -728,6 +729,8 @@ var apexDashboardChart = function (apex, $) {
var zoomType = setObjectParameter(pConfigData.zoomType, pDefaultConfig.d3chart.zoom.type);
var showSubChart = false;

var charThreshold = setObjectParameter(pConfigData.threshold, pDefaultConfig.d3chart.threshold);

if (zoomEnabled) {
if (zoomType == "scroll") {
showSubChart = false;
Expand Down Expand Up @@ -912,12 +915,13 @@ var apexDashboardChart = function (apex, $) {
index = 0
}
if (seriesData[key][index] && util.isDefinedAndNotNull(seriesData[key][index].tooltip)) {
var subDiv = $("<div>");
var ttS = seriesData[key][index].tooltip;
if (pRequireHTMLEscape !== false) {
ttS = util.escapeHTML(ttS);
}
div.append(ttS);
div.append("<br>");
subDiv.append(ttS);
div.append(subDiv);
}
}
});
Expand Down Expand Up @@ -959,13 +963,13 @@ var apexDashboardChart = function (apex, $) {
pie: {
label: {
format: absoluteFormatting,
threshold: 0.05
threshold: charThreshold
}
},
donut: {
label: {
format: absoluteFormatting,
threshold: 0.05
threshold: charThreshold
}
},
line: {
Expand All @@ -976,7 +980,7 @@ var apexDashboardChart = function (apex, $) {
gauge: {
label: {
format: absoluteFormatting,
threshold: (gaugeType === "single") ? 0.05 : null
threshold: charThreshold
},
fullCircle: gaugeFullCircle,
min: gaugeMin,
Expand Down
Loading

0 comments on commit 359d42d

Please sign in to comment.