index.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 line from './line'
  21. import bar from './bar'
  22. import scatter from './scatter'
  23. import pie from './pie'
  24. import { IDrawingData } from '../../components/Pivot/Pivot'
  25. import { DimetionType } from '../../components/Widget'
  26. interface IChartOptions {
  27. chartOption: object
  28. stackOption?: boolean
  29. calcPieCenterAndRadius? (
  30. dimetionAxis: DimetionType,
  31. containerWidth: number,
  32. containerHeight: number,
  33. elementSize: number,
  34. unitMetricLengthArr: number[],
  35. horizontalRecordCountOfCol: number,
  36. verticalRecordCountOfRow: number,
  37. lineRecordSum: number,
  38. lineCount: number,
  39. unitCount: number,
  40. metricCount: number,
  41. recordCount: number,
  42. lineIndex: number,
  43. unitIndex: number,
  44. metricIndex: number,
  45. recordIndex: number
  46. ): { center: string[], radius: string[]}
  47. getSymbolSize? (name: string, size: number): number
  48. }
  49. export default function (type, drawingData?: IDrawingData): IChartOptions {
  50. switch (type) {
  51. case 'line': return line()
  52. case 'bar': return bar(drawingData.elementSize)
  53. case 'scatter': return scatter(drawingData.sizeRate)
  54. case 'pie': return pie()
  55. }
  56. }