Skip to content

Commit

Permalink
fix: add signigicant digits to xy plot
Browse files Browse the repository at this point in the history
  • Loading branch information
corteggiano committed Jan 31, 2024
1 parent f5eed70 commit 70a109e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { PropertyLens } from '~/customization/propertiesSection';

const isSettingsWidget = (
w: DashboardWidget
): w is DashboardWidget<CommonChartProperties> =>
'queryConfig' in w.properties && w.type !== 'xy-plot';
): w is DashboardWidget<CommonChartProperties> => 'queryConfig' in w.properties;

const RenderSettingsConfiguration = ({
useProperty,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { YAXisComponentOption } from 'echarts';
import { ChartAxisOptions } from '../../types';
import { DEFAULT_Y_AXIS } from '../../eChartsConstants';
import { round } from '@iot-app-kit/core-util';

export const convertYAxis = (
axis: ChartAxisOptions | undefined
axis?: ChartAxisOptions,
significantDigits?: number
): YAXisComponentOption => ({
...DEFAULT_Y_AXIS,
name: axis?.yLabel,
Expand All @@ -15,6 +17,7 @@ export const convertYAxis = (
axisLabel: {
hideOverlap: true,
color: '#5f6b7a',
formatter: (value: number) => `${round(value, significantDigits)}`,
},
nameLocation: 'middle',
nameGap: 30,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ export const useSeriesAndYAxis = (
useHighlightedDataStreams();

return useMemo(() => {
const defaultYAxis: YAXisComponentOption[] = [convertChartYAxis(axis)];
const defaultYAxis: YAXisComponentOption[] = [
convertChartYAxis(axis, significantDigits),
];
const convertedThresholds = convertThresholds(thresholds);

const shouldUseEmphasis = highlightedDataStreams.length > 0;
Expand Down

0 comments on commit 70a109e

Please sign in to comment.