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
2 changes: 2 additions & 0 deletions src/lib/ctx/metrics-registry/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export type TChartMetricBase<GMetricType extends TMetricTypes, GData extends obj
lineStyle?: LineStyle
color?: string
visible?: boolean
lastValueVisible?: boolean
priceLineVisible?: boolean
pane?: number
unit?: TMetricUnit

Expand Down
12 changes: 12 additions & 0 deletions src/lib/ui/app/Chart/ctx/series.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ type TBaseSeries<GType extends TMetricTypes> = {
color: string
style: NonNullable<TChartMetric['style']>
lineStyle: LineStyle
lastValueVisible: boolean
priceLineVisible: boolean
unit: TChartMetric['unit']

isSelectorLocked: boolean
Expand Down Expand Up @@ -116,6 +118,8 @@ type TBaseSeries<GType extends TMetricTypes> = {
color: string
style: TMetricStyles
lineStyle: LineStyle
lastValueVisible?: boolean
priceLineVisible?: boolean
unit?: TMetricUnit

scaleId?: string
Expand Down Expand Up @@ -191,6 +195,8 @@ export function createSeries(
lineStyle = LineStyle.Solid,
color = '#00ff00',
visible = true,
lastValueVisible = true,
priceLineVisible = true,

scaleId,
scaleMargins,
Expand Down Expand Up @@ -230,6 +236,8 @@ export function createSeries(
color,
style,
lineStyle,
lastValueVisible,
priceLineVisible,
unit,

isSelectorLocked,
Expand Down Expand Up @@ -359,6 +367,10 @@ export function createSeries(

// default true -> undefined (omit from API)
visible: metric.visible.$ && undefined,
// default true -> undefined (omit from API)
lastValueVisible: metric.ui.$$.lastValueVisible && undefined,
// default true -> undefined (omit from API)
priceLineVisible: metric.ui.$$.priceLineVisible && undefined,
color: metric.ui.$$.color,
style: metric.ui.$$.style,
lineStyle: metric.ui.$$.lineStyle,
Expand Down
11 changes: 8 additions & 3 deletions src/lib/ui/app/Chart/series/RawSeries.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
})

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

if (style === MetricStyle.AREA) {
Object.assign(options, getAreaSeriesColors(series), { lineStyle })
Expand Down Expand Up @@ -139,7 +139,12 @@
}

function getSeriesTypeOptions() {
const base = { zOrder: 10, priceFormat: untrack(() => priceFormat) }
const base = {
zOrder: 10,
priceFormat: untrack(() => priceFormat),
lastValueVisible: ui.$$.lastValueVisible,
priceLineVisible: ui.$$.priceLineVisible,
}

switch (ui.$$.style) {
case MetricStyle.HISTOGRAM:
Expand Down
28 changes: 28 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 @@ -527,6 +527,34 @@ export const MetricsRegistryCustomGranularityRules: Story = {
},
}

export const LineValueIndicators: Story = {
args: {
defaultMetrics: [
{
apiMetricName: 'price_usd',
label: 'Default Line (btc)',
scaleId: 'right-price_usd',
lastValueVisible: false,
priceLineVisible: false,
},
{
apiMetricName: 'sentiment_volume_consumed_total',
label: 'Dotted Line (volume consumed)',
scaleId: 'right-sentiment_volume_consumed_total',
lastValueVisible: false,
priceLineVisible: false,
},
{
apiMetricName: 'price_eth',
label: 'Dashed Area (eth)',
scaleId: 'right-price_eth',
lastValueVisible: true,
priceLineVisible: false,
},
],
},
}

export const UnderMaintenanceMetric: Story = {
args: {
defaultMetrics: [
Expand Down