Skip to content

Commit e78901c

Browse files
committed
v6.6.10
1 parent 72e7b1f commit e78901c

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netdata/charts",
3-
"version": "6.6.9",
3+
"version": "6.6.10",
44
"description": "Netdata frontend SDK and chart utilities",
55
"main": "dist/index.js",
66
"module": "dist/es6/index.js",

src/components/toolbox/settings/pointsToFetch.js

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import React, { useState, useEffect, useMemo } from "react"
22
import { Flex, TextSmall, TextMicro, TextInput } from "@netdata/netdata-ui"
3+
import information from "@netdata/netdata-ui/dist/components/icon/assets/information.svg"
34
import { useAttributeValue } from "@/components/provider"
5+
import { pointMultiplierByChartType } from "@/sdk/makeChart/api/helpers"
6+
import Tooltip from "@/components/tooltip"
7+
import Icon from "@/components/icon"
48

59
export const useMaxPoints = () => {
610
const after = useAttributeValue("after")
@@ -24,9 +28,33 @@ export const usePointsExceedsMax = () => {
2428
return maxPoints !== null && points !== null && points > maxPoints
2529
}
2630

31+
const useAutoPoints = () => {
32+
const containerWidth = useAttributeValue("containerWidth")
33+
const pixelsPerPoint = useAttributeValue("pixelsPerPoint") || 3
34+
const chartType = useAttributeValue("chartType")
35+
const chartLibrary = useAttributeValue("chartLibrary")
36+
37+
return useMemo(() => {
38+
if (!containerWidth) return null
39+
40+
const multiplier =
41+
pointMultiplierByChartType[chartType] ||
42+
pointMultiplierByChartType[chartLibrary] ||
43+
pointMultiplierByChartType.default
44+
45+
const points = Math.round((containerWidth / pixelsPerPoint) * multiplier)
46+
47+
if (isNaN(points)) return null
48+
49+
return points
50+
}, [containerWidth, pixelsPerPoint, chartType, chartLibrary])
51+
}
52+
2753
const PointsToFetch = ({ formState, onChange }) => {
2854
const [pointsValue, setPointsValue] = useState(formState.points ?? "")
2955

56+
const autoPoints = useAutoPoints()
57+
3058
const updateEvery = useAttributeValue("updateEvery")
3159
const maxPoints = useMaxPoints()
3260
const exceedsMax = maxPoints !== null && pointsValue !== "" && Number(pointsValue) > maxPoints
@@ -42,18 +70,22 @@ const PointsToFetch = ({ formState, onChange }) => {
4270
onChange({ points })
4371
}
4472

73+
const placeholder = autoPoints ? `Auto (${autoPoints} data points)` : "Auto"
74+
4575
return (
4676
<Flex column gap={2}>
47-
<TextSmall color="textNoFocus" strong>
48-
Data resolution
49-
</TextSmall>
77+
<Flex alignItems="center" gap={1}>
78+
<TextSmall strong>Data resolution</TextSmall>
79+
<Tooltip content="Number of data points to fetch from the server. Higher values provide more detail but may impact performance. Auto calculates optimal points based on chart width.">
80+
<Icon svg={information} size="12px" color="textLite" />
81+
</Tooltip>
82+
</Flex>
5083
<Flex column gap={1}>
5184
<TextInput
52-
label="Points to fetch"
5385
type="number"
5486
value={pointsValue}
5587
onChange={handleChange}
56-
placeholder="Auto"
88+
placeholder={placeholder}
5789
min="1"
5890
/>
5991
{exceedsMax && (

0 commit comments

Comments
 (0)