Skip to content

Commit

Permalink
upgrade d3
Browse files Browse the repository at this point in the history
  • Loading branch information
ydaniju committed Aug 14, 2024
1 parent 697be0c commit fee344a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 30 deletions.
5 changes: 2 additions & 3 deletions assets/js/Ioda/components/modal/RawSignalsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ import React, { PureComponent } from "react";
import PropTypes from "prop-types";
import T from "i18n-react";
import Loading from "../../components/loading/Loading";
import LoadingIcon from "images/icons/icon-loading.png";
import Tooltip from "../tooltip/Tooltip";
import TopoMap from "../map/Map";
import Table from "../table/Table";
import * as d3 from "d3-shape";
import { curveStepAfter } from "d3-shape";
import {
horizonChartSeriesColor,
humanizeNumber,
Expand Down Expand Up @@ -284,7 +283,7 @@ class RawSignalsModal extends PureComponent {
.height(360)
.enableZoom(false)
.showRuler(true)
.interpolationCurve(d3.curveStepAfter)
.interpolationCurve(curveStepAfter)
.positiveColors(["white", color]).toolTipContent = ({
series,
ts,
Expand Down
4 changes: 2 additions & 2 deletions assets/js/Ioda/pages/dashboard/DashboardTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import TimeStamp from "../../components/timeStamp/TimeStamp";
import Tooltip from "../../components/tooltip/Tooltip";
import Table from "../../components/table/Table";
import HorizonTSChart from "horizon-timeseries-chart";
import * as d3 from "d3-shape";
import { curveStepAfter } from "d3-shape";
import TopoMap from "../../components/map/Map";
import { Button } from "antd";
import { asn } from "./DashboardConstants";
Expand Down Expand Up @@ -75,7 +75,7 @@ class DashboardTab extends Component {
.height(570)
.enableZoom(false)
.showRuler(true)
.interpolationCurve(d3.curveStepAfter)
.interpolationCurve(curveStepAfter)
.positiveColors(["white", horizonChartSeriesColor]).toolTipContent = ({
series,
ts,
Expand Down
7 changes: 4 additions & 3 deletions assets/js/Ioda/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
* IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
import d3 from 'd3';
import { geoBounds } from 'd3-geo';
import { format } from 'd3-format';
import T from 'i18n-react';
import { getColorFromLinearScale, getEntityScaleColor } from './mapColors';
import { secondsToUTC } from './timeUtils';
Expand Down Expand Up @@ -110,7 +111,7 @@ export const legend = [
// Humanize number with rounding, abbreviations, etc.
export function humanizeNumber(value, precisionDigits) {
precisionDigits = precisionDigits || 3;
return d3.format(
return format(
(isNaN(precisionDigits) ? '' : '.' + precisionDigits)
+ ((Math.abs(value) < 1) ? 'r' : 's')
)(value);
Expand Down Expand Up @@ -277,7 +278,7 @@ export function convertTsDataForHtsViz(tsData) {

// take a list of outages that will populate on a map and create a bounding box the map will use for zoom location
export function getOutageCoords(features) {
return features.map(d3.geo.bounds).reduce(function (prev, cur) {
return features.map(geoBounds).reduce(function (prev, cur) {
return [
[
Math.min(prev[0][0], cur[0][0]),
Expand Down
7 changes: 2 additions & 5 deletions assets/js/Ioda/utils/mapColors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import d3 from "d3";
import { scaleLinear } from "d3-scale";

export const LOW_COLOR = "#FFCC3D";
export const HIGH_COLOR = "#EE695B";
Expand Down Expand Up @@ -61,10 +61,7 @@ export const getColorFromLinearScale = (
minColor = LOW_COLOR,
maxColor = HIGH_COLOR
) => {
const linearScale = d3.scale
.linear()
.domain([minScore, maxScore])
.range([minColor, maxColor]);
const linearScale = scaleLinear([minScore, maxScore], [minColor, maxColor]);

return linearScale(score);
};
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@
"axios": "^1.7.2",
"clsx": "^2.1.1",
"core-js": "^3.37.1",
"d3": "3",
"d3-shape": "^2.1.0",
"d3-format": "^3.1.0",
"d3-geo": "^3.1.1",
"d3-scale": "^4.0.2",
"d3-shape": "^3.2.0",
"dayjs": "^1.11.7",
"fabric": "^5.4.0",
"fabric-history": "^2.0.0",
Expand Down
32 changes: 17 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4036,6 +4036,13 @@ cwd@^0.10.0:
dependencies:
internmap "1 - 2"

"d3-array@2.5.0 - 3":
version "3.2.4"
resolved "https://registry.yarnpkg.com/d3-array/-/d3-array-3.2.4.tgz#15fec33b237f97ac5d7c986dc77da273a8ed0bb5"
integrity sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==
dependencies:
internmap "1 - 2"

"d3-axis@1 - 3":
version "3.0.0"
resolved "https://registry.yarnpkg.com/d3-axis/-/d3-axis-3.0.0.tgz#c42a4a13e8131d637b745fc2973824cfeaf93322"
Expand Down Expand Up @@ -4064,7 +4071,7 @@ cwd@^0.10.0:
resolved "https://registry.yarnpkg.com/d3-ease/-/d3-ease-3.0.1.tgz#9658ac38a2140d59d346160f1f6c30fda0bd12f4"
integrity sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==

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

d3-geo@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/d3-geo/-/d3-geo-3.1.1.tgz#6027cf51246f9b2ebd64f99e01dc7c3364033a4d"
integrity sha512-637ln3gXKXOwhalDzinUgY83KzNWZRKbYubaG+fGVuc/dxO64RRljtCTnf5ecMyE1RIdtqpkVcq0IbtU2S8j2Q==
dependencies:
d3-array "2.5.0 - 3"

d3-horizon@1:
version "1.11.2"
resolved "https://registry.yarnpkg.com/d3-horizon/-/d3-horizon-1.11.2.tgz#a783f6fd51db8a9dce33a6ee8f1c5298e2820be6"
Expand All @@ -4097,11 +4111,6 @@ d3-horizon@1:
dependencies:
d3-color "1 - 3"

"d3-path@1 - 2":
version "2.0.0"
resolved "https://registry.yarnpkg.com/d3-path/-/d3-path-2.0.0.tgz#55d86ac131a0548adae241eebfb56b4582dd09d8"
integrity sha512-ZwZQxKhBnv9yHaiWd6ZU4x5BtCQ7pXszEV9CU6kRgwIQVQGLMv1oiL4M+MK/n79sYzsj+gcgpPQSctJUsLN7fA==

d3-path@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/d3-path/-/d3-path-3.1.0.tgz#22df939032fb5a71ae8b1800d61ddb7851c42526"
Expand All @@ -4112,7 +4121,7 @@ d3-queue@1:
resolved "https://registry.yarnpkg.com/d3-queue/-/d3-queue-1.2.3.tgz#143a701cfa65fe021292f321c10d14e98abd491b"
integrity sha512-m6KtxX4V5pmVf1PqhH4SkQVMshSJfyCLM2vf2oFPi9FWFVT3+rtbCGerk766b/JXymHQDU3oqXHaZoiQ/e8yUQ==

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

"d3-shape@1 - 3":
"d3-shape@1 - 3", d3-shape@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/d3-shape/-/d3-shape-3.2.0.tgz#a1a839cbd9ba45f28674c69d7f855bcf91dfc6a5"
integrity sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==
dependencies:
d3-path "^3.1.0"

d3-shape@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/d3-shape/-/d3-shape-2.1.0.tgz#3b6a82ccafbc45de55b57fcf956c584ded3b666f"
integrity sha512-PnjUqfM2PpskbSLTJvAzp2Wv4CZsnAgTfcVRTwW03QR3MkXF8Uo7B1y/lWkAsmbKwuecto++4NlsYcvYpXpTHA==
dependencies:
d3-path "1 - 2"

"d3-time-format@1 - 4", "d3-time-format@2 - 4":
version "4.1.0"
resolved "https://registry.yarnpkg.com/d3-time-format/-/d3-time-format-4.1.0.tgz#7ab5257a5041d11ecb4fe70a5c7d16a195bb408a"
Expand Down

0 comments on commit fee344a

Please sign in to comment.