models.gen.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. // NOTE: This file will be auto generated from models.cue
  3. // It is currenty hand written but will serve as the target for cuetsy
  4. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. import { LegendDisplayMode, OptionsWithLegend } from '@grafana/schema';
  6. export const modelVersion = Object.freeze([1, 0]);
  7. export enum VizDisplayMode {
  8. CandlesVolume = 'candles+volume',
  9. Candles = 'candles',
  10. Volume = 'volume',
  11. }
  12. export enum CandleStyle {
  13. Candles = 'candles',
  14. OHLCBars = 'ohlcbars',
  15. }
  16. export enum ColorStrategy {
  17. // up/down color depends on current close vs current open
  18. // filled always
  19. OpenClose = 'open-close',
  20. // up/down color depends on current close vs prior close
  21. // filled/hollow depends on current close vs current open
  22. CloseClose = 'close-close',
  23. }
  24. export interface CandlestickFieldMap {
  25. open?: string;
  26. high?: string;
  27. low?: string;
  28. close?: string;
  29. volume?: string;
  30. }
  31. export interface CandlestickColors {
  32. up: string;
  33. down: string;
  34. flat: string;
  35. }
  36. export const defaultColors: CandlestickColors = {
  37. up: 'green',
  38. down: 'red',
  39. flat: 'gray',
  40. };
  41. export interface CandlestickOptions extends OptionsWithLegend {
  42. mode: VizDisplayMode;
  43. candleStyle: CandleStyle;
  44. colorStrategy: ColorStrategy;
  45. fields: CandlestickFieldMap;
  46. colors: CandlestickColors;
  47. // When enabled, all fields will be sent to the graph
  48. includeAllFields?: boolean;
  49. }
  50. export const defaultPanelOptions: CandlestickOptions = {
  51. mode: VizDisplayMode.CandlesVolume,
  52. candleStyle: CandleStyle.Candles,
  53. colorStrategy: ColorStrategy.OpenClose,
  54. colors: defaultColors,
  55. fields: {},
  56. legend: {
  57. displayMode: LegendDisplayMode.List,
  58. placement: 'bottom',
  59. calcs: [],
  60. },
  61. includeAllFields: false,
  62. };