util.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2017 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * >>
  19. */
  20. import { IReferenceLine, IReferenceBand } from './types'
  21. import { ReferenceValueType, ReferenceLabelPosition } from './constants'
  22. import {
  23. PIVOT_CHART_FONT_FAMILIES,
  24. PIVOT_DEFAULT_FONT_COLOR,
  25. CHART_LABEL_POSITIONS
  26. } from 'app/globalConstants'
  27. import defaultTheme from 'assets/json/echartsThemes/default.project.json'
  28. const defaultThemeColors = defaultTheme.theme.color
  29. export function getDefaultReferenceLineData(): Pick<IReferenceLine, 'data'> {
  30. return {
  31. data: {
  32. metric: void 0,
  33. type: ReferenceValueType.Constant,
  34. value: 0,
  35. label: {
  36. visible: false,
  37. position: ReferenceLabelPosition.Start,
  38. font: {
  39. size: '12',
  40. family: PIVOT_CHART_FONT_FAMILIES[0].value,
  41. // style: string,
  42. // weight: string,
  43. color: PIVOT_DEFAULT_FONT_COLOR
  44. }
  45. },
  46. line: {
  47. width: 1,
  48. type: 'solid',
  49. color: defaultThemeColors[0]
  50. }
  51. }
  52. }
  53. }
  54. export function getDefaultReferenceBandData(): Pick<IReferenceBand, 'data'> {
  55. return {
  56. data: [
  57. {
  58. metric: void 0,
  59. type: ReferenceValueType.Constant,
  60. value: 0
  61. },
  62. {
  63. metric: void 0,
  64. type: ReferenceValueType.Constant,
  65. value: 0,
  66. label: {
  67. visible: false,
  68. position: CHART_LABEL_POSITIONS[0].value,
  69. font: {
  70. size: '12',
  71. family: PIVOT_CHART_FONT_FAMILIES[0].value,
  72. // style: string,
  73. // weight: string,
  74. color: PIVOT_DEFAULT_FONT_COLOR
  75. }
  76. },
  77. band: {
  78. color: defaultThemeColors[0],
  79. border: {
  80. width: 0,
  81. type: 'solid',
  82. color: '#000'
  83. }
  84. }
  85. }
  86. ]
  87. }
  88. }