Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d6056a8
Add chart modeling menu to widget
kuzmadom Jan 29, 2026
8650846
fix
kuzmadom Jan 29, 2026
b022f95
restrict the display of menus for graph types and visualizations
kuzmadom Jan 29, 2026
dd06971
fix
kuzmadom Jan 29, 2026
c1090c1
fix tooltip
kuzmadom Jan 29, 2026
193c2ce
Add ChartModelingSettings drawer
kuzmadom Jan 30, 2026
12f0075
Add chart-modeling store
kuzmadom Jan 30, 2026
a5eaa64
Merge branch 'main' into CHARTS-12431_trends
kuzmadom Jan 30, 2026
c8eb618
Add widget name
kuzmadom Jan 30, 2026
7b39f80
fix trend colorMode
kuzmadom Jan 30, 2026
8664111
Add chart icon
kuzmadom Feb 2, 2026
712350e
close dialog on widget change
kuzmadom Feb 2, 2026
1465b57
fix
kuzmadom Feb 2, 2026
b6b915f
fix Preview
kuzmadom Feb 2, 2026
740bf55
Add chroma-js to devDependencies
kuzmadom Feb 2, 2026
5ad3cf9
Add @types/chroma-js
kuzmadom Feb 2, 2026
2fffa75
Merge branch 'main' of github.com:datalens-tech/datalens-ui into CHAR…
kuzmadom Feb 3, 2026
e8ee6ee
Add warning
kuzmadom Feb 3, 2026
7fc87ac
Merge branch 'main' into CHARTS-12431_trends
kuzmadom Feb 3, 2026
910f922
fix
kuzmadom Feb 3, 2026
8a49307
fix
kuzmadom Feb 4, 2026
9a771e7
Merge branch 'main' of github.com:datalens-tech/datalens-ui into CHAR…
kuzmadom Feb 5, 2026
68ef012
Add preview label
kuzmadom Feb 5, 2026
285a755
Fix tooltip text
kuzmadom Feb 5, 2026
789811a
Merge branch 'main' of github.com:datalens-tech/datalens-ui into CHAR…
kuzmadom Feb 5, 2026
394882e
fix lock file
kuzmadom Feb 5, 2026
18a8321
fix lock file
kuzmadom Feb 5, 2026
10c71e7
Merge branch 'main' into CHARTS-12431
kuzmadom Feb 5, 2026
54332e5
fix
kuzmadom Feb 5, 2026
d484b8d
Merge branch 'main' into CHARTS-12431
kuzmadom Feb 5, 2026
84d377c
fix
kuzmadom Feb 6, 2026
a337e8f
Merge branch 'main' of github.com:datalens-tech/datalens-ui into CHAR…
kuzmadom Feb 6, 2026
e35b498
fix merge
kuzmadom Feb 6, 2026
849ebd9
Merge branch 'main' into CHARTS-12431
kuzmadom Feb 6, 2026
42d3866
Merge branch 'main' of github.com:datalens-tech/datalens-ui into CHAR…
kuzmadom Feb 9, 2026
0fa9349
Remove i18n mocks
kuzmadom Feb 9, 2026
0fe8841
Merge branch 'main' into CHARTS-12431
kuzmadom Feb 9, 2026
e8a9bae
fix
kuzmadom Feb 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/shared/types/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ export enum MenuItemsIds {
SETTINGS = 'settings',
ALERTS = 'alerts',
FULLSCREEEN = 'fullscreen',
CHART_MODELING = 'modeling',
CHART_MODELING_TREND = 'trend',
CHART_MODELING_SMOOTHING = 'smoothing',
CHART_MODELING_SETTINGS = 'modelingSettings',
}
77 changes: 77 additions & 0 deletions src/ui/components/ChartModelingSettings/ChartModelingSettings.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
.chart-modeling-settings {
&__container {
top: var(--dl-chart-modelling-settings-top, 40px);
width: 280px;
z-index: 2;
background: var(--g-color-base-float);
overflow: auto;
}

&__section {
border-bottom: 1px solid var(--g-color-line-generic-solid);
padding: var(--g-spacing-4);
}

&__header {
display: flex;
justify-content: space-between;
align-items: center;
}

&__title {
margin-right: var(--g-spacing-2);
}

&__section-header {
display: flex;
justify-content: space-between;
align-items: center;
}

&__form-row {
padding: var(--g-spacing-5) 0 0;
display: flex;
flex-direction: column;
gap: var(--g-spacing-2);

&_switch {
flex-direction: row;
justify-content: space-between;
align-items: center;
}
}

&__shape-and-width-controls {
display: flex;
gap: var(--g-spacing-2);
}

&__line-width-input {
width: 120px;
}

&__shape-select {
width: 112px;
}

&__shape-select-icon {
display: flex;
overflow: hidden;
}

&__widget-name {
display: flex;
align-items: center;
gap: var(--g-spacing-1);
padding-top: var(--g-spacing-2);
}

&__control-label {
cursor: pointer;
}

&__label-with-hint {
display: flex;
gap: var(--g-spacing-1);
}
}
141 changes: 141 additions & 0 deletions src/ui/components/ChartModelingSettings/ChartModelingSettings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import React from 'react';

