c79c558c4add6f7333d071e2b886fd9bdc6c545c26adfb691a4f60e168036697b90fd25b8429334522ee730f13c896f006d5ed5ba914323a4b11562c206906 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import { HashMap } from 'zrender/lib/core/util.js';
  2. import { SourceFormat, SeriesLayoutBy, DimensionDefinition, OptionEncodeValue, OptionSourceData, DimensionName, OptionSourceHeader, DimensionDefinitionLoose } from '../util/types.js';
  3. import { DatasetOption } from '../component/dataset/install.js';
  4. /**
  5. * [sourceFormat]
  6. *
  7. * + "original":
  8. * This format is only used in series.data, where
  9. * itemStyle can be specified in data item.
  10. *
  11. * + "arrayRows":
  12. * [
  13. * ['product', 'score', 'amount'],
  14. * ['Matcha Latte', 89.3, 95.8],
  15. * ['Milk Tea', 92.1, 89.4],
  16. * ['Cheese Cocoa', 94.4, 91.2],
  17. * ['Walnut Brownie', 85.4, 76.9]
  18. * ]
  19. *
  20. * + "objectRows":
  21. * [
  22. * {product: 'Matcha Latte', score: 89.3, amount: 95.8},
  23. * {product: 'Milk Tea', score: 92.1, amount: 89.4},
  24. * {product: 'Cheese Cocoa', score: 94.4, amount: 91.2},
  25. * {product: 'Walnut Brownie', score: 85.4, amount: 76.9}
  26. * ]
  27. *
  28. * + "keyedColumns":
  29. * {
  30. * 'product': ['Matcha Latte', 'Milk Tea', 'Cheese Cocoa', 'Walnut Brownie'],
  31. * 'count': [823, 235, 1042, 988],
  32. * 'score': [95.8, 81.4, 91.2, 76.9]
  33. * }
  34. *
  35. * + "typedArray"
  36. *
  37. * + "unknown"
  38. */
  39. export interface SourceMetaRawOption {
  40. seriesLayoutBy: SeriesLayoutBy;
  41. sourceHeader: OptionSourceHeader;
  42. dimensions: DimensionDefinitionLoose[];
  43. }
  44. export interface Source extends SourceImpl {
  45. }
  46. declare class SourceImpl {
  47. /**
  48. * Not null/undefined.
  49. */
  50. readonly data: OptionSourceData;
  51. /**
  52. * See also "detectSourceFormat".
  53. * Not null/undefined.
  54. */
  55. readonly sourceFormat: SourceFormat;
  56. /**
  57. * 'row' or 'column'
  58. * Not null/undefined.
  59. */
  60. readonly seriesLayoutBy: SeriesLayoutBy;
  61. /**
  62. * dimensions definition from:
  63. * (1) standalone defined in option prop `dimensions: [...]`
  64. * (2) detected from option data. See `determineSourceDimensions`.
  65. * If can not be detected (e.g., there is only pure data `[[11, 33], ...]`
  66. * `dimensionsDefine` will be null/undefined.
  67. */
  68. readonly dimensionsDefine: DimensionDefinition[];
  69. /**
  70. * Only make sense in `SOURCE_FORMAT_ARRAY_ROWS`.
  71. * That is the same as `sourceHeader: number`,
  72. * which means from which line the real data start.
  73. * Not null/undefined, uint.
  74. */
  75. readonly startIndex: number;
  76. /**
  77. * Dimension count detected from data. Only works when `dimensionDefine`
  78. * does not exists.
  79. * Can be null/undefined (when unknown), uint.
  80. */
  81. readonly dimensionsDetectedCount: number;
  82. /**
  83. * Raw props from user option.
  84. */
  85. readonly metaRawOption: SourceMetaRawOption;
  86. constructor(fields: {
  87. data: OptionSourceData;
  88. sourceFormat: SourceFormat;
  89. seriesLayoutBy?: SeriesLayoutBy;
  90. dimensionsDefine?: DimensionDefinition[];
  91. startIndex?: number;
  92. dimensionsDetectedCount?: number;
  93. metaRawOption?: SourceMetaRawOption;
  94. encodeDefine?: HashMap<OptionEncodeValue, DimensionName>;
  95. });
  96. }
  97. export declare function isSourceInstance(val: unknown): val is Source;
  98. /**
  99. * Create a source from option.
  100. * NOTE: Created source is immutable. Don't change any properties in it.
  101. */
  102. export declare function createSource(sourceData: OptionSourceData, thisMetaRawOption: SourceMetaRawOption, sourceFormat: SourceFormat): Source;
  103. /**
  104. * Wrap original series data for some compatibility cases.
  105. */
  106. export declare function createSourceFromSeriesDataOption(data: OptionSourceData): Source;
  107. /**
  108. * Clone source but excludes source data.
  109. */
  110. export declare function cloneSourceShallow(source: Source): Source;
  111. /**
  112. * Note: An empty array will be detected as `SOURCE_FORMAT_ARRAY_ROWS`.
  113. */
  114. export declare function detectSourceFormat(data: DatasetOption['source']): SourceFormat;
  115. export declare function shouldRetrieveDataByName(source: Source): boolean;
  116. export {};