Skip to content

Commit fee344a

Browse files
author
ydaniju
committed
upgrade d3
1 parent 697be0c commit fee344a

6 files changed

Lines changed: 31 additions & 30 deletions

File tree

assets/js/Ioda/components/modal/RawSignalsModal.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ import React, { PureComponent } from "react";
3939
import PropTypes from "prop-types";
4040
import T from "i18n-react";
4141
import Loading from "../../components/loading/Loading";
42-
import LoadingIcon from "images/icons/icon-loading.png";
4342
import Tooltip from "../tooltip/Tooltip";
4443
import TopoMap from "../map/Map";
4544
import Table from "../table/Table";
46-
import * as d3 from "d3-shape";
45+
import { curveStepAfter } from "d3-shape";
4746
import {
4847
horizonChartSeriesColor,
4948
humanizeNumber,
@@ -284,7 +283,7 @@ class RawSignalsModal extends PureComponent {
284283
.height(360)
285284
.enableZoom(false)
286285
.showRuler(true)
287-
.interpolationCurve(d3.curveStepAfter)
286+
.interpolationCurve(curveStepAfter)
288287
.positiveColors(["white", color]).toolTipContent = ({
289288
series,
290289
ts,

assets/js/Ioda/pages/dashboard/DashboardTab.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import TimeStamp from "../../components/timeStamp/TimeStamp";
99
import Tooltip from "../../components/tooltip/Tooltip";
1010
import Table from "../../components/table/Table";
1111
import HorizonTSChart from "horizon-timeseries-chart";
12-
import * as d3 from "d3-shape";
12+
import { curveStepAfter } from "d3-shape";
1313
import TopoMap from "../../components/map/Map";
1414
import { Button } from "antd";
1515
import { asn } from "./DashboardConstants";
@@ -75,7 +75,7 @@ class DashboardTab extends Component {
7575
.height(570)
7676
.enableZoom(false)
7777
.showRuler(true)
78-
.interpolationCurve(d3.curveStepAfter)
78+
.interpolationCurve(curveStepAfter)
7979
.positiveColors(["white", horizonChartSeriesColor]).toolTipContent = ({
8080
series,
8181
ts,

assets/js/Ioda/utils/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
* IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
3232
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
3333
*/
34-
import d3 from 'd3';
34+
import { geoBounds } from 'd3-geo';
35+
import { format } from 'd3-format';
3536
import T from 'i18n-react';
3637
import { getColorFromLinearScale, getEntityScaleColor } from './mapColors';
3738
import { secondsToUTC } from './timeUtils';
@@ -110,7 +111,7 @@ export const legend = [
110111
// Humanize number with rounding, abbreviations, etc.
111112
export function humanizeNumber(value, precisionDigits) {
112113
precisionDigits = precisionDigits || 3;
113-
return d3.format(
114+
return format(
114115
(isNaN(precisionDigits) ? '' : '.' + precisionDigits)
115116
+ ((Math.abs(value) < 1) ? 'r' : 's')
116117
)(value);
@@ -277,7 +278,7 @@ export function convertTsDataForHtsViz(tsData) {
277278

278279
// take a list of outages that will populate on a map and create a bounding box the map will use for zoom location
279280
export function getOutageCoords(features) {
280-
return features.map(d3.geo.bounds).reduce(function (prev, cur) {
281+
return features.map(geoBounds).reduce(function (prev, cur) {
281282
return [
282283
[
283284
Math.min(prev[0][0], cur[0][0]),

assets/js/Ioda/utils/mapColors.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import d3 from "d3";
1+
import { scaleLinear } from "d3-scale";
22

33
export const LOW_COLOR = "#FFCC3D";
44
export const HIGH_COLOR = "#EE695B";
@@ -61,10 +61,7 @@ export const getColorFromLinearScale = (
6161
minColor = LOW_COLOR,
6262
maxColor = HIGH_COLOR
6363
) => {
64-
const linearScale = d3.scale
65-
.linear()
66-
.domain([minScore, maxScore])
67-
.range([minColor, maxColor]);
64+
const linearScale = scaleLinear([minScore, maxScore], [minColor, maxColor]);
6865

6966
return linearScale(score);
7067
};

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@
5959
"axios": "^1.7.2",
6060
"clsx": "^2.1.1",
6161
"core-js": "^3.37.1",
62-
"d3": "3",
63-
"d3-shape": "^2.1.0",
62+
"d3-format": "^3.1.0",
63+
"d3-geo": "^3.1.1",
64+
"d3-scale": "^4.0.2",
65+
"d3-shape": "^3.2.0",
6466
"dayjs": "^1.11.7",
6567
"fabric": "^5.4.0",
6668
"fabric-history": "^2.0.0",

yarn.lock

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4036,6 +4036,13 @@ cwd@^0.10.0:
40364036
dependencies:
40374037
internmap "1 - 2"
40384038

4039+
"d3-array@2.5.0 - 3":
4040+
version "3.2.4"
4041+
resolved "https://registry.yarnpkg.com/d3-array/-/d3-array-3.2.4.tgz#15fec33b237f97ac5d7c986dc77da273a8ed0bb5"
4042+
integrity sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==
4043+
dependencies:
4044+
internmap "1 - 2"
4045+
40394046
"d3-axis@1 - 3":
40404047
version "3.0.0"
40414048
resolved "https://registry.yarnpkg.com/d3-axis/-/d3-axis-3.0.0.tgz#c42a4a13e8131d637b745fc2973824cfeaf93322"
@@ -4064,7 +4071,7 @@ cwd@^0.10.0:
40644071
resolved "https://registry.yarnpkg.com/d3-ease/-/d3-ease-3.0.1.tgz#9658ac38a2140d59d346160f1f6c30fda0bd12f4"
40654072
integrity sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==
40664073

4067-
"d3-format@1 - 3":
4074+
"d3-format@1 - 3", d3-format@^3.1.0:
40684075
version "3.1.0"
40694076
resolved "https://registry.yarnpkg.com/d3-format/-/d3-format-3.1.0.tgz#9260e23a28ea5cb109e93b21a06e24e2ebd55641"
40704077
integrity sha512-YyUI6AEuY/Wpt8KWLgZHsIU86atmikuoOmCfommt0LYHiQSPjvX2AcFc38PX0CBpr2RCyZhjex+NS/LPOv6YqA==
@@ -4076,6 +4083,13 @@ d3-geo-projection@0.2:
40764083
dependencies:
40774084
brfs "^1.3.0"
40784085

4086+
d3-geo@^3.1.1:
4087+
version "3.1.1"
4088+
resolved "https://registry.yarnpkg.com/d3-geo/-/d3-geo-3.1.1.tgz#6027cf51246f9b2ebd64f99e01dc7c3364033a4d"
4089+
integrity sha512-637ln3gXKXOwhalDzinUgY83KzNWZRKbYubaG+fGVuc/dxO64RRljtCTnf5ecMyE1RIdtqpkVcq0IbtU2S8j2Q==
4090+
dependencies:
4091+
d3-array "2.5.0 - 3"
4092+
40794093
d3-horizon@1:
40804094
version "1.11.2"
40814095
resolved "https://registry.yarnpkg.com/d3-horizon/-/d3-horizon-1.11.2.tgz#a783f6fd51db8a9dce33a6ee8f1c5298e2820be6"
@@ -4097,11 +4111,6 @@ d3-horizon@1:
40974111
dependencies:
40984112
d3-color "1 - 3"
40994113

4100-
"d3-path@1 - 2":
4101-
version "2.0.0"
4102-
resolved "https://registry.yarnpkg.com/d3-path/-/d3-path-2.0.0.tgz#55d86ac131a0548adae241eebfb56b4582dd09d8"
4103-
integrity sha512-ZwZQxKhBnv9yHaiWd6ZU4x5BtCQ7pXszEV9CU6kRgwIQVQGLMv1oiL4M+MK/n79sYzsj+gcgpPQSctJUsLN7fA==
4104-
41054114
d3-path@^3.1.0:
41064115
version "3.1.0"
41074116
resolved "https://registry.yarnpkg.com/d3-path/-/d3-path-3.1.0.tgz#22df939032fb5a71ae8b1800d61ddb7851c42526"
@@ -4112,7 +4121,7 @@ d3-queue@1:
41124121
resolved "https://registry.yarnpkg.com/d3-queue/-/d3-queue-1.2.3.tgz#143a701cfa65fe021292f321c10d14e98abd491b"
41134122
integrity sha512-m6KtxX4V5pmVf1PqhH4SkQVMshSJfyCLM2vf2oFPi9FWFVT3+rtbCGerk766b/JXymHQDU3oqXHaZoiQ/e8yUQ==
41144123

4115-
"d3-scale@1 - 4":
4124+
"d3-scale@1 - 4", d3-scale@^4.0.2:
41164125
version "4.0.2"
41174126
resolved "https://registry.yarnpkg.com/d3-scale/-/d3-scale-4.0.2.tgz#82b38e8e8ff7080764f8dcec77bd4be393689396"
41184127
integrity sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==
@@ -4128,20 +4137,13 @@ d3-queue@1:
41284137
resolved "https://registry.yarnpkg.com/d3-selection/-/d3-selection-3.0.0.tgz#c25338207efa72cc5b9bd1458a1a41901f1e1b31"
41294138
integrity sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==
41304139

4131-
"d3-shape@1 - 3":
4140+
"d3-shape@1 - 3", d3-shape@^3.2.0:
41324141
version "3.2.0"
41334142
resolved "https://registry.yarnpkg.com/d3-shape/-/d3-shape-3.2.0.tgz#a1a839cbd9ba45f28674c69d7f855bcf91dfc6a5"
41344143
integrity sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==
41354144
dependencies:
41364145
d3-path "^3.1.0"
41374146

4138-
d3-shape@^2.1.0:
4139-
version "2.1.0"
4140-
resolved "https://registry.yarnpkg.com/d3-shape/-/d3-shape-2.1.0.tgz#3b6a82ccafbc45de55b57fcf956c584ded3b666f"
4141-
integrity sha512-PnjUqfM2PpskbSLTJvAzp2Wv4CZsnAgTfcVRTwW03QR3MkXF8Uo7B1y/lWkAsmbKwuecto++4NlsYcvYpXpTHA==
4142-
dependencies:
4143-
d3-path "1 - 2"
4144-
41454147
"d3-time-format@1 - 4", "d3-time-format@2 - 4":
41464148
version "4.1.0"
41474149
resolved "https://registry.yarnpkg.com/d3-time-format/-/d3-time-format-4.1.0.tgz#7ab5257a5041d11ecb4fe70a5c7d16a195bb408a"

0 commit comments

Comments
 (0)