import {Xmark} from '@gravity-ui/icons';
import {Drawer, DrawerItem} from '@gravity-ui/navigation';
import {Alert, Button, Icon, Label, Switch, Text} from '@gravity-ui/uikit';
import block from 'bem-cn-lite';
import {useDispatch, useSelector} from 'react-redux';
import {DEFAULT_SMOOTHING, DEFAULT_TREND_SETTINGS} from 'shared/constants/chart-modeling';
import type {DatalensGlobalState} from 'ui/index';
import {chartModelingActions} from 'ui/store/toolkit/chart-modeling/actions';
import {getChartModelingState, getEditingWidgetId} from 'ui/store/toolkit/chart-modeling/selectors';

import {EntityIcon} from '../EntityIcon/EntityIcon';

import {SmothSettings} from './components/SmothSettings';
import {TrendSettings} from './components/TrendSettings';
import {i18n} from './i18n';
import {getChartModelingWarning} from './utils';

import './ChartModelingSettings.scss';

const b = block('chart-modeling-settings');

export const ChartModelingSettings = () => {
const dispatch = useDispatch();
const containerRef = React.useRef<HTMLDivElement | null>(null);
const widgetId = useSelector(getEditingWidgetId);
const isOpen = Boolean(widgetId);
const chartState = useSelector((state: DatalensGlobalState) =>
getChartModelingState(state, widgetId),
);
const widgetName = chartState?.widgetName;
const warning = React.useMemo(
() => getChartModelingWarning(chartState?.warnings)?.description,
[chartState?.warnings],
);

const handleClose = React.useCallback(() => {
dispatch(chartModelingActions.closeChartModelingDialog());
}, [dispatch]);

const shouldLinkSeries = Boolean(
(chartState?.smoothing?.settings?.linked ?? DEFAULT_SMOOTHING.linked) ||
(chartState?.trends?.settings?.linked ?? DEFAULT_TREND_SETTINGS.linked),
);
const handleLinkSeries = React.useCallback(() => {
if (!widgetId) {
return;
}

dispatch(
chartModelingActions.updateChartSettings({
id: widgetId,
settings: {
smoothing: {
...chartState.smoothing,
settings: {
...chartState.smoothing?.settings,
linked: !shouldLinkSeries,
},
},
trends: {
...chartState.trends,
settings: {
...chartState.trends?.settings,
linked: !shouldLinkSeries,
},
},
},
}),
);
}, [chartState, dispatch, shouldLinkSeries, widgetId]);

React.useEffect(() => {
return () => {
dispatch(chartModelingActions.closeChartModelingDialog());
};
}, [dispatch]);

return (
<Drawer className={b()} hideVeil={true} keepMounted={true}>
<DrawerItem
id="item"
visible={isOpen}
direction="right"
className={b('container')}
ref={containerRef}
>
<div className={b('section')}>
<div className={b('header')}>
<div>
<Text className={b('title')} variant="subheader-2">
{i18n('title_modeling')}
</Text>
<Label theme="info" size="xs">
Preview
</Label>
</div>
<Button view="flat" size="m" onClick={handleClose}>
<Icon data={Xmark} />
</Button>
</div>
{widgetName && (
<div className={b('widget-name')}>
<EntityIcon size="m" type={'chart-wizard'} iconSize={12} />
<Text>{widgetName}</Text>
</div>
)}
</div>
{Boolean(widgetId) && (
<React.Fragment>
{warning && <Alert theme="warning" message={warning} corners="square" />}
<div className={b('section')}>
<SmothSettings chartState={chartState} widgetId={String(widgetId)} />
</div>
<div className={b('section')}>
<TrendSettings chartState={chartState} widgetId={String(widgetId)} />
</div>
<div className={b('section')}>
<div className={b('section-header')}>
<Text variant="subheader-1">
{i18n('label_additional-settings')}
</Text>
</div>
<div className={b('form-row', {switch: true})}>
<Text className={b('control-label')} onClick={handleLinkSeries}>
{i18n('label_link-series')}
</Text>
<Switch
onChange={handleLinkSeries}
size="l"
checked={shouldLinkSeries}
></Switch>
</div>
</div>
</React.Fragment>
)}
</DrawerItem>
</Drawer>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from 'react';

import {Select, type SelectOption} from '@gravity-ui/uikit';
import block from 'bem-cn-lite';
import type {LineShapeType} from 'shared';
import {SHAPES_PALETTE_ORDER} from 'shared';
import {selectClientAvailableLineShapes} from 'ui/constants/common';

import {i18n} from '../../i18n';

import {getShapedLineIcon} from './utils';

const b = block('chart-modeling-settings');

function getShapeSelectOptions() {
const availableLineShapes = selectClientAvailableLineShapes();
const values = availableLineShapes.sort(
(shape1, shape2) => SHAPES_PALETTE_ORDER[shape1] - SHAPES_PALETTE_ORDER[shape2],
);

const items: SelectOption[] = values.map((v) => ({value: v}));
return items;
}

function renderShapeSelectOption({value, width}: {value: string; width: number}) {
if (value === 'auto') {
return <React.Fragment>{i18n('label_auto')}</React.Fragment>;
}

return (
<div className={b('shape-select-icon')}>
{getShapedLineIcon({shape: value as LineShapeType, width, height: 2})}
</div>
);
}

export const ShapeSelect = ({
value,
onChange,
}: {
value: string;
onChange: (values: string[]) => void;
}) => {
return (
<Select
value={[value]}
onUpdate={onChange}
options={getShapeSelectOptions()}
renderOption={({value: item}) => renderShapeSelectOption({value: item, width: 112})}
renderSelectedOption={({value: item}) =>
renderShapeSelectOption({value: item, width: 80})
}
className={b('shape-select')}
/>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';

import {line as lineGenerator} from 'd3';
import type {LineShapeType} from 'shared';

function getLineDashArray(dashStyle: LineShapeType, strokeWidth = 2) {
const arrayValue = dashStyle
.toLowerCase()
.replace('shortdashdotdot', '3,1,1,1,1,1,')
.replace('shortdashdot', '3,1,1,1')
.replace('shortdot', '1,1,')
.replace('shortdash', '3,1,')
.replace('longdash', '8,3,')
.replace(/dot/g, '1,3,')
.replace('dash', '4,3,')
.replace(/,$/, '')
.split(',')
.map((part) => {
return `${parseInt(part, 10) * strokeWidth}`;
});

return arrayValue.join(',').replace(/NaN/g, 'none');
}

const line = lineGenerator();
export function getShapedLineIcon({
shape,
width,
height = 2,
}: {
width: number;
height: number;
shape: LineShapeType;
}) {
const path = line([
[0, height / 2],
[width, height / 2],
]);

return (
<svg width={width} height={height}>
<g>
<path
fill="none"
d={path ?? ''}
stroke="currentColor"
strokeWidth={height}
strokeDasharray={getLineDashArray(shape)}
></path>
</g>
</svg>
);
}
Loading
Loading