Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/lib/ctx/metrics-registry/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export type TChartMetricBase<GMetricType extends TMetricTypes, GData extends obj

data?: TMetricData
label?: string
title?: string
style?: TMetricStyles
lineStyle?: LineStyle
color?: string
Expand Down
5 changes: 5 additions & 0 deletions src/lib/ui/app/Chart/ctx/series.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type TBaseSeries<GType extends TMetricTypes> = {
ui: {
get $$(): {
color: string
title: string
style: NonNullable<TChartMetric['style']>
lineStyle: LineStyle
lastValueVisible: boolean
Expand Down Expand Up @@ -116,6 +117,7 @@ type TBaseSeries<GType extends TMetricTypes> = {

visible?: boolean
color: string
title?: string
style: TMetricStyles
lineStyle: LineStyle
lastValueVisible?: boolean
Expand Down Expand Up @@ -181,6 +183,7 @@ export function createSeries(
apiMetricName = '',

label = apiMetricName,
title = '',
data = [],

// getLabels$ = DEFAULT_LABELS_GETTER,
Expand Down Expand Up @@ -234,6 +237,7 @@ export function createSeries(

const ui = $state({
color,
title,
style,
lineStyle,
lastValueVisible,
Expand Down Expand Up @@ -372,6 +376,7 @@ export function createSeries(
// default true -> undefined (omit from API)
priceLineVisible: metric.ui.$$.priceLineVisible && undefined,
color: metric.ui.$$.color,
title: metric.ui.$$.title || undefined,
style: metric.ui.$$.style,
lineStyle: metric.ui.$$.lineStyle,
unit: metric.ui.$$.unit,
Expand Down
10 changes: 8 additions & 2 deletions src/lib/ui/app/Chart/series/RawSeries.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,13 @@
})

$effect.pre(() => {
const { color, style, lineStyle, lastValueVisible, priceLineVisible } = ui.$$
const options = { color, lastValueVisible, priceLineVisible }
const { color, title, style, lineStyle, lastValueVisible, priceLineVisible } = ui.$$
const options = {
color,
title,
lastValueVisible,
priceLineVisible,
}

if (style === MetricStyle.AREA) {
Object.assign(options, getAreaSeriesColors(series), { lineStyle })
Expand Down Expand Up @@ -142,6 +147,7 @@
const base = {
zOrder: 10,
priceFormat: untrack(() => priceFormat),
title: ui.$$.title,
lastValueVisible: ui.$$.lastValueVisible,
priceLineVisible: ui.$$.priceLineVisible,
}
Expand Down
27 changes: 27 additions & 0 deletions src/stories/Design System - App UI/Chart/index.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,3 +593,30 @@ export const LineStyleMetrics: Story = {
],
},
}

export const FixedLineWithText: Story = {
args: {
defaultMetrics: [
{
apiMetricName: 'price_usd',
label: 'Default Line (btc)',
style: 'line',
},
{
type: MetricType.DATA_STORE,
title: 'Label text',
color: '#5275FF',
style: 'line',
lineStyle: LineStyle.Dashed,
lastValueVisible: false,
priceLineVisible: false,
scaleId: 'right',
scaleMargins: { top: 0.1, bottom: 0 },
data: [
{ time: 0, value: 20_000 },
{ time: Date.now() / 1000, value: 20_000 },
],
},
],
},
}