@pie-lib/charting 7.0.3-next.3 → 7.0.4-next.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [7.0.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/charting@7.0.2...@pie-lib/charting@7.0.3) (2026-05-15)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **charting:** avoid floating-point precision errors in the % operator PIE-434 ([d325882](https://github.com/pie-framework/pie-lib/commit/d325882408975633c872d5fca70a8117fec30e51))
11
+
6
12
  ## [7.0.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/charting@7.0.2-next.3...@pie-lib/charting@7.0.2) (2026-05-07)
7
13
 
8
14
  **Note:** Version bump only for package @pie-lib/charting
package/lib/grid.js CHANGED
@@ -50,9 +50,20 @@ var Grid = exports.Grid = /*#__PURE__*/function (_React$Component) {
50
50
  _range$labelStep = range.labelStep,
51
51
  labelStep = _range$labelStep === void 0 ? 0 : _range$labelStep;
52
52
  var highlightNonLabel = step && labelStep && step < labelStep;
53
- // if highlightNonLabel is true, we need to separate the unlabled lines in order to render them in a different color
53
+
54
+ // Avoid floating-point precision errors in the % operator.
55
+ // e.g. 0.6 % 0.2 = 0.19999999999999996, but safeModulo(0.6, 0.2) = 0
56
+ var safeModulo = function safeModulo(value, step) {
57
+ var valueDecimals = (value.toString().split('.')[1] || '').length;
58
+ var stepDecimals = (step.toString().split('.')[1] || '').length;
59
+ var decimals = Math.max(valueDecimals, stepDecimals);
60
+ var factor = Math.pow(10, decimals);
61
+ return value * factor % (step * factor) / factor;
62
+ };
63
+
64
+ // if highlightNonLabel is true, we need to separate the unlabeled lines in order to render them in a different color
54
65
  var _reduce = (rowTickValues || []).reduce(function (acc, value) {
55
- if (highlightNonLabel && value % labelStep !== 0) {
66
+ if (highlightNonLabel && safeModulo(value, labelStep) !== 0) {
56
67
  acc.unlabeledLines.push(value);
57
68
  } else {
58
69
  acc.labeledLines.push(value);
@@ -77,7 +88,7 @@ var Grid = exports.Grid = /*#__PURE__*/function (_React$Component) {
77
88
  width: size.width,
78
89
  tickValues: labeledLines,
79
90
  lineStyle: {
80
- stroke: _renderUi.color.visualElementsColors.GRIDLINES_COLOR,
91
+ stroke: unlabeledLines.length ? _renderUi.color.visualElementsColors.GRIDLINES_COLOR : _renderUi.color.fadedPrimary(),
81
92
  strokeWidth: 1
82
93
  }
83
94
  }), /*#__PURE__*/_react["default"].createElement(_grid.GridColumns, {
package/lib/grid.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"grid.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_grid","_plot","_renderUi","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","StyledGridGroup","styled","stroke","color","primaryLight","Grid","exports","_React$Component","_classCallCheck2","arguments","_inherits2","_createClass2","key","value","render","_this$props","props","graphProps","xBand","rowTickValues","columnTickValues","_ref","_ref$scale","scale","_ref$size","size","_ref$range","range","_range$step","step","_range$labelStep","labelStep","highlightNonLabel","_reduce","reduce","acc","unlabeledLines","push","labeledLines","createElement","GridRows","y","width","tickValues","lineStyle","fadedPrimary","strokeWidth","visualElementsColors","GRIDLINES_COLOR","GridColumns","height","offset","bandwidth","React","Component","_defineProperty2","className","PropTypes","string","types","GraphPropsType","isRequired","func","array","_default"],"sources":["../src/grid.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport { GridColumns, GridRows } from '@visx/grid';\n\nimport { types } from '@pie-lib/plot';\nimport { color } from '@pie-lib/render-ui';\n\nconst StyledGridGroup = styled('g')(() => ({\n stroke: color.primaryLight(),\n}));\n\nexport class Grid extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n graphProps: types.GraphPropsType.isRequired,\n xBand: PropTypes.func,\n columnTickValues: PropTypes.array,\n rowTickValues: PropTypes.array,\n };\n\n static defaultProps = {};\n\n render() {\n const { graphProps, xBand, rowTickValues, columnTickValues } = this.props;\n const { scale = {}, size = {}, range = {} } = graphProps || {};\n const { step = 0, labelStep = 0 } = range;\n const highlightNonLabel = step && labelStep && step < labelStep;\n // if highlightNonLabel is true, we need to separate the unlabled lines in order to render them in a different color\n const { unlabeledLines, labeledLines } = (rowTickValues || []).reduce(\n (acc, value) => {\n if (highlightNonLabel && value % labelStep !== 0) {\n acc.unlabeledLines.push(value);\n } else {\n acc.labeledLines.push(value);\n }\n return acc;\n },\n { unlabeledLines: [], labeledLines: [] },\n );\n\n return (\n <StyledGridGroup>\n <GridRows\n scale={scale.y}\n width={size.width}\n tickValues={unlabeledLines}\n lineStyle={{\n stroke: color.fadedPrimary(),\n strokeWidth: 1,\n }}\n />\n <GridRows\n scale={scale.y}\n width={size.width}\n tickValues={labeledLines}\n lineStyle={{\n stroke: color.visualElementsColors.GRIDLINES_COLOR,\n strokeWidth: 1,\n }}\n />\n <GridColumns scale={xBand} height={size.height} offset={xBand.bandwidth() / 2} tickValues={columnTickValues} />\n </StyledGridGroup>\n );\n }\n}\n\nexport default Grid;\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAA2C,SAAAM,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,aAAAF,CAAA,OAAAG,2BAAA,aAAAJ,CAAA,EAAAK,yBAAA,KAAAC,OAAA,CAAAC,SAAA,CAAAN,CAA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AK,EAAEA,KAAK,CAACkB,CAAE;QACfC,KAAK,EAAEjB,IAAI,CAACiB,KAAM;QAClBC,UAAU,EAAEL,YAAa;QACzBM,SAAS,EAAE;UACT1C,MAAM,EAAEC,eAAK,CAAC4C,oBAAoB,CAACC,eAAe;UAClDF,WAAW,EAAE;QACf;MAAE,CACH,CAAC,eACFrE,MAAA,YAAA8D,aAAA,CAACzD,KAAA,CAAAmE,WAAW;QAAC1B,KAAK,EAAEL,KAAM;QAACgC,MAAM,EAAEzB,IAAI,CAACyB,MAAO;QAACC,MAAM,EAAEjC,KAAK,CAACkC,SAAS,CAAC,CAAC,GAAG,CAAE;QAACT,UAAU,EAAEvB;MAAiB,CAAE,CAC/F,CAAC;IAEtB;EAAC;AAAA,EApDuBiC,iBAAK,CAACC,SAAS;AAAA,IAAAC,gBAAA,aAA5BlD,IAAI,eACI;EACjBmD,SAAS,EAAEC,qBAAS,CAACC,MAAM;EAC3BzC,UAAU,EAAE0C,WAAK,CAACC,cAAc,CAACC,UAAU;EAC3C3C,KAAK,EAAEuC,qBAAS,CAACK,IAAI;EACrB1C,gBAAgB,EAAEqC,qBAAS,CAACM,KAAK;EACjC5C,aAAa,EAAEsC,qBAAS,CAACM;AAC3B,CAAC;AAAA,IAAAR,gBAAA,aAPUlD,IAAI,kBASO,CAAC,CAAC;AAAA,IAAA2D,QAAA,GAAA1D,OAAA,cA8CXD,IAAI","ignoreList":[]}
1
+ {"version":3,"file":"grid.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_grid","_plot","_renderUi","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","StyledGridGroup","styled","stroke","color","primaryLight","Grid","exports","_React$Component","_classCallCheck2","arguments","_inherits2","_createClass2","key","value","render","_this$props","props","graphProps","xBand","rowTickValues","columnTickValues","_ref","_ref$scale","scale","_ref$size","size","_ref$range","range","_range$step","step","_range$labelStep","labelStep","highlightNonLabel","safeModulo","valueDecimals","toString","split","length","stepDecimals","decimals","Math","max","factor","pow","_reduce","reduce","acc","unlabeledLines","push","labeledLines","createElement","GridRows","y","width","tickValues","lineStyle","fadedPrimary","strokeWidth","visualElementsColors","GRIDLINES_COLOR","GridColumns","height","offset","bandwidth","React","Component","_defineProperty2","className","PropTypes","string","types","GraphPropsType","isRequired","func","array","_default"],"sources":["../src/grid.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport { GridColumns, GridRows } from '@visx/grid';\n\nimport { types } from '@pie-lib/plot';\nimport { color } from '@pie-lib/render-ui';\n\nconst StyledGridGroup = styled('g')(() => ({\n stroke: color.primaryLight(),\n}));\n\nexport class Grid extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n graphProps: types.GraphPropsType.isRequired,\n xBand: PropTypes.func,\n columnTickValues: PropTypes.array,\n rowTickValues: PropTypes.array,\n };\n\n static defaultProps = {};\n\n render() {\n const { graphProps, xBand, rowTickValues, columnTickValues } = this.props;\n const { scale = {}, size = {}, range = {} } = graphProps || {};\n const { step = 0, labelStep = 0 } = range;\n const highlightNonLabel = step && labelStep && step < labelStep;\n\n // Avoid floating-point precision errors in the % operator.\n // e.g. 0.6 % 0.2 = 0.19999999999999996, but safeModulo(0.6, 0.2) = 0\n const safeModulo = (value, step) => {\n const valueDecimals = (value.toString().split('.')[1] || '').length;\n const stepDecimals =(step.toString().split('.')[1] || '').length\n const decimals = Math.max(valueDecimals, stepDecimals);\n const factor = Math.pow(10, decimals);\n\n return ((value * factor) % (step * factor)) / factor;\n };\n\n // if highlightNonLabel is true, we need to separate the unlabeled lines in order to render them in a different color\n const { unlabeledLines, labeledLines } = (rowTickValues || []).reduce(\n (acc, value) => {\n if (highlightNonLabel && safeModulo(value, labelStep) !== 0) {\n acc.unlabeledLines.push(value);\n } else {\n acc.labeledLines.push(value);\n }\n return acc;\n },\n { unlabeledLines: [], labeledLines: [] },\n );\n\n return (\n <StyledGridGroup>\n <GridRows\n scale={scale.y}\n width={size.width}\n tickValues={unlabeledLines}\n lineStyle={{\n stroke: color.fadedPrimary(),\n strokeWidth: 1,\n }}\n />\n <GridRows\n scale={scale.y}\n width={size.width}\n tickValues={labeledLines}\n lineStyle={{\n stroke: unlabeledLines.length ? color.visualElementsColors.GRIDLINES_COLOR : color.fadedPrimary(),\n strokeWidth: 1,\n }}\n />\n <GridColumns scale={xBand} height={size.height} offset={xBand.bandwidth() / 2} tickValues={columnTickValues} />\n </StyledGridGroup>\n );\n }\n}\n\nexport default Grid;\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAA2C,SAAAM,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,aAAAF,CAAA,OAAAG,2BAAA,aAAAJ,CAAA,EAAAK,yBAAA,KAAAC,OAAA,CAAAC,SAAA,CAAAN,CAAA,EAAAC,CAAA,YAAAC,gBAAA,aAAAH,CAAA,EAAAQ,WAAA,IAAAP,CAAA,CAAAQ,KAAA,CAAAT,CAAA,EAAAE,CAAA;AAAA,SAAAG,0BAAA,cAAAL,CAAA,IAAAU,OAAA,CAAAC,SAAA,CAAAC,OAAA,CAAAC,IAAA,CAAAP,OAAA,CAAAC,SAAA,CAAAG,OAAA,iCAAAV,CAAA,aAAAK,yBAAA,YAAAA,0BAAA,aAAAL,CAAA;AAE3C,IAAMc,eAAe,GAAG,IAAAC,cAAM,EAAC,GAAG,CAAC,CAAC;EAAA,OAAO;IACzCC,MAAM,EAAEC,eAAK,CAACC,YAAY,CAAC;EAC7B,CAAC;AAAA,CAAC,CAAC;AAAC,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
+ "version": "7.0.4-next.12+b4f875b88",
7
7
  "description": "charting",
8
8
  "keywords": [
9
9
  "react",
@@ -23,7 +23,7 @@
23
23
  "@mui/icons-material": "^7.3.4",
24
24
  "@mui/material": "^7.3.4",
25
25
  "@pie-lib/math-rendering": "^5.0.2",
26
- "@pie-lib/plot": "^4.0.3-next.3+9ed0f0b3d",
26
+ "@pie-lib/plot": "^4.0.4-next.12+b4f875b88",
27
27
  "@pie-lib/render-ui": "^6.1.0",
28
28
  "@pie-lib/translator": "^4.0.2",
29
29
  "@visx/axis": "^3.0.0",
@@ -49,5 +49,5 @@
49
49
  "devDependencies": {
50
50
  "@pie-lib/test-utils": "^2.0.2"
51
51
  },
52
- "gitHead": "9ed0f0b3d5fa8b6ee6a161ec237e2aa1fe11d9f6"
52
+ "gitHead": "b4f875b8831ed211d0665026040a89091438bb82"
53
53
  }
package/src/grid.jsx CHANGED
@@ -26,10 +26,22 @@ export class Grid extends React.Component {
26
26
  const { scale = {}, size = {}, range = {} } = graphProps || {};
27
27
  const { step = 0, labelStep = 0 } = range;
28
28
  const highlightNonLabel = step && labelStep && step < labelStep;
29
- // if highlightNonLabel is true, we need to separate the unlabled lines in order to render them in a different color
29
+
30
+ // Avoid floating-point precision errors in the % operator.
31
+ // e.g. 0.6 % 0.2 = 0.19999999999999996, but safeModulo(0.6, 0.2) = 0
32
+ const safeModulo = (value, step) => {
33
+ const valueDecimals = (value.toString().split('.')[1] || '').length;
34
+ const stepDecimals =(step.toString().split('.')[1] || '').length
35
+ const decimals = Math.max(valueDecimals, stepDecimals);
36
+ const factor = Math.pow(10, decimals);
37
+
38
+ return ((value * factor) % (step * factor)) / factor;
39
+ };
40
+
41
+ // if highlightNonLabel is true, we need to separate the unlabeled lines in order to render them in a different color
30
42
  const { unlabeledLines, labeledLines } = (rowTickValues || []).reduce(
31
43
  (acc, value) => {
32
- if (highlightNonLabel && value % labelStep !== 0) {
44
+ if (highlightNonLabel && safeModulo(value, labelStep) !== 0) {
33
45
  acc.unlabeledLines.push(value);
34
46
  } else {
35
47
  acc.labeledLines.push(value);
@@ -55,7 +67,7 @@ export class Grid extends React.Component {
55
67
  width={size.width}
56
68
  tickValues={labeledLines}
57
69
  lineStyle={{
58
- stroke: color.visualElementsColors.GRIDLINES_COLOR,
70
+ stroke: unlabeledLines.length ? color.visualElementsColors.GRIDLINES_COLOR : color.fadedPrimary(),
59
71
  strokeWidth: 1,
60
72
  }}
61
73
  />