mirror of https://github.com/ghostfolio/ghostfolio
committed by
GitHub
10 changed files with 221 additions and 131 deletions
@ -0,0 +1,29 @@ |
|||
import { getTooltipPositionerMapTop } from '@ghostfolio/common/chart-helper'; |
|||
|
|||
import { Tooltip, TooltipPositionerFunction, ChartType } from 'chart.js'; |
|||
|
|||
interface VerticalHoverLinePluginOptions { |
|||
color?: string; |
|||
width?: number; |
|||
} |
|||
|
|||
declare module 'chart.js' { |
|||
interface PluginOptionsByType<TType extends ChartType> { |
|||
verticalHoverLine: TType extends 'line' | 'bar' |
|||
? VerticalHoverLinePluginOptions |
|||
: never; |
|||
} |
|||
interface TooltipPositionerMap { |
|||
top: TooltipPositionerFunction<ChartType>; |
|||
} |
|||
} |
|||
|
|||
export function registerChartConfiguration() { |
|||
if (Tooltip.positioners['top']) { |
|||
return; |
|||
} |
|||
|
|||
Tooltip.positioners.top = function (_elements, eventPosition) { |
|||
return getTooltipPositionerMapTop(this.chart, eventPosition); |
|||
}; |
|||
} |
|||
@ -0,0 +1 @@ |
|||
export * from './chart.registry'; |
|||
@ -1,5 +1,21 @@ |
|||
import { PortfolioPosition } from '@ghostfolio/common/interfaces'; |
|||
|
|||
import { ScriptableContext, TooltipItem } from 'chart.js'; |
|||
import { TreemapDataPoint } from 'chartjs-chart-treemap'; |
|||
|
|||
export interface GetColorParams { |
|||
annualizedNetPerformancePercent: number; |
|||
negativeNetPerformancePercentsRange: { max: number; min: number }; |
|||
positiveNetPerformancePercentsRange: { max: number; min: number }; |
|||
} |
|||
|
|||
interface GfTreemapDataPoint extends TreemapDataPoint { |
|||
_data: PortfolioPosition; |
|||
} |
|||
|
|||
export interface GfTreemapScriptableContext extends ScriptableContext<'treemap'> { |
|||
raw: GfTreemapDataPoint; |
|||
} |
|||
export interface GfTreemapTooltipItem extends TooltipItem<'treemap'> { |
|||
raw: GfTreemapDataPoint; |
|||
} |
|||
|
|||
Loading…
Reference in new issue