@formant/ava 3.4.21-formant → 3.5.0-formant

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/ava.min.js +1 -1
  2. package/esm/insight/chart/constants.js +2 -23
  3. package/esm/insight/chart/generator/index.js +0 -1
  4. package/esm/insight/chart/generator/insights.js +2 -2
  5. package/esm/insight/chart/index.js +0 -1
  6. package/esm/insight/chart/strategy/augmentedMarks/categoryOutlier.js +5 -11
  7. package/esm/insight/chart/strategy/augmentedMarks/changePoint.js +11 -27
  8. package/esm/insight/chart/strategy/augmentedMarks/correlation.js +1 -2
  9. package/esm/insight/chart/strategy/augmentedMarks/index.js +0 -1
  10. package/esm/insight/chart/strategy/augmentedMarks/lowVariance.js +6 -11
  11. package/esm/insight/chart/strategy/augmentedMarks/majority.js +1 -2
  12. package/esm/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.js +10 -67
  13. package/esm/insight/chart/strategy/augmentedMarks/trend.js +9 -9
  14. package/esm/insight/chart/strategy/chart.js +16 -27
  15. package/esm/insight/chart/strategy/commonMarks/areaMark.js +1 -11
  16. package/esm/insight/chart/strategy/commonMarks/barMark.js +6 -0
  17. package/esm/insight/chart/strategy/commonMarks/index.js +2 -2
  18. package/esm/insight/chart/strategy/commonMarks/lineMark.js +1 -33
  19. package/esm/insight/chart/strategy/commonMarks/pointMark.js +8 -12
  20. package/esm/insight/chart/strategy/commonMarks/ruleMark.js +2 -0
  21. package/esm/insight/chart/strategy/viewSpec.js +19 -13
  22. package/esm/insight/chart/types.js +7 -0
  23. package/esm/insight/narrative/strategy/categoryOutlier.js +2 -2
  24. package/esm/insight/narrative/strategy/trend.js +1 -1
  25. package/esm/insight/pipeline/specificInsight.js +2 -6
  26. package/esm/insight/pipeline/visualize.js +0 -2
  27. package/lib/index.d.ts +1 -1
  28. package/lib/insight/chart/constants.d.ts +2 -11
  29. package/lib/insight/chart/constants.js +3 -24
  30. package/lib/insight/chart/generator/index.d.ts +0 -1
  31. package/lib/insight/chart/generator/index.js +0 -1
  32. package/lib/insight/chart/generator/insights.d.ts +2 -2
  33. package/lib/insight/chart/generator/insights.js +2 -2
  34. package/lib/insight/chart/index.d.ts +0 -1
  35. package/lib/insight/chart/index.js +0 -1
  36. package/lib/insight/chart/strategy/augmentedMarks/categoryOutlier.d.ts +2 -3
  37. package/lib/insight/chart/strategy/augmentedMarks/categoryOutlier.js +4 -10
  38. package/lib/insight/chart/strategy/augmentedMarks/changePoint.d.ts +2 -3
  39. package/lib/insight/chart/strategy/augmentedMarks/changePoint.js +11 -27
  40. package/lib/insight/chart/strategy/augmentedMarks/correlation.d.ts +2 -2
  41. package/lib/insight/chart/strategy/augmentedMarks/correlation.js +1 -2
  42. package/lib/insight/chart/strategy/augmentedMarks/index.d.ts +0 -1
  43. package/lib/insight/chart/strategy/augmentedMarks/index.js +1 -3
  44. package/lib/insight/chart/strategy/augmentedMarks/lowVariance.d.ts +2 -3
  45. package/lib/insight/chart/strategy/augmentedMarks/lowVariance.js +5 -10
  46. package/lib/insight/chart/strategy/augmentedMarks/majority.d.ts +2 -2
  47. package/lib/insight/chart/strategy/augmentedMarks/majority.js +1 -2
  48. package/lib/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.d.ts +2 -3
  49. package/lib/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.js +10 -67
  50. package/lib/insight/chart/strategy/augmentedMarks/trend.d.ts +2 -3
  51. package/lib/insight/chart/strategy/augmentedMarks/trend.js +9 -9
  52. package/lib/insight/chart/strategy/chart.d.ts +6 -3
  53. package/lib/insight/chart/strategy/chart.js +15 -26
  54. package/lib/insight/chart/strategy/commonMarks/areaMark.d.ts +2 -3
  55. package/lib/insight/chart/strategy/commonMarks/areaMark.js +1 -11
  56. package/lib/insight/chart/strategy/commonMarks/barMark.d.ts +4 -0
  57. package/lib/insight/chart/strategy/commonMarks/barMark.js +10 -0
  58. package/lib/insight/chart/strategy/commonMarks/index.d.ts +2 -2
  59. package/lib/insight/chart/strategy/commonMarks/index.js +5 -5
  60. package/lib/insight/chart/strategy/commonMarks/lineMark.d.ts +2 -3
  61. package/lib/insight/chart/strategy/commonMarks/lineMark.js +1 -33
  62. package/lib/insight/chart/strategy/commonMarks/pointMark.d.ts +5 -4
  63. package/lib/insight/chart/strategy/commonMarks/pointMark.js +7 -11
  64. package/lib/insight/chart/strategy/commonMarks/ruleMark.d.ts +2 -0
  65. package/lib/insight/chart/strategy/commonMarks/ruleMark.js +6 -0
  66. package/lib/insight/chart/strategy/viewSpec.d.ts +9 -3
  67. package/lib/insight/chart/strategy/viewSpec.js +19 -13
  68. package/lib/insight/chart/types.d.ts +99 -42
  69. package/lib/insight/chart/types.js +7 -0
  70. package/lib/insight/chart/utils.d.ts +2 -3
  71. package/lib/insight/index.d.ts +1 -1
  72. package/lib/insight/narrative/strategy/categoryOutlier.js +2 -2
  73. package/lib/insight/narrative/strategy/trend.js +1 -1
  74. package/lib/insight/pipeline/specificInsight.d.ts +2 -3
  75. package/lib/insight/pipeline/specificInsight.js +2 -6
  76. package/lib/insight/pipeline/visualize.js +0 -2
  77. package/lib/insight/types.d.ts +3 -3
  78. package/package.json +1 -1
  79. package/esm/insight/chart/generator/homogeneous.js +0 -70
  80. package/esm/insight/chart/strategy/augmentedMarks/homogeneous.js +0 -5
  81. package/esm/insight/chart/strategy/commonMarks/intervalMark.js +0 -14
  82. package/esm/insight/chart/strategy/commonMarks/textMark.js +0 -28
  83. package/lib/insight/chart/generator/homogeneous.d.ts +0 -3
  84. package/lib/insight/chart/generator/homogeneous.js +0 -75
  85. package/lib/insight/chart/strategy/augmentedMarks/homogeneous.d.ts +0 -3
  86. package/lib/insight/chart/strategy/augmentedMarks/homogeneous.js +0 -9
  87. package/lib/insight/chart/strategy/commonMarks/intervalMark.d.ts +0 -5
  88. package/lib/insight/chart/strategy/commonMarks/intervalMark.js +0 -18
  89. package/lib/insight/chart/strategy/commonMarks/textMark.d.ts +0 -5
  90. package/lib/insight/chart/strategy/commonMarks/textMark.js +0 -32
