UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

156 lines (155 loc) 9.53 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; var _a; import { size, get } from 'lodash'; import { ChartType } from '../../constants/chart-style'; import { getBucketMetricNameByFields } from './utils'; import SearchLineChartStyleService from './charts/line/line'; import SearchStackLineChartStyleService from './charts/line/stack'; import SearchPercentageLineChartStyleService from './charts/line/percentage-line'; import SearchAreaChartStyleService from './charts/line/area'; import SearchStackAreaChartStyleService from './charts/line/stack-area'; import SearchPercentageAreaChartStyleService from './charts/line/percentage-area'; import SearchPieBucketChartStyleService from './charts/pie/bucket'; import SearchPieMetricChartStyleService from './charts/pie/metric'; import SearchPieRingBucketChartStyleService from './charts/pie/ring-bucket'; import SearchPieRingMetricChartStyleService from './charts/pie/ring-metric'; import SearchPieRoseBucketChartStyleService from './charts/pie/rose-bucket'; import SearchPieRoseMetricChartStyleService from './charts/pie/rose-metric'; import SearchSingleValueChartStyleService from './charts/single/value'; import SearchSingleGaugeChartStyleService from './charts/single/gauge'; import SearchSinglePercentChartStyleService from './charts/single/percent'; import SearchBubbleChinaChartStyleService from './charts/map/bubbleChina'; import SearchBubbleWorldChartStyleService from './charts/map/bubbleWorld'; import SearchMigrationChinaStyleService from './charts/migration/china'; import SearchMigrationWorldStyleService from './charts/migration/world'; import SearchRelationHorizontalStyleService from './charts/relation/horizontal'; import SearchRelationCircularStyleService from './charts/relation/circular'; import SearchSankeyStyleService from './charts/sankey'; import SearchLineBarChartStyleService from './charts/combination/line-bar'; import SearchLineBarY2ChartStyleService from './charts/combination/line-bar-y2'; import SearchLineY2ChartStyleService from './charts/combination/line-y2'; import SearchBarChartStyleService from './charts/bar/bar'; import SearchStackBarChartStyleService from './charts/bar/stack'; import SearchPercentageBarChartStyleService from './charts/bar/percentage'; import SearchStackVerticalBarChartStyleService from './charts/bar/stack-vertical'; import SearchVerticalBarChartStyleService from './charts/bar/vertical'; import SearchPercentageVerticalBarChartStyleService from './charts/bar/percentage-vertical'; import SearchMapColorChinaStyleService from './charts/map/colorChina'; import SearchMapColorWorldStyleService from './charts/map/colorWorld'; import SearchRadarBucketChartStyleService from './charts/radar/bucket'; import SearchRadarMetricChartStyleService from './charts/radar/metric'; import SearchScatterChartStyleService from './charts/scatter/scatter'; import SearchBubbleChartStyleService from './charts/bubble/bubble'; import SearchGridTableChartStyleService from './charts/table/grid-table'; import SearchTreeTableChartStyleService from './charts/table/tree-table'; import SearchSunburstStyleService from './charts/sunburst/sunburst'; import SearchEditorStyleService from './charts/editor/editor'; import SearchOutlierStyleService from './charts/outlier'; import SearchTimeLineStyleService from './charts/timeline/timeline'; import SearchStatusPanelStyleService from './charts/metric-panel/status'; import SearchMetricPanelStyleService from './charts/metric-panel/metric'; import SearchCustomChartStyleService from './charts/custom'; import SearchCapsuleBarStyleService from './charts/capsule-bar'; import SearchMapboxBubbleChartStyleService from './charts/mapbox/bubble'; import SearchMapboxPathChartStyleService from './charts/mapbox/path'; import SearchLogEventChartStyleService from './charts/log-event'; import SearchHoneycombStyleService from './charts/honeycomb'; import SearchTopologyStyleService from './charts/topology'; var chartStyleServiceMap = (_a = {}, _a[ChartType.Line] = SearchLineChartStyleService, _a[ChartType.StackLine] = SearchStackLineChartStyleService, _a[ChartType.PercentageLine] = SearchPercentageLineChartStyleService, _a[ChartType.Area] = SearchAreaChartStyleService, _a[ChartType.StackArea] = SearchStackAreaChartStyleService, _a[ChartType.PercentageArea] = SearchPercentageAreaChartStyleService, _a[ChartType.LineBar] = SearchLineBarChartStyleService, _a[ChartType.LineBarY2] = SearchLineBarY2ChartStyleService, _a[ChartType.LineY2] = SearchLineY2ChartStyleService, _a[ChartType.Bar] = SearchBarChartStyleService, _a[ChartType.StackBar] = SearchStackBarChartStyleService, _a[ChartType.PercentageBar] = SearchPercentageBarChartStyleService, _a[ChartType.VerticalBar] = SearchVerticalBarChartStyleService, _a[ChartType.StackVerticalBar] = SearchStackVerticalBarChartStyleService, _a[ChartType.PercentageVerticalBar] = SearchPercentageVerticalBarChartStyleService, _a[ChartType.SingleValue] = SearchSingleValueChartStyleService, _a[ChartType.SingleGauge] = SearchSingleGaugeChartStyleService, _a[ChartType.SinglePercent] = SearchSinglePercentChartStyleService, _a[ChartType.PieBucket] = SearchPieBucketChartStyleService, _a[ChartType.PieMetric] = SearchPieMetricChartStyleService, _a[ChartType.PieRingBucket] = SearchPieRingBucketChartStyleService, _a[ChartType.PieRingMetric] = SearchPieRingMetricChartStyleService, _a[ChartType.PieRoseBucket] = SearchPieRoseBucketChartStyleService, _a[ChartType.PieRoseMetric] = SearchPieRoseMetricChartStyleService, _a[ChartType.MapColorChina] = SearchMapColorChinaStyleService, _a[ChartType.MapColorWorld] = SearchMapColorWorldStyleService, _a[ChartType.MapBubbleChina] = SearchBubbleChinaChartStyleService, _a[ChartType.MapBubbleWorld] = SearchBubbleWorldChartStyleService, _a[ChartType.MigrationChina] = SearchMigrationChinaStyleService, _a[ChartType.MigrationWorld] = SearchMigrationWorldStyleService, _a[ChartType.RelationHorizontal] = SearchRelationHorizontalStyleService, _a[ChartType.RelationCircular] = SearchRelationCircularStyleService, _a[ChartType.Sankey] = SearchSankeyStyleService, _a[ChartType.RadarBucket] = SearchRadarBucketChartStyleService, _a[ChartType.RadarMetric] = SearchRadarMetricChartStyleService, _a[ChartType.Scatter] = SearchScatterChartStyleService, _a[ChartType.Bubble] = SearchBubbleChartStyleService, _a[ChartType.GridTable] = SearchGridTableChartStyleService, _a[ChartType.TreeTable] = SearchTreeTableChartStyleService, _a[ChartType.Sunburst] = SearchSunburstStyleService, _a[ChartType.Editor] = SearchEditorStyleService, _a[ChartType.Outlier] = SearchOutlierStyleService, _a[ChartType.TimeLine] = SearchTimeLineStyleService, _a[ChartType.StatusPanel] = SearchStatusPanelStyleService, _a[ChartType.MetricPanel] = SearchMetricPanelStyleService, _a[ChartType.CapsuleBar] = SearchCapsuleBarStyleService, _a[ChartType.MapboxBubble] = SearchMapboxBubbleChartStyleService, _a[ChartType.MapboxPath] = SearchMapboxPathChartStyleService, _a[ChartType.LogEvent] = SearchLogEventChartStyleService, _a[ChartType.Honeycomb] = SearchHoneycombStyleService, _a[ChartType.TopoLogy] = SearchTopologyStyleService, _a); var SearchChartStyleFactory = /** @class */ (function () { function SearchChartStyleFactory() { } SearchChartStyleFactory.create = function (chartType, option, dataset, initFirst, isExtendsChart) { if (dataset === void 0) { dataset = { fields: [], rows: [] }; } if (initFirst === void 0) { initFirst = true; } if (isExtendsChart === void 0) { isExtendsChart = false; } var StyleService = isExtendsChart ? SearchCustomChartStyleService : get(chartStyleServiceMap, chartType); if (!StyleService) { throw new Error('chart type not exist'); } option = option || {}; var _a = getBucketMetricNameByFields(dataset.fields), metrics = _a.metrics, buckets = _a.buckets; var chartMetrics = option.metrics, chartBuckets = option.buckets, restOption = __rest(option, ["metrics", "buckets"]); var useCrossAxis2 = chartType === ChartType.LineBarY2 || chartType === ChartType.LineY2; return new StyleService(StyleService.getChartInitStyle(isExtendsChart ? option : __assign({ metrics: size(chartMetrics) > 0 ? chartMetrics : metrics, buckets: size(chartBuckets) > 0 ? chartBuckets : buckets, fields: dataset.fields }, restOption), initFirst, useCrossAxis2), chartType); }; return SearchChartStyleFactory; }()); export default SearchChartStyleFactory;