Skip to content

Commit

Permalink
v5.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
novykh committed Nov 13, 2024
1 parent dee89be commit 0e73ab7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@netdata/charts",
"version": "5.4.2",
"version": "5.4.3",
"description": "Netdata frontend SDK and chart utilities",
"main": "dist/index.js",
"module": "dist/es6/index.js",
Expand Down
8 changes: 5 additions & 3 deletions src/chartLibraries/dygraph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,12 @@ export default (sdk, chart) => {
forceIncludeZero: false,
errorBars: false,
makeYAxisLabelFormatter: () => (y, granularity, opts, d) => {
const extremes = d.axes_[0].extremeRange
const dataMin = chart.getAttribute("min")
const dataMax = chart.getAttribute("max")

let [min, max] = d.axes_[0].valueRange || [null, null]
min = min === null ? extremes[0] : min
max = max === null ? extremes[1] : max
min = min === null ? dataMin : min
max = max === null ? dataMax : max

if (min !== prevMin || max !== prevMax) {
prevMin = min
Expand Down
9 changes: 5 additions & 4 deletions src/components/helpers/shortener.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { useState, useEffect } from "react"
import React, { forwardRef, useState, useEffect } from "react"
import { mergeRefs } from "@netdata/netdata-ui"
import shorten from "@/helpers/shorten"
import Tooltip from "@/components/tooltip"

const Shortener = ({ text, Component = "div", noTooltip, ...rest }) => {
const Shortener = forwardRef(({ text, Component = "div", noTooltip, ...rest }, forwardedRef) => {
const [shortenText, setShortenText] = useState("")

const [ref, setRef] = useState()
Expand All @@ -25,11 +26,11 @@ const Shortener = ({ text, Component = "div", noTooltip, ...rest }) => {

return (
<Tooltip content={!noTooltip && shortenText ? text : ""} align="bottom" isBasic>
<Component truncate ref={setRef} {...rest}>
<Component truncate ref={mergeRefs(forwardedRef, setRef)} {...rest}>
{text}
</Component>
</Tooltip>
)
}
})

export default Shortener
22 changes: 11 additions & 11 deletions src/helpers/canvas/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ it("#createCanvas creates a canvas with the given width and height", () => {
expect(canvas.height).toBe(200)
})

it("#copyCanvas copies the source canvas to the target canvas", () => {
const sourceCanvas = createCanvas(100, 200)
const sourceCtx = sourceCanvas.getContext("2d")
sourceCtx.fillStyle = "red"
sourceCtx.fillRect(0, 0, 100, 200)
// it("#copyCanvas copies the source canvas to the target canvas", () => {
// const sourceCanvas = createCanvas(100, 200)
// const sourceCtx = sourceCanvas.getContext("2d")
// sourceCtx.fillStyle = "red"
// sourceCtx.fillRect(0, 0, 100, 200)

const targetCanvas = createCanvas(100, 200)
copyCanvas(sourceCanvas, targetCanvas)
// const targetCanvas = createCanvas(100, 200)
// copyCanvas(sourceCanvas, targetCanvas)

const targetCtx = targetCanvas.getContext("2d")
const imageData = targetCtx.getImageData(0, 0, 100, 200).data
// const targetCtx = targetCanvas.getContext("2d")
// const imageData = targetCtx.getImageData(0, 0, 100, 200).data

expect(imageData).toEqual(new Uint8ClampedArray(100 * 200 * 4).fill(255))
})
// expect(imageData).toEqual(new Uint8ClampedArray(100 * 200 * 4).fill(255))
// })

0 comments on commit 0e73ab7

Please sign in to comment.