@@ -1,29 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PIE_RADIUS_STYLE = exports.ChartTypeMap = exports.TEXT_STYLE = exports.BOLD_FONT_WEIGHT = exports.INSIGHT_COLOR_PLATTE = void 0;
4
- exports.INSIGHT_COLOR_PLATTE = {
5
- highlight: '#f89973',
6
- outlier: '#ea719d',
7
- font: '#bac4e2',
8
- defaultPointColor: '#fff',
9
- };
10
- exports.BOLD_FONT_WEIGHT = 500;
11
- exports.TEXT_STYLE = {
12
- textAlign: 'center',
13
- fill: exports.INSIGHT_COLOR_PLATTE.font,
14
- fontFamily: 'Moderat',
15
- opacity: 0.85,
16
- };
17
- exports.ChartTypeMap = {
18
- category_outlier: 'column_chart',
19
- trend: 'line_chart',
20
- change_point: 'line_chart',
21
- time_series_outlier: 'line_chart',
22
- majority: 'pie_chart',
23
- low_variance: 'column_chart',
24
- correlation: 'scatter_plot',
25
- };
26
- exports.PIE_RADIUS_STYLE = {
3
+ exports.PIE_RADIUS = void 0;
4
+ /** pie radii as fractions of the available radius */
5
+ exports.PIE_RADIUS = {
27
6
  innerRadius: 0.25,
28
7
  outerRadius: 0.8,
29
8
  };
@@ -1,2 +1 @@
1
- export * from './homogeneous';
2
1
  export * from './insights';
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./homogeneous"), exports);
5
4
  tslib_1.__exportStar(require("./insights"), exports);
@@ -1,3 +1,3 @@
1
- import { G2Spec } from '@antv/g2';
2
1
  import { InsightInfo, PatternInfo } from '../../types';
3
- export declare function generateInsightChartSpec(insight: InsightInfo<PatternInfo>): G2Spec;
2
+ import { InsightChartSpec } from '../types';
3
+ export declare function generateInsightChartSpec(insight: InsightInfo<PatternInfo>): InsightChartSpec;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateInsightChartSpec = void 0;
4
4
  var strategy_1 = require("../strategy");
5
5
  function generateInsightChartSpec(insight) {
6
- var _a;
6
+ var _a, _b;
7
7
  var insightType = insight.patterns[0].type;
8
8
  var insightType2Strategy = {
9
9
  trend: strategy_1.trendStrategy,
@@ -14,7 +14,7 @@ function generateInsightChartSpec(insight) {
14
14
  majority: strategy_1.majorityStrategy,
15
15
  correlation: strategy_1.correlationStrategy,
16
16
  };
17
- var marks = (_a = insightType2Strategy[insightType]) === null || _a === void 0 ? void 0 : _a.call(insightType2Strategy, insight);
17
+ var marks = (_b = (_a = insightType2Strategy[insightType]) === null || _a === void 0 ? void 0 : _a.call(insightType2Strategy, insight)) !== null && _b !== void 0 ? _b : [];
18
18
  return (0, strategy_1.viewSpecStrategy)(marks, insight);
19
19
  }
20
20
  exports.generateInsightChartSpec = generateInsightChartSpec;
@@ -1,4 +1,3 @@
1
- export * from './generator/homogeneous';
2
1
  export * from './generator/insights';
3
2
  export * from './strategy/augmentedMarks';
4
3
  export * from './types';
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./generator/homogeneous"), exports);
5
4
  tslib_1.__exportStar(require("./generator/insights"), exports);
6
5
  tslib_1.__exportStar(require("./strategy/augmentedMarks"), exports);
7
6
  tslib_1.__exportStar(require("./types"), exports);
@@ -1,5 +1,4 @@
1
- import { Mark } from '@antv/g2';
2
1
  import { InsightInfo, CategoryOutlierInfo } from '../../../types';
3
- import { CategoryOutlierMark } from '../../types';
2
+ import { CategoryOutlierMark, InsightChartMark } from '../../types';
4
3
  export declare const categoryOutlierAugmentedMarksStrategy: (insight: InsightInfo<CategoryOutlierInfo>) => CategoryOutlierMark[];
5
- export declare const categoryOutlierStrategy: (insight: InsightInfo<CategoryOutlierInfo>) => Mark[];
4
+ export declare const categoryOutlierStrategy: (insight: InsightInfo<CategoryOutlierInfo>) => InsightChartMark[];
@@ -10,20 +10,14 @@ var categoryOutlierAugmentedMarksStrategy = function (insight) {
10
10
  var patterns = insight.patterns;
11
11
  if (!(0, lodash_1.size)(patterns))
12
12
  return [];
13
- var categoryOutlierMarks = [];
14
- patterns.forEach(function (pattern) {
15
- var rectMark = (0, commonMarks_1.intervalMarkStrategy)([pattern]);
16
- categoryOutlierMarks.push({
17
- categoryOutlier: [rectMark],
18
- });
19
- });
20
- return categoryOutlierMarks;
13
+ return patterns.map(function (pattern) { return ({
14
+ categoryOutlier: [(0, commonMarks_1.barMarkStrategy)([pattern], { role: 'outlier', name: 'outlier' })],
15
+ }); });
21
16
  };
22
17
  exports.categoryOutlierAugmentedMarksStrategy = categoryOutlierAugmentedMarksStrategy;
23
18
  var categoryOutlierStrategy = function (insight) {
24
19
  var chart = (0, chart_1.insight2ChartStrategy)(insight);
25
- var categoryOutlierMarks = (0, exports.categoryOutlierAugmentedMarksStrategy)(insight);
26
- var marks = (0, utils_1.augmentedMarks2Marks)(categoryOutlierMarks);
20
+ var marks = (0, utils_1.augmentedMarks2Marks)((0, exports.categoryOutlierAugmentedMarksStrategy)(insight));
27
21
  return tslib_1.__spreadArray([chart], tslib_1.__read(marks), false);
28
22
  };
29
23
  exports.categoryOutlierStrategy = categoryOutlierStrategy;
@@ -1,5 +1,4 @@
1
- import { Mark } from '@antv/g2';
2
1
  import { ChangePointInfo, InsightInfo } from '../../../types';
3
- import { ChangePointMark } from '../../types';
2
+ import { ChangePointMark, InsightChartMark } from '../../types';
4
3
  export declare const changePointAugmentedMarksStrategy: (insight: InsightInfo<ChangePointInfo>) => ChangePointMark[];
5
- export declare const changePointStrategy: (insight: InsightInfo<ChangePointInfo>) => Mark[];
4
+ export declare const changePointStrategy: (insight: InsightInfo<ChangePointInfo>) => InsightChartMark[];
@@ -3,45 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.changePointStrategy = exports.changePointAugmentedMarksStrategy = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var lodash_1 = require("lodash");
6
- var constants_1 = require("../../constants");
7
6
  var utils_1 = require("../../../../utils");
8
- var pointMark_1 = require("../commonMarks/pointMark");
9
- var textMark_1 = require("../commonMarks/textMark");
7
+ var commonMarks_1 = require("../commonMarks");
10
8
  var chart_1 = require("../chart");
11
9
  var utils_2 = require("../../utils");
12
10
  var changePointAugmentedMarksStrategy = function (insight) {
13
11
  var patterns = insight.patterns;
14
- var color = constants_1.INSIGHT_COLOR_PLATTE.highlight;
15
12
  if (!(0, lodash_1.size)(patterns))
16
13
  return [];
17
14
  var measure = patterns[0].measure;
18
- var changePointMarks = [];
19
- patterns.forEach(function (pattern) {
20
- var pointMark = (0, pointMark_1.pointMarkStrategy)([pattern], { style: { fill: color } });
21
- var textMark = (0, textMark_1.textMarkStrategy)([pattern], {
22
- formatter: utils_1.dataFormat,
23
- label: function (pt) { return "".concat(pt.x, ", ").concat(measure, ": ").concat(pt.y); },
24
- style: {
25
- dy: -20,
26
- background: true,
27
- backgroundRadius: 2,
28
- connector: true,
29
- startMarker: true,
30
- startMarkerFill: '#1c1e2d',
31
- startMarkerFillOpacity: 0.65,
32
- },
33
- });
34
- changePointMarks.push({
35
- changePoint: [pointMark, textMark],
36
- });
37
- });
38
- return changePointMarks;
15
+ return patterns.map(function (pattern) { return ({
16
+ changePoint: [
17
+ (0, commonMarks_1.pointMarkStrategy)([pattern], {
18
+ role: 'highlight',
19
+ name: 'change point',
20
+ label: function (pt) { return "".concat(pt.x, ", ").concat(measure, ": ").concat((0, utils_1.dataFormat)(pt.y)); },
21
+ }),
22
+ ],
23
+ }); });
39
24
  };
40
25
  exports.changePointAugmentedMarksStrategy = changePointAugmentedMarksStrategy;
41
26
  var changePointStrategy = function (insight) {
42
27
  var chart = (0, chart_1.insight2ChartStrategy)(insight);
43
- var changePointMarks = (0, exports.changePointAugmentedMarksStrategy)(insight);
44
- var marks = (0, utils_2.augmentedMarks2Marks)(changePointMarks);
28
+ var marks = (0, utils_2.augmentedMarks2Marks)((0, exports.changePointAugmentedMarksStrategy)(insight));
45
29
  return tslib_1.__spreadArray([chart], tslib_1.__read(marks), false);
46
30
  };
47
31
  exports.changePointStrategy = changePointStrategy;
@@ -1,3 +1,3 @@
1
- import { Mark } from '@antv/g2';
2
1
  import { CorrelationInfo, InsightInfo } from '../../../types';
3
- export declare const correlationStrategy: (insight: InsightInfo<CorrelationInfo>) => Mark[];
2
+ import { InsightChartMark } from '../../types';
3
+ export declare const correlationStrategy: (insight: InsightInfo<CorrelationInfo>) => InsightChartMark[];
@@ -4,7 +4,6 @@ exports.correlationStrategy = void 0;
4
4
  var chart_1 = require("../chart");
5
5
  var correlationStrategy = function (insight) {
6
6
  // todo add correlation regression line and value
7
- var chartMark = (0, chart_1.insight2ChartStrategy)(insight);
8
- return [chartMark];
7
+ return [(0, chart_1.insight2ChartStrategy)(insight)];
9
8
  };
10
9
  exports.correlationStrategy = correlationStrategy;
@@ -4,5 +4,4 @@ export { categoryOutlierStrategy, categoryOutlierAugmentedMarksStrategy } from '
4
4
  export { changePointStrategy, changePointAugmentedMarksStrategy } from './changePoint';
5
5
  export { majorityStrategy } from './majority';
6
6
  export { correlationStrategy } from './correlation';
7
- export { homogeneousStrategy } from './homogeneous';
8
7
  export { timeSeriesOutlierStrategy, timeSeriesOutlierStrategyAugmentedMarksStrategy } from './timeSeriesOutlier';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.timeSeriesOutlierStrategyAugmentedMarksStrategy = exports.timeSeriesOutlierStrategy = exports.homogeneousStrategy = exports.correlationStrategy = exports.majorityStrategy = exports.changePointAugmentedMarksStrategy = exports.changePointStrategy = exports.categoryOutlierAugmentedMarksStrategy = exports.categoryOutlierStrategy = exports.lowVarianceAugmentedMarkStrategy = exports.lowVarianceStrategy = exports.trendAugmentedMarksStrategy = exports.trendStrategy = void 0;
3
+ exports.timeSeriesOutlierStrategyAugmentedMarksStrategy = exports.timeSeriesOutlierStrategy = exports.correlationStrategy = exports.majorityStrategy = exports.changePointAugmentedMarksStrategy = exports.changePointStrategy = exports.categoryOutlierAugmentedMarksStrategy = exports.categoryOutlierStrategy = exports.lowVarianceAugmentedMarkStrategy = exports.lowVarianceStrategy = exports.trendAugmentedMarksStrategy = exports.trendStrategy = void 0;
4
4
  var trend_1 = require("./trend");
5
5
  Object.defineProperty(exports, "trendStrategy", { enumerable: true, get: function () { return trend_1.trendStrategy; } });
6
6
  Object.defineProperty(exports, "trendAugmentedMarksStrategy", { enumerable: true, get: function () { return trend_1.trendAugmentedMarksStrategy; } });
@@ -17,8 +17,6 @@ var majority_1 = require("./majority");
17
17
  Object.defineProperty(exports, "majorityStrategy", { enumerable: true, get: function () { return majority_1.majorityStrategy; } });
18
18
  var correlation_1 = require("./correlation");
19
19
  Object.defineProperty(exports, "correlationStrategy", { enumerable: true, get: function () { return correlation_1.correlationStrategy; } });
20
- var homogeneous_1 = require("./homogeneous");
21
- Object.defineProperty(exports, "homogeneousStrategy", { enumerable: true, get: function () { return homogeneous_1.homogeneousStrategy; } });
22
20
  var timeSeriesOutlier_1 = require("./timeSeriesOutlier");
23
21
  Object.defineProperty(exports, "timeSeriesOutlierStrategy", { enumerable: true, get: function () { return timeSeriesOutlier_1.timeSeriesOutlierStrategy; } });
24
22
  Object.defineProperty(exports, "timeSeriesOutlierStrategyAugmentedMarksStrategy", { enumerable: true, get: function () { return timeSeriesOutlier_1.timeSeriesOutlierStrategyAugmentedMarksStrategy; } });
@@ -1,5 +1,4 @@
1
- import { Mark } from '@antv/g2';
2
1
  import { LowVarianceInfo, InsightInfo } from '../../../types';
3
- import { LowVarianceMark } from '../../types';
2
+ import { InsightChartMark, LowVarianceMark } from '../../types';
4
3
  export declare const lowVarianceAugmentedMarkStrategy: (insight: InsightInfo<LowVarianceInfo>) => LowVarianceMark[];
5
- export declare const lowVarianceStrategy: (insight: InsightInfo<LowVarianceInfo>) => Mark[];
4
+ export declare const lowVarianceStrategy: (insight: InsightInfo<LowVarianceInfo>) => InsightChartMark[];
@@ -7,22 +7,17 @@ var chart_1 = require("../chart");
7
7
  var utils_1 = require("../../utils");
8
8
  var utils_2 = require("../../../../utils");
9
9
  var lowVarianceAugmentedMarkStrategy = function (insight) {
10
- var patterns = insight.patterns;
11
- var marks = [];
12
- patterns.forEach(function (pattern) {
13
- var mean = pattern.mean;
14
- var meanLineMark = (0, commonMarks_1.lineMarkStrategy)({ y: mean }, { label: "mean: ".concat((0, utils_2.dataFormat)(mean)) });
15
- marks.push({
16
- meanLine: [meanLineMark],
10
+ return insight.patterns.map(function (_a) {
11
+ var mean = _a.mean;
12
+ return ({
13
+ meanLine: [(0, commonMarks_1.ruleYMarkStrategy)(mean, { role: 'mean', name: 'mean', label: "mean: ".concat((0, utils_2.dataFormat)(mean)) })],
17
14
  });
18
15
  });
19
- return marks;
20
16
  };
21
17
  exports.lowVarianceAugmentedMarkStrategy = lowVarianceAugmentedMarkStrategy;
22
18
  var lowVarianceStrategy = function (insight) {
23
19
  var chartMark = (0, chart_1.insight2ChartStrategy)(insight);
24
- var lowVarianceMarks = (0, exports.lowVarianceAugmentedMarkStrategy)(insight);
25
- var marks = (0, utils_1.augmentedMarks2Marks)(lowVarianceMarks);
20
+ var marks = (0, utils_1.augmentedMarks2Marks)((0, exports.lowVarianceAugmentedMarkStrategy)(insight));
26
21
  return tslib_1.__spreadArray([chartMark], tslib_1.__read(marks), false);
27
22
  };
28
23
  exports.lowVarianceStrategy = lowVarianceStrategy;
@@ -1,3 +1,3 @@
1
- import { Mark } from '@antv/g2';
2
1
  import { MajorityInfo, InsightInfo } from '../../../types';
3
- export declare const majorityStrategy: (insight: InsightInfo<MajorityInfo>) => Mark[];
2
+ import { InsightChartMark } from '../../types';
3
+ export declare const majorityStrategy: (insight: InsightInfo<MajorityInfo>) => InsightChartMark[];
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.majorityStrategy = void 0;
4
4
  var chart_1 = require("../chart");
5
5
  var majorityStrategy = function (insight) {
6
- var chartMark = (0, chart_1.insight2ChartStrategy)(insight);
7
- return [chartMark];
6
+ return [(0, chart_1.insight2ChartStrategy)(insight)];
8
7
  };
9
8
  exports.majorityStrategy = majorityStrategy;
@@ -1,5 +1,4 @@
1
- import { Mark } from '@antv/g2';
2
1
  import { TimeSeriesOutlierInfo, InsightInfo } from '../../../types';
3
- import { TimeSeriesOutlierMark } from '../../types';
2
+ import { InsightChartMark, TimeSeriesOutlierMark } from '../../types';
4
3
  export declare const timeSeriesOutlierStrategyAugmentedMarksStrategy: (insight: InsightInfo<TimeSeriesOutlierInfo>) => TimeSeriesOutlierMark[];
5
- export declare const timeSeriesOutlierStrategy: (insight: InsightInfo<TimeSeriesOutlierInfo>) => Mark[];
4
+ export declare const timeSeriesOutlierStrategy: (insight: InsightInfo<TimeSeriesOutlierInfo>) => InsightChartMark[];
@@ -4,84 +4,27 @@ exports.timeSeriesOutlierStrategy = exports.timeSeriesOutlierStrategyAugmentedMa
4
4
  var tslib_1 = require("tslib");
5
5
  var chart_1 = require("../chart");
6
6
  var commonMarks_1 = require("../commonMarks");
7
- var BASELINE = 'baseline';
8
- var INTERVAL = 'interval';
9
- var OUTLIER = 'outlier';
10
7
  var timeSeriesOutlierStrategyAugmentedMarksStrategy = function (insight) {
11
8
  var chartData = insight.data, _a = tslib_1.__read(insight.dimensions, 1), dimensionName = _a[0].fieldName, patterns = insight.patterns;
12
9
  var _b = patterns[0], baselines = _b.baselines, thresholds = _b.thresholds;
13
- var data = chartData.map(function (datum, index) {
14
- var baseline = baselines[index];
15
- var interval = [baseline - Math.abs(thresholds[0]), baseline + thresholds[1]];
16
- return {
17
- baseline: {
18
- x: datum[dimensionName],
19
- y: baseline,
20
- },
21
- interval: {
22
- x: datum[dimensionName],
23
- y: interval,
24
- },
25
- };
26
- });
27
- var intervalData = data.map(function (datum) { return datum[INTERVAL]; });
28
- var intervalMark = (0, commonMarks_1.areaMarkStrategy)(intervalData, {
29
- encode: {
30
- shape: 'smooth',
31
- },
32
- style: {
33
- fillOpacity: 0.3,
34
- fill: '#ffd8b8',
35
- },
36
- tooltip: {
37
- title: '',
38
- items: [
39
- function (_d, i, _data, column) { return ({
40
- name: INTERVAL,
41
- value: "".concat(column.y.value[i], "-").concat(column.y1.value[i]),
42
- color: '#ffd8b8',
43
- }); },
44
- ],
45
- },
46
- });
47
- var baselineData = data.map(function (datum) { return datum[BASELINE]; });
48
- var baselineMark = (0, commonMarks_1.lineMarkStrategy)({ points: baselineData }, {
49
- encode: {
50
- shape: 'smooth',
51
- },
52
- style: {
53
- lineWidth: 1,
54
- stroke: '#ffa45c',
55
- lineDash: undefined,
56
- },
57
- tooltip: {
58
- title: '',
59
- items: [{ name: BASELINE, channel: 'y' }],
60
- },
61
- });
62
- var outlierMark = (0, commonMarks_1.pointMarkStrategy)(patterns, {
63
- style: {
64
- fill: '#f4664a',
65
- stroke: '#f4664a',
66
- },
67
- tooltip: {
68
- title: '',
69
- items: [{ name: OUTLIER, channel: 'y' }],
70
- },
71
- });
10
+ var intervalData = chartData.map(function (datum, index) { return ({
11
+ x: datum[dimensionName],
12
+ y0: baselines[index] - Math.abs(thresholds[0]),
13
+ y1: baselines[index] + thresholds[1],
14
+ }); });
15
+ var baselineData = chartData.map(function (datum, index) { return ({ x: datum[dimensionName], y: baselines[index] }); });
72
16
  return [
73
17
  {
74
- trendLine: [baselineMark],
75
- anomalyArea: [intervalMark],
76
- outliers: [outlierMark],
18
+ trendLine: [(0, commonMarks_1.lineMarkStrategy)(baselineData, { role: 'baseline', name: 'baseline', smooth: true })],
19
+ anomalyArea: [(0, commonMarks_1.areaMarkStrategy)(intervalData, { role: 'band', name: 'interval', smooth: true })],
20
+ outliers: [(0, commonMarks_1.pointMarkStrategy)(patterns, { role: 'outlier', name: 'outlier' })],
77
21
  },
78
22
  ];
79
23
  };
80
24
  exports.timeSeriesOutlierStrategyAugmentedMarksStrategy = timeSeriesOutlierStrategyAugmentedMarksStrategy;
81
25
  var timeSeriesOutlierStrategy = function (insight) {
82
- // Should to support marks free combination
83
26
  var chartMark = (0, chart_1.insight2ChartStrategy)(insight);
84
- var _a = (0, exports.timeSeriesOutlierStrategyAugmentedMarksStrategy)(insight)[0] || {}, _b = _a.trendLine, trendLine = _b === void 0 ? [] : _b, _c = _a.anomalyArea, anomalyArea = _c === void 0 ? [] : _c, _e = _a.outliers, outliers = _e === void 0 ? [] : _e;
27
+ var _a = (0, exports.timeSeriesOutlierStrategyAugmentedMarksStrategy)(insight)[0] || {}, _b = _a.trendLine, trendLine = _b === void 0 ? [] : _b, _c = _a.anomalyArea, anomalyArea = _c === void 0 ? [] : _c, _d = _a.outliers, outliers = _d === void 0 ? [] : _d;
85
28
  return tslib_1.__spreadArray(tslib_1.__spreadArray(tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(anomalyArea), false), tslib_1.__read(trendLine), false), [chartMark], false), tslib_1.__read(outliers), false);
86
29
  };
87
30
  exports.timeSeriesOutlierStrategy = timeSeriesOutlierStrategy;
@@ -1,5 +1,4 @@
1
- import { Mark } from '@antv/g2';
2
1
  import { InsightInfo, TrendInfo } from '../../../types';
3
- import { TrendMark } from '../../types';
2
+ import { InsightChartMark, TrendMark } from '../../types';
4
3
  export declare const trendAugmentedMarksStrategy: (insight: InsightInfo<TrendInfo>) => TrendMark[];
5
- export declare const trendStrategy: (insight: InsightInfo<TrendInfo>) => Mark[];
4
+ export declare const trendStrategy: (insight: InsightInfo<TrendInfo>) => InsightChartMark[];
@@ -7,17 +7,17 @@ var chart_1 = require("../chart");
7
7
  var utils_1 = require("../../../../utils");
8
8
  var trendAugmentedMarksStrategy = function (insight) {
9
9
  var chartData = insight.data, _a = tslib_1.__read(insight.dimensions, 1), dimensionName = _a[0].fieldName, patterns = insight.patterns;
10
- var points = chartData.map(function (datum, index) {
11
- var points = patterns[0].regression.points;
12
- var point = points[index];
13
- return [datum[dimensionName], point];
14
- });
15
- var _b = tslib_1.__read(patterns[0].regression.equation, 2), m = _b[0], c = _b[1];
16
- var lineData = points.map(function (point) { return ({ x: point[0], y: point[1] }); });
17
- var regressionLineMark = (0, commonMarks_1.lineMarkStrategy)({ points: lineData }, { label: "y=".concat((0, utils_1.dataFormat)(m), "x").concat(c < 0 ? '' : '+').concat((0, utils_1.dataFormat)(c)) });
10
+ var _b = patterns[0].regression, points = _b.points, _c = tslib_1.__read(_b.equation, 2), m = _c[0], c = _c[1];
11
+ var lineData = chartData.map(function (datum, index) { return ({ x: datum[dimensionName], y: points[index] }); });
18
12
  return [
19
13
  {
20
- trendLine: [regressionLineMark],
14
+ trendLine: [
15
+ (0, commonMarks_1.lineMarkStrategy)(lineData, {
16
+ role: 'trend',
17
+ name: 'trend',
18
+ label: "y=".concat((0, utils_1.dataFormat)(m), "x").concat(c < 0 ? '' : '+').concat((0, utils_1.dataFormat)(c)),
19
+ }),
20
+ ],
21
21
  },
22
22
  ];
23
23
  };
@@ -1,7 +1,10 @@
1
- import { Mark } from '@antv/g2';
2
1
  import { InsightInfo, InsightType } from '../../types';
3
- export declare const insight2ChartStrategy: (insight: Omit<InsightInfo<import("../../types").PatternInfo>, "patterns" | "visualizationSpecs"> & {
2
+ import { InsightChartMark } from '../types';
3
+ type ChartInsight = Omit<InsightInfo, 'visualizationSpecs' | 'patterns'> & {
4
4
  patterns: {
5
5
  type: InsightType;
6
6
  }[];
7
- }) => Mark;
7
+ };
8
+ /** the mark that draws the insight data itself */
9
+ export declare const insight2ChartStrategy: (insight: ChartInsight) => InsightChartMark;
10
+ export {};
@@ -3,46 +3,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.insight2ChartStrategy = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var constants_1 = require("../constants");
6
+ /** the mark that draws the insight data itself */
6
7
  var insight2ChartStrategy = function (insight) {
7
- var _a, _b;
8
+ var _a, _b, _c;
8
9
  var data = insight.data, patterns = insight.patterns, dimensions = insight.dimensions, measures = insight.measures;
9
10
  var insightType = patterns[0].type;
10
- var commonSpec = {
11
- data: data,
12
- encode: {
13
- x: dimensions[0].fieldName,
14
- y: measures[0].fieldName,
15
- },
16
- };
11
+ var dimension = (_a = dimensions[0]) === null || _a === void 0 ? void 0 : _a.fieldName;
12
+ var measure = (_b = measures[0]) === null || _b === void 0 ? void 0 : _b.fieldName;
13
+ var points = function () { return data.map(function (datum) { return ({ x: datum[dimension], y: Number(datum[measure]) }); }); };
17
14
  // pie
18
15
  if (insightType === 'majority') {
19
- return tslib_1.__assign(tslib_1.__assign({}, commonSpec), { type: 'interval', encode: {
20
- color: dimensions[0].fieldName,
21
- y: measures[0].fieldName,
22
- }, transform: [{ type: 'stackY' }], coordinate: {
23
- type: 'theta',
24
- innerRadius: constants_1.PIE_RADIUS_STYLE.innerRadius,
25
- outerRadius: constants_1.PIE_RADIUS_STYLE.outerRadius,
26
- }, tooltip: {
27
- items: [{ field: dimensions[0].fieldName }, { field: measures[0].fieldName }],
28
- } });
16
+ return tslib_1.__assign({ type: 'arc', role: 'primary', name: measure, data: data.map(function (datum) { return ({ name: String(datum[dimension]), value: Number(datum[measure]) }); }) }, constants_1.PIE_RADIUS);
29
17
  }
30
18
  // line
31
19
  if (insightType === 'trend' || insightType === 'time_series_outlier' || insightType === 'change_point') {
32
- return tslib_1.__assign(tslib_1.__assign({}, commonSpec), { type: 'line', style: {
33
- lineWidth: 2,
34
- } });
20
+ return { type: 'line', role: 'primary', name: measure, data: points() };
35
21
  }
36
22
  // bar
37
23
  if (insightType === 'category_outlier' || insightType === 'low_variance') {
38
- return tslib_1.__assign(tslib_1.__assign({}, commonSpec), { type: 'interval' });
24
+ return { type: 'bar', role: 'primary', name: measure, data: points() };
39
25
  }
40
26
  // scatter
41
27
  if (insightType === 'correlation') {
42
- return tslib_1.__assign(tslib_1.__assign({}, commonSpec), { type: 'point', encode: {
43
- x: (_a = measures[0]) === null || _a === void 0 ? void 0 : _a.fieldName,
44
- y: (_b = measures[1]) === null || _b === void 0 ? void 0 : _b.fieldName,
45
- } });
28
+ var yMeasure_1 = (_c = measures[1]) === null || _c === void 0 ? void 0 : _c.fieldName;
29
+ return {
30
+ type: 'point',
31
+ role: 'primary',
32
+ name: "".concat(measure, " / ").concat(yMeasure_1),
33
+ data: data.map(function (datum) { return ({ x: Number(datum[measure]), y: Number(datum[yMeasure_1]) }); }),
34
+ };
46
35
  }
47
36
  return null;
48
37
  };
@@ -1,3 +1,2 @@
1
- import { AreaMark } from '@antv/g2';
2
- import { AreaMarkData, AreaMarkConfig } from '../../types';
3
- export declare const areaMarkStrategy: (data: AreaMarkData, { encode, style, tooltip }: AreaMarkConfig) => AreaMark;
1
+ import type { InsightAreaMark } from '../../types';
2
+ export declare const areaMarkStrategy: (data: InsightAreaMark['data'], config: Omit<InsightAreaMark, 'type' | 'data'>) => InsightAreaMark;
@@ -2,15 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.areaMarkStrategy = void 0;
4
4
  var tslib_1 = require("tslib");
5
- var areaMarkStrategy = function (data, _a) {
6
- var encode = _a.encode, style = _a.style, tooltip = _a.tooltip;
7
- var common = {
8
- style: style,
9
- tooltip: tooltip,
10
- };
11
- if (data) {
12
- return tslib_1.__assign(tslib_1.__assign({}, common), { type: 'area', data: data, encode: tslib_1.__assign({ x: 'x', y: 'y' }, encode) });
13
- }
14
- return null;
15
- };
5
+ var areaMarkStrategy = function (data, config) { return (tslib_1.__assign({ type: 'area', data: data }, config)); };
16
6
  exports.areaMarkStrategy = areaMarkStrategy;
@@ -0,0 +1,4 @@
1
+ import type { PointPatternInfo } from '../../../types';
2
+ import type { InsightBarMark } from '../../types';
3
+ /** get mark for point patterns, the patterns should have same dimension and measure */
4
+ export declare const barMarkStrategy: (patterns: PointPatternInfo[], config: Omit<InsightBarMark, 'type' | 'data'>) => InsightBarMark;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.barMarkStrategy = void 0;
4
+ var tslib_1 = require("tslib");
5
+ /** get mark for point patterns, the patterns should have same dimension and measure */
6
+ var barMarkStrategy = function (patterns, config) { return (tslib_1.__assign({ type: 'bar', data: patterns.map(function (_a) {
7
+ var x = _a.x, y = _a.y;
8
+ return ({ x: x, y: y });
9
+ }) }, config)); };
10
+ exports.barMarkStrategy = barMarkStrategy;
@@ -1,5 +1,5 @@
1
1
  export { lineMarkStrategy } from './lineMark';
2
2
  export { pointMarkStrategy } from './pointMark';
3
- export { textMarkStrategy } from './textMark';
4
3
  export { areaMarkStrategy } from './areaMark';
5
- export { intervalMarkStrategy } from './intervalMark';
4
+ export { barMarkStrategy } from './barMark';
5
+ export { ruleYMarkStrategy } from './ruleMark';
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.intervalMarkStrategy = exports.areaMarkStrategy = exports.textMarkStrategy = exports.pointMarkStrategy = exports.lineMarkStrategy = void 0;
3
+ exports.ruleYMarkStrategy = exports.barMarkStrategy = exports.areaMarkStrategy = exports.pointMarkStrategy = exports.lineMarkStrategy = void 0;
4
4
  var lineMark_1 = require("./lineMark");
5
5
  Object.defineProperty(exports, "lineMarkStrategy", { enumerable: true, get: function () { return lineMark_1.lineMarkStrategy; } });
6
6
  var pointMark_1 = require("./pointMark");
7
7
  Object.defineProperty(exports, "pointMarkStrategy", { enumerable: true, get: function () { return pointMark_1.pointMarkStrategy; } });
8
- var textMark_1 = require("./textMark");
9
- Object.defineProperty(exports, "textMarkStrategy", { enumerable: true, get: function () { return textMark_1.textMarkStrategy; } });
10
8
  var areaMark_1 = require("./areaMark");
11
9
  Object.defineProperty(exports, "areaMarkStrategy", { enumerable: true, get: function () { return areaMark_1.areaMarkStrategy; } });
12
- var intervalMark_1 = require("./intervalMark");
13
- Object.defineProperty(exports, "intervalMarkStrategy", { enumerable: true, get: function () { return intervalMark_1.intervalMarkStrategy; } });
10
+ var barMark_1 = require("./barMark");
11
+ Object.defineProperty(exports, "barMarkStrategy", { enumerable: true, get: function () { return barMark_1.barMarkStrategy; } });
12
+ var ruleMark_1 = require("./ruleMark");
13
+ Object.defineProperty(exports, "ruleYMarkStrategy", { enumerable: true, get: function () { return ruleMark_1.ruleYMarkStrategy; } });
@@ -1,3 +1,2 @@
1
- import { LineMark } from '@antv/g2';
2
- import { LineMarkConfig, LineMarkData } from '../../types';
3
- export declare const lineMarkStrategy: ({ points, x, y }: LineMarkData, { encode, style, label, tooltip }: LineMarkConfig) => LineMark;
1
+ import type { InsightChartPoint, InsightLineMark } from '../../types';
2
+ export declare const lineMarkStrategy: (data: InsightChartPoint[], config: Omit<InsightLineMark, 'type' | 'data'>) => InsightLineMark;