@tetacom/svg-charts 1.0.1
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.
- package/.browserslistrc +16 -0
- package/README.md +24 -0
- package/dist/README.md +24 -0
- package/dist/chart/base/series-base.component.d.ts +22 -0
- package/dist/chart/chart/chart.component.d.ts +29 -0
- package/dist/chart/chart-container/chart-container.component.d.ts +42 -0
- package/dist/chart/chart-container/gridlines/gridlines.component.d.ts +23 -0
- package/dist/chart/chart-container/plotband/plotband.component.d.ts +33 -0
- package/dist/chart/chart-container/plotline/plotline.component.d.ts +30 -0
- package/dist/chart/chart-container/series/bar/bar-series.component.d.ts +25 -0
- package/dist/chart/chart-container/series/line/line-series.component.d.ts +28 -0
- package/dist/chart/chart-container/series-host/series-host.component.d.ts +20 -0
- package/dist/chart/chart-container/tooltip/tooltip.component.d.ts +29 -0
- package/dist/chart/chart-container/x-axis/x-axis.component.d.ts +23 -0
- package/dist/chart/chart-container/y-axis/y-axis.component.d.ts +24 -0
- package/dist/chart/chart.module.d.ts +22 -0
- package/dist/chart/core/axis/axis.d.ts +54 -0
- package/dist/chart/core/axis/builders/axis-size-builder.d.ts +8 -0
- package/dist/chart/core/axis/builders/extremes-builder.d.ts +7 -0
- package/dist/chart/core/axis/builders/public-api.d.ts +2 -0
- package/dist/chart/core/utils/generate-ticks.d.ts +1 -0
- package/dist/chart/core/utils/get-text-width.d.ts +1 -0
- package/dist/chart/core/utils/public-api.d.ts +2 -0
- package/dist/chart/directives/brushable.directive.d.ts +17 -0
- package/dist/chart/directives/zoomable.directive.d.ts +20 -0
- package/dist/chart/legend/legend.component.d.ts +14 -0
- package/dist/chart/model/axis-options.d.ts +17 -0
- package/dist/chart/model/base-point.d.ts +9 -0
- package/dist/chart/model/chart-bounds.d.ts +12 -0
- package/dist/chart/model/enum/axis-orientation.d.ts +4 -0
- package/dist/chart/model/enum/axis-type.d.ts +7 -0
- package/dist/chart/model/enum/brush-type.d.ts +5 -0
- package/dist/chart/model/enum/drag-point-type.d.ts +5 -0
- package/dist/chart/model/enum/series-type.d.ts +4 -0
- package/dist/chart/model/enum/tooltip-tracking.d.ts +4 -0
- package/dist/chart/model/enum/zoom-type.d.ts +5 -0
- package/dist/chart/model/i-broadcast-message.d.ts +5 -0
- package/dist/chart/model/i-builder.d.ts +3 -0
- package/dist/chart/model/i-chart-config.d.ts +32 -0
- package/dist/chart/model/i-chart-event.d.ts +4 -0
- package/dist/chart/model/i-display-tooltip.d.ts +6 -0
- package/dist/chart/model/i-point-move.d.ts +6 -0
- package/dist/chart/model/marker-options.d.ts +7 -0
- package/dist/chart/model/plotband.d.ts +31 -0
- package/dist/chart/model/plotline.d.ts +19 -0
- package/dist/chart/model/series.d.ts +17 -0
- package/dist/chart/model/svg-attributes.d.ts +14 -0
- package/dist/chart/model/tooltip-options.d.ts +8 -0
- package/dist/chart/service/axes.service.d.ts +11 -0
- package/dist/chart/service/broadcast.service.d.ts +11 -0
- package/dist/chart/service/brush.service.d.ts +17 -0
- package/dist/chart/service/chart.service.d.ts +38 -0
- package/dist/chart/service/scale.service.d.ts +14 -0
- package/dist/chart/service/zoom.service.d.ts +25 -0
- package/dist/esm2020/chart/base/series-base.component.mjs +34 -0
- package/dist/esm2020/chart/chart/chart.component.mjs +73 -0
- package/dist/esm2020/chart/chart-container/chart-container.component.mjs +151 -0
- package/dist/esm2020/chart/chart-container/gridlines/gridlines.component.mjs +41 -0
- package/dist/esm2020/chart/chart-container/plotband/plotband.component.mjs +139 -0
- package/dist/esm2020/chart/chart-container/plotline/plotline.component.mjs +79 -0
- package/dist/esm2020/chart/chart-container/series/bar/bar-series.component.mjs +48 -0
- package/dist/esm2020/chart/chart-container/series/line/line-series.component.mjs +148 -0
- package/dist/esm2020/chart/chart-container/series-host/series-host.component.mjs +59 -0
- package/dist/esm2020/chart/chart-container/tooltip/tooltip.component.mjs +81 -0
- package/dist/esm2020/chart/chart-container/x-axis/x-axis.component.mjs +56 -0
- package/dist/esm2020/chart/chart-container/y-axis/y-axis.component.mjs +63 -0
- package/dist/esm2020/chart/chart.module.mjs +62 -0
- package/dist/esm2020/chart/core/axis/axis.mjs +96 -0
- package/dist/esm2020/chart/core/axis/builders/axis-size-builder.mjs +24 -0
- package/dist/esm2020/chart/core/axis/builders/extremes-builder.mjs +32 -0
- package/dist/esm2020/chart/core/axis/builders/public-api.mjs +3 -0
- package/dist/esm2020/chart/core/utils/generate-ticks.mjs +11 -0
- package/dist/esm2020/chart/core/utils/get-text-width.mjs +6 -0
- package/dist/esm2020/chart/core/utils/public-api.mjs +3 -0
- package/dist/esm2020/chart/directives/brushable.directive.mjs +28 -0
- package/dist/esm2020/chart/directives/zoomable.directive.mjs +37 -0
- package/dist/esm2020/chart/legend/legend.component.mjs +30 -0
- package/dist/esm2020/chart/model/axis-options.mjs +2 -0
- package/dist/esm2020/chart/model/base-point.mjs +2 -0
- package/dist/esm2020/chart/model/chart-bounds.mjs +13 -0
- package/dist/esm2020/chart/model/enum/axis-orientation.mjs +6 -0
- package/dist/esm2020/chart/model/enum/axis-type.mjs +9 -0
- package/dist/esm2020/chart/model/enum/brush-type.mjs +7 -0
- package/dist/esm2020/chart/model/enum/drag-point-type.mjs +7 -0
- package/dist/esm2020/chart/model/enum/series-type.mjs +6 -0
- package/dist/esm2020/chart/model/enum/tooltip-tracking.mjs +6 -0
- package/dist/esm2020/chart/model/enum/zoom-type.mjs +7 -0
- package/dist/esm2020/chart/model/i-broadcast-message.mjs +2 -0
- package/dist/esm2020/chart/model/i-builder.mjs +2 -0
- package/dist/esm2020/chart/model/i-chart-config.mjs +2 -0
- package/dist/esm2020/chart/model/i-chart-event.mjs +2 -0
- package/dist/esm2020/chart/model/i-display-tooltip.mjs +2 -0
- package/dist/esm2020/chart/model/i-point-move.mjs +2 -0
- package/dist/esm2020/chart/model/marker-options.mjs +2 -0
- package/dist/esm2020/chart/model/plotband.mjs +16 -0
- package/dist/esm2020/chart/model/plotline.mjs +12 -0
- package/dist/esm2020/chart/model/series.mjs +2 -0
- package/dist/esm2020/chart/model/svg-attributes.mjs +2 -0
- package/dist/esm2020/chart/model/tooltip-options.mjs +2 -0
- package/dist/esm2020/chart/service/axes.service.mjs +29 -0
- package/dist/esm2020/chart/service/broadcast.service.mjs +25 -0
- package/dist/esm2020/chart/service/brush.service.mjs +67 -0
- package/dist/esm2020/chart/service/chart.service.mjs +76 -0
- package/dist/esm2020/chart/service/scale.service.mjs +64 -0
- package/dist/esm2020/chart/service/zoom.service.mjs +117 -0
- package/dist/esm2020/public-api.mjs +7 -0
- package/dist/esm2020/tetacom-svg-charts.mjs +5 -0
- package/dist/fesm2015/tetacom-svg-charts.mjs +1589 -0
- package/dist/fesm2015/tetacom-svg-charts.mjs.map +1 -0
- package/dist/fesm2020/tetacom-svg-charts.mjs +1575 -0
- package/dist/fesm2020/tetacom-svg-charts.mjs.map +1 -0
- package/dist/package.json +35 -0
- package/dist/public-api.d.ts +3 -0
- package/dist/tetacom-svg-charts.d.ts +5 -0
- package/karma.conf.js +44 -0
- package/ng-package.json +7 -0
- package/package.json +15 -0
- package/src/chart/Chart.stories.ts +397 -0
- package/src/chart/base/series-base.component.ts +41 -0
- package/src/chart/chart/chart.component.html +5 -0
- package/src/chart/chart/chart.component.scss +6 -0
- package/src/chart/chart/chart.component.spec.ts +25 -0
- package/src/chart/chart/chart.component.ts +97 -0
- package/src/chart/chart-container/chart-container.component.html +78 -0
- package/src/chart/chart-container/chart-container.component.scss +15 -0
- package/src/chart/chart-container/chart-container.component.spec.ts +25 -0
- package/src/chart/chart-container/chart-container.component.ts +242 -0
- package/src/chart/chart-container/gridlines/gridlines.component.html +7 -0
- package/src/chart/chart-container/gridlines/gridlines.component.scss +8 -0
- package/src/chart/chart-container/gridlines/gridlines.component.spec.ts +25 -0
- package/src/chart/chart-container/gridlines/gridlines.component.ts +55 -0
- package/src/chart/chart-container/plotband/plotband.component.html +58 -0
- package/src/chart/chart-container/plotband/plotband.component.scss +13 -0
- package/src/chart/chart-container/plotband/plotband.component.spec.ts +25 -0
- package/src/chart/chart-container/plotband/plotband.component.ts +206 -0
- package/src/chart/chart-container/plotline/plotline.component.html +22 -0
- package/src/chart/chart-container/plotline/plotline.component.scss +6 -0
- package/src/chart/chart-container/plotline/plotline.component.spec.ts +25 -0
- package/src/chart/chart-container/plotline/plotline.component.ts +113 -0
- package/src/chart/chart-container/series/bar/bar-series.component.html +3 -0
- package/src/chart/chart-container/series/bar/bar-series.component.scss +0 -0
- package/src/chart/chart-container/series/bar/bar-series.component.ts +71 -0
- package/src/chart/chart-container/series/line/line-series.component.html +38 -0
- package/src/chart/chart-container/series/line/line-series.component.scss +9 -0
- package/src/chart/chart-container/series/line/line-series.component.spec.ts +25 -0
- package/src/chart/chart-container/series/line/line-series.component.ts +245 -0
- package/src/chart/chart-container/series-host/series-host.component.ts +80 -0
- package/src/chart/chart-container/tooltip/tooltip.component.html +14 -0
- package/src/chart/chart-container/tooltip/tooltip.component.scss +7 -0
- package/src/chart/chart-container/tooltip/tooltip.component.spec.ts +25 -0
- package/src/chart/chart-container/tooltip/tooltip.component.ts +134 -0
- package/src/chart/chart-container/x-axis/x-axis.component.html +1 -0
- package/src/chart/chart-container/x-axis/x-axis.component.scss +3 -0
- package/src/chart/chart-container/x-axis/x-axis.component.spec.ts +25 -0
- package/src/chart/chart-container/x-axis/x-axis.component.ts +80 -0
- package/src/chart/chart-container/y-axis/y-axis.component.html +4 -0
- package/src/chart/chart-container/y-axis/y-axis.component.scss +13 -0
- package/src/chart/chart-container/y-axis/y-axis.component.spec.ts +25 -0
- package/src/chart/chart-container/y-axis/y-axis.component.ts +90 -0
- package/src/chart/chart.module.ts +40 -0
- package/src/chart/core/axis/axis.ts +132 -0
- package/src/chart/core/axis/builders/axis-size-builder.ts +37 -0
- package/src/chart/core/axis/builders/extremes-builder.ts +45 -0
- package/src/chart/core/axis/builders/public-api.ts +2 -0
- package/src/chart/core/utils/generate-ticks.ts +14 -0
- package/src/chart/core/utils/get-text-width.ts +10 -0
- package/src/chart/core/utils/public-api.ts +2 -0
- package/src/chart/default/default-chart-config.ts +12 -0
- package/src/chart/directives/brushable.directive.ts +30 -0
- package/src/chart/directives/zoomable.directive.ts +31 -0
- package/src/chart/legend/legend.component.html +6 -0
- package/src/chart/legend/legend.component.scss +20 -0
- package/src/chart/legend/legend.component.spec.ts +25 -0
- package/src/chart/legend/legend.component.ts +35 -0
- package/src/chart/model/axis-options.ts +18 -0
- package/src/chart/model/base-point.ts +10 -0
- package/src/chart/model/chart-bounds.ts +18 -0
- package/src/chart/model/enum/axis-orientation.ts +4 -0
- package/src/chart/model/enum/axis-type.ts +7 -0
- package/src/chart/model/enum/brush-type.ts +5 -0
- package/src/chart/model/enum/drag-point-type.ts +5 -0
- package/src/chart/model/enum/public-api.ts +7 -0
- package/src/chart/model/enum/series-type.ts +4 -0
- package/src/chart/model/enum/tooltip-tracking.ts +4 -0
- package/src/chart/model/enum/zoom-type.ts +5 -0
- package/src/chart/model/i-broadcast-message.ts +5 -0
- package/src/chart/model/i-builder.ts +3 -0
- package/src/chart/model/i-chart-config.ts +33 -0
- package/src/chart/model/i-chart-event.ts +4 -0
- package/src/chart/model/i-display-tooltip.ts +7 -0
- package/src/chart/model/i-drag-event.ts +5 -0
- package/src/chart/model/i-point-move.ts +7 -0
- package/src/chart/model/marker-options.ts +8 -0
- package/src/chart/model/plotband.ts +45 -0
- package/src/chart/model/plotline.ts +29 -0
- package/src/chart/model/public-api.ts +0 -0
- package/src/chart/model/series.ts +18 -0
- package/src/chart/model/svg-attributes.ts +14 -0
- package/src/chart/model/tooltip-options.ts +37 -0
- package/src/chart/service/axes.service.spec.ts +16 -0
- package/src/chart/service/axes.service.ts +27 -0
- package/src/chart/service/broadcast.service.spec.ts +16 -0
- package/src/chart/service/broadcast.service.ts +24 -0
- package/src/chart/service/brush.service.spec.ts +16 -0
- package/src/chart/service/brush.service.ts +87 -0
- package/src/chart/service/chart.service.spec.ts +16 -0
- package/src/chart/service/chart.service.ts +100 -0
- package/src/chart/service/scale.service.spec.ts +16 -0
- package/src/chart/service/scale.service.ts +74 -0
- package/src/chart/service/zoom.service.spec.ts +16 -0
- package/src/chart/service/zoom.service.ts +153 -0
- package/src/public-api.ts +7 -0
- package/src/test.ts +27 -0
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import { Meta } from '@storybook/angular/types-6-0';
|
|
2
|
+
import { withKnobs } from '@storybook/addon-knobs';
|
|
3
|
+
import { ChartComponent } from './chart/chart.component';
|
|
4
|
+
import { ChartModule } from './chart.module';
|
|
5
|
+
import { IconModule } from '../../../components/src/component/icon/icon.module';
|
|
6
|
+
import { IChartConfig } from './model/i-chart-config';
|
|
7
|
+
import { AxisType } from './model/enum/axis-type';
|
|
8
|
+
import { SeriesType } from './model/enum/series-type';
|
|
9
|
+
import { randomInt } from 'd3-random';
|
|
10
|
+
import { Series } from './model/series';
|
|
11
|
+
import { BasePoint } from './model/base-point';
|
|
12
|
+
import * as faker from 'faker';
|
|
13
|
+
import { ZoomType } from './model/enum/zoom-type';
|
|
14
|
+
import { Plotband } from './model/plotband';
|
|
15
|
+
import { PlotLine } from './model/plotline';
|
|
16
|
+
import { DragPointType } from './model/enum/drag-point-type';
|
|
17
|
+
import { TooltipTracking } from './model/enum/tooltip-tracking';
|
|
18
|
+
import { BrushType } from './model/enum/brush-type';
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
title: 'Component/Chart',
|
|
22
|
+
decorators: [withKnobs],
|
|
23
|
+
component: ChartComponent,
|
|
24
|
+
moduleMetadata: {
|
|
25
|
+
imports: [ChartModule, IconModule],
|
|
26
|
+
},
|
|
27
|
+
} as Meta;
|
|
28
|
+
|
|
29
|
+
const cssColorNames = [
|
|
30
|
+
'AliceBlue',
|
|
31
|
+
'AntiqueWhite',
|
|
32
|
+
'Aqua',
|
|
33
|
+
'Aquamarine',
|
|
34
|
+
'Azure',
|
|
35
|
+
'Beige',
|
|
36
|
+
'Bisque',
|
|
37
|
+
'Black',
|
|
38
|
+
'BlanchedAlmond',
|
|
39
|
+
'Blue',
|
|
40
|
+
'BlueViolet',
|
|
41
|
+
'Brown',
|
|
42
|
+
'BurlyWood',
|
|
43
|
+
'CadetBlue',
|
|
44
|
+
'Chartreuse',
|
|
45
|
+
'Chocolate',
|
|
46
|
+
'Coral',
|
|
47
|
+
'CornflowerBlue',
|
|
48
|
+
'Cornsilk',
|
|
49
|
+
'Crimson',
|
|
50
|
+
'Cyan',
|
|
51
|
+
'DarkBlue',
|
|
52
|
+
'DarkCyan',
|
|
53
|
+
'DarkGoldenRod',
|
|
54
|
+
'DarkGray',
|
|
55
|
+
'DarkGrey',
|
|
56
|
+
'DarkGreen',
|
|
57
|
+
'DarkKhaki',
|
|
58
|
+
'DarkMagenta',
|
|
59
|
+
'DarkOliveGreen',
|
|
60
|
+
'DarkOrange',
|
|
61
|
+
'DarkOrchid',
|
|
62
|
+
'DarkRed',
|
|
63
|
+
'DarkSalmon',
|
|
64
|
+
'DarkSeaGreen',
|
|
65
|
+
'DarkSlateBlue',
|
|
66
|
+
'DarkSlateGray',
|
|
67
|
+
'DarkSlateGrey',
|
|
68
|
+
'DarkTurquoise',
|
|
69
|
+
'DarkViolet',
|
|
70
|
+
'DeepPink',
|
|
71
|
+
'DeepSkyBlue',
|
|
72
|
+
'DimGray',
|
|
73
|
+
'DimGrey',
|
|
74
|
+
'DodgerBlue',
|
|
75
|
+
'FireBrick',
|
|
76
|
+
'FloralWhite',
|
|
77
|
+
'ForestGreen',
|
|
78
|
+
'Fuchsia',
|
|
79
|
+
'Gainsboro',
|
|
80
|
+
'GhostWhite',
|
|
81
|
+
'Gold',
|
|
82
|
+
'GoldenRod',
|
|
83
|
+
'Gray',
|
|
84
|
+
'Grey',
|
|
85
|
+
'Green',
|
|
86
|
+
'GreenYellow',
|
|
87
|
+
'HoneyDew',
|
|
88
|
+
'HotPink',
|
|
89
|
+
'IndianRed',
|
|
90
|
+
'Indigo',
|
|
91
|
+
'Ivory',
|
|
92
|
+
'Khaki',
|
|
93
|
+
'Lavender',
|
|
94
|
+
'LavenderBlush',
|
|
95
|
+
'LawnGreen',
|
|
96
|
+
'LemonChiffon',
|
|
97
|
+
'LightBlue',
|
|
98
|
+
'LightCoral',
|
|
99
|
+
'LightCyan',
|
|
100
|
+
'LightGoldenRodYellow',
|
|
101
|
+
'LightGray',
|
|
102
|
+
'LightGrey',
|
|
103
|
+
'LightGreen',
|
|
104
|
+
'LightPink',
|
|
105
|
+
'LightSalmon',
|
|
106
|
+
'LightSeaGreen',
|
|
107
|
+
'LightSkyBlue',
|
|
108
|
+
'LightSlateGray',
|
|
109
|
+
'LightSlateGrey',
|
|
110
|
+
'LightSteelBlue',
|
|
111
|
+
'LightYellow',
|
|
112
|
+
'Lime',
|
|
113
|
+
'LimeGreen',
|
|
114
|
+
'Linen',
|
|
115
|
+
'Magenta',
|
|
116
|
+
'Maroon',
|
|
117
|
+
'MediumAquaMarine',
|
|
118
|
+
'MediumBlue',
|
|
119
|
+
'MediumOrchid',
|
|
120
|
+
'MediumPurple',
|
|
121
|
+
'MediumSeaGreen',
|
|
122
|
+
'MediumSlateBlue',
|
|
123
|
+
'MediumSpringGreen',
|
|
124
|
+
'MediumTurquoise',
|
|
125
|
+
'MediumVioletRed',
|
|
126
|
+
'MidnightBlue',
|
|
127
|
+
'MintCream',
|
|
128
|
+
'MistyRose',
|
|
129
|
+
'Moccasin',
|
|
130
|
+
'NavajoWhite',
|
|
131
|
+
'Navy',
|
|
132
|
+
'OldLace',
|
|
133
|
+
'Olive',
|
|
134
|
+
'OliveDrab',
|
|
135
|
+
'Orange',
|
|
136
|
+
'OrangeRed',
|
|
137
|
+
'Orchid',
|
|
138
|
+
'PaleGoldenRod',
|
|
139
|
+
'PaleGreen',
|
|
140
|
+
'PaleTurquoise',
|
|
141
|
+
'PaleVioletRed',
|
|
142
|
+
'PapayaWhip',
|
|
143
|
+
'PeachPuff',
|
|
144
|
+
'Peru',
|
|
145
|
+
'Pink',
|
|
146
|
+
'Plum',
|
|
147
|
+
'PowderBlue',
|
|
148
|
+
'Purple',
|
|
149
|
+
'RebeccaPurple',
|
|
150
|
+
'Red',
|
|
151
|
+
'RosyBrown',
|
|
152
|
+
'RoyalBlue',
|
|
153
|
+
'SaddleBrown',
|
|
154
|
+
'Salmon',
|
|
155
|
+
'SandyBrown',
|
|
156
|
+
'SeaGreen',
|
|
157
|
+
'SeaShell',
|
|
158
|
+
'Sienna',
|
|
159
|
+
'Silver',
|
|
160
|
+
'SkyBlue',
|
|
161
|
+
'SlateBlue',
|
|
162
|
+
'SlateGray',
|
|
163
|
+
'SlateGrey',
|
|
164
|
+
'Snow',
|
|
165
|
+
'SpringGreen',
|
|
166
|
+
'SteelBlue',
|
|
167
|
+
'Tan',
|
|
168
|
+
'Teal',
|
|
169
|
+
'Thistle',
|
|
170
|
+
'Tomato',
|
|
171
|
+
'Turquoise',
|
|
172
|
+
'Violet',
|
|
173
|
+
'Wheat',
|
|
174
|
+
'White',
|
|
175
|
+
'WhiteSmoke',
|
|
176
|
+
'Yellow',
|
|
177
|
+
'YellowGreen',
|
|
178
|
+
];
|
|
179
|
+
|
|
180
|
+
const randomColor = randomInt(0, cssColorNames.length - 1);
|
|
181
|
+
|
|
182
|
+
const seriesType = [SeriesType.line, SeriesType.line, SeriesType.line];
|
|
183
|
+
|
|
184
|
+
faker.locale = 'ru';
|
|
185
|
+
|
|
186
|
+
const series2: Series<BasePoint>[] = seriesType.map(
|
|
187
|
+
(type: SeriesType, index: number) => {
|
|
188
|
+
return {
|
|
189
|
+
id: index,
|
|
190
|
+
type,
|
|
191
|
+
name: faker.address.cityName(),
|
|
192
|
+
yAxisIndex: 0,
|
|
193
|
+
xAxisIndex: 0,
|
|
194
|
+
|
|
195
|
+
color: cssColorNames[randomColor()].toLowerCase(),
|
|
196
|
+
data: Array.from(Array(3000).keys()).map((key, index) => {
|
|
197
|
+
const num = faker.datatype.number({ min: 0, max: 500 });
|
|
198
|
+
|
|
199
|
+
const point = {
|
|
200
|
+
x: key,
|
|
201
|
+
y: num,
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
if (index % 10 === 0) {
|
|
205
|
+
point.x = null;
|
|
206
|
+
point.y = null;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return point;
|
|
210
|
+
}),
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
const series: Series<BasePoint>[] = seriesType.map(
|
|
216
|
+
(type: SeriesType, index: number) => {
|
|
217
|
+
return {
|
|
218
|
+
id: index,
|
|
219
|
+
type,
|
|
220
|
+
name: faker.address.cityName(),
|
|
221
|
+
yAxisIndex: 0,
|
|
222
|
+
xAxisIndex: 0,
|
|
223
|
+
style: {
|
|
224
|
+
strokeWidth: 0.5,
|
|
225
|
+
},
|
|
226
|
+
color: cssColorNames[randomColor()].toLowerCase(),
|
|
227
|
+
data: Array.from(Array(3000).keys()).map((key, index) => {
|
|
228
|
+
const num = faker.datatype.number({ min: 0, max: 500 });
|
|
229
|
+
|
|
230
|
+
const point: BasePoint = {
|
|
231
|
+
x: key,
|
|
232
|
+
y: num,
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
if (index % 30 === 0) {
|
|
236
|
+
point.marker = {
|
|
237
|
+
draggable: true,
|
|
238
|
+
dragType: DragPointType.xy,
|
|
239
|
+
style: {
|
|
240
|
+
fill: 'green',
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return point;
|
|
246
|
+
}),
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
const plotbands1 = [
|
|
252
|
+
new Plotband({
|
|
253
|
+
id: 0,
|
|
254
|
+
from: 10,
|
|
255
|
+
to: 12,
|
|
256
|
+
max: 20,
|
|
257
|
+
style: {
|
|
258
|
+
plotband: {
|
|
259
|
+
opacity: 0.2,
|
|
260
|
+
patternImage: 'patternintersect',
|
|
261
|
+
},
|
|
262
|
+
grabbers: {
|
|
263
|
+
strokeDasharray: '4, 4',
|
|
264
|
+
strokeWidth: 2,
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
}),
|
|
268
|
+
];
|
|
269
|
+
|
|
270
|
+
const plotbands2 = [
|
|
271
|
+
new Plotband({
|
|
272
|
+
id: 0,
|
|
273
|
+
from: 1100,
|
|
274
|
+
to: 1200,
|
|
275
|
+
draggable: true,
|
|
276
|
+
style: {
|
|
277
|
+
plotband: {
|
|
278
|
+
opacity: 0.6,
|
|
279
|
+
fill: 'green',
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
}),
|
|
283
|
+
];
|
|
284
|
+
|
|
285
|
+
const config: IChartConfig = {
|
|
286
|
+
name: '123123123132',
|
|
287
|
+
inverted: false,
|
|
288
|
+
tooltip: {
|
|
289
|
+
tracking: TooltipTracking.x,
|
|
290
|
+
},
|
|
291
|
+
xAxis: [
|
|
292
|
+
{
|
|
293
|
+
type: AxisType.number,
|
|
294
|
+
visible: true,
|
|
295
|
+
plotbands: plotbands2,
|
|
296
|
+
},
|
|
297
|
+
],
|
|
298
|
+
yAxis: [
|
|
299
|
+
{
|
|
300
|
+
type: AxisType.number,
|
|
301
|
+
visible: true,
|
|
302
|
+
title: 'атм',
|
|
303
|
+
plotlines: [
|
|
304
|
+
new PlotLine({
|
|
305
|
+
value: 360,
|
|
306
|
+
draggable: true,
|
|
307
|
+
style: {
|
|
308
|
+
stroke: cssColorNames[randomColor()].toLowerCase(),
|
|
309
|
+
},
|
|
310
|
+
}),
|
|
311
|
+
],
|
|
312
|
+
},
|
|
313
|
+
],
|
|
314
|
+
brush: {
|
|
315
|
+
enable: false,
|
|
316
|
+
type: BrushType.y,
|
|
317
|
+
},
|
|
318
|
+
zoom: {
|
|
319
|
+
enable: true,
|
|
320
|
+
type: ZoomType.x,
|
|
321
|
+
syncChannel: 'channelA',
|
|
322
|
+
},
|
|
323
|
+
legend: {
|
|
324
|
+
enable: true,
|
|
325
|
+
},
|
|
326
|
+
series,
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
const config2: IChartConfig = {
|
|
330
|
+
name: '123',
|
|
331
|
+
tooltip: {
|
|
332
|
+
tracking: TooltipTracking.x,
|
|
333
|
+
},
|
|
334
|
+
legend: {
|
|
335
|
+
enable: false,
|
|
336
|
+
},
|
|
337
|
+
inverted: false,
|
|
338
|
+
xAxis: [
|
|
339
|
+
{
|
|
340
|
+
type: AxisType.number,
|
|
341
|
+
visible: true,
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
type: AxisType.number,
|
|
345
|
+
visible: true,
|
|
346
|
+
opposite: true,
|
|
347
|
+
min: 0,
|
|
348
|
+
max: 1000,
|
|
349
|
+
},
|
|
350
|
+
],
|
|
351
|
+
yAxis: [
|
|
352
|
+
{
|
|
353
|
+
type: AxisType.number,
|
|
354
|
+
visible: true,
|
|
355
|
+
title: 'атм',
|
|
356
|
+
opposite: true,
|
|
357
|
+
plotlines: [
|
|
358
|
+
new PlotLine({
|
|
359
|
+
value: 360,
|
|
360
|
+
draggable: true,
|
|
361
|
+
style: {
|
|
362
|
+
stroke: cssColorNames[randomColor()].toLowerCase(),
|
|
363
|
+
},
|
|
364
|
+
}),
|
|
365
|
+
],
|
|
366
|
+
},
|
|
367
|
+
],
|
|
368
|
+
zoom: {
|
|
369
|
+
enable: true,
|
|
370
|
+
type: ZoomType.x,
|
|
371
|
+
syncChannel: '',
|
|
372
|
+
},
|
|
373
|
+
series: series2,
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
export const basicChart = () => ({
|
|
377
|
+
moduleMetadata: {
|
|
378
|
+
imports: [ChartModule, IconModule],
|
|
379
|
+
},
|
|
380
|
+
props: {
|
|
381
|
+
config,
|
|
382
|
+
config2,
|
|
383
|
+
event: (_) => {
|
|
384
|
+
console.log(_);
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
template: `
|
|
388
|
+
<div>
|
|
389
|
+
<div [tetaIconSprite]="['assets/icons.svg', 'assets/lithotype-icons.svg']" class="font-body-3 padding-3 bg-background-0" style="width: 100%; height: 40vh;">
|
|
390
|
+
<teta-chart [config]="config" (pointMove)="event($event)" class="bg-background-50 border border-text-50"></teta-chart>
|
|
391
|
+
</div>
|
|
392
|
+
<div [tetaIconSprite]="['assets/icons.svg', 'assets/lithotype-icons.svg']" class="font-body-3 padding-3 bg-background-0" style="width: 100%; height: 40vh;">
|
|
393
|
+
<teta-chart [config]="config2" (pointMove)="event($event)" class="bg-background-50 border border-text-50"></teta-chart>
|
|
394
|
+
</div>
|
|
395
|
+
</div>
|
|
396
|
+
`,
|
|
397
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectorRef,
|
|
3
|
+
Component,
|
|
4
|
+
ElementRef,
|
|
5
|
+
Input,
|
|
6
|
+
OnInit,
|
|
7
|
+
} from '@angular/core';
|
|
8
|
+
import { ChartService } from '../service/chart.service';
|
|
9
|
+
import { Series } from '../model/series';
|
|
10
|
+
import { BasePoint } from '../model/base-point';
|
|
11
|
+
import { ScaleService } from '../service/scale.service';
|
|
12
|
+
import { ZoomService } from '../service/zoom.service';
|
|
13
|
+
import { Observable, tap } from 'rxjs';
|
|
14
|
+
|
|
15
|
+
@Component({
|
|
16
|
+
template: '',
|
|
17
|
+
})
|
|
18
|
+
export class SeriesBaseComponent<T extends BasePoint> implements OnInit {
|
|
19
|
+
@Input() series: Series<T>;
|
|
20
|
+
@Input() size: DOMRect;
|
|
21
|
+
|
|
22
|
+
zoom: Observable<any>;
|
|
23
|
+
|
|
24
|
+
constructor(
|
|
25
|
+
protected svc: ChartService,
|
|
26
|
+
protected cdr: ChangeDetectorRef,
|
|
27
|
+
protected scaleService: ScaleService,
|
|
28
|
+
protected zoomService: ZoomService,
|
|
29
|
+
protected element: ElementRef
|
|
30
|
+
) {
|
|
31
|
+
this.zoomService.zoomed
|
|
32
|
+
.pipe(
|
|
33
|
+
tap((_) => {
|
|
34
|
+
this.cdr.detectChanges();
|
|
35
|
+
})
|
|
36
|
+
)
|
|
37
|
+
.subscribe();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
ngOnInit(): void {}
|
|
41
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { ChartComponent } from './chart.component';
|
|
4
|
+
|
|
5
|
+
describe('ChartComponent', () => {
|
|
6
|
+
let component: ChartComponent;
|
|
7
|
+
let fixture: ComponentFixture<ChartComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
declarations: [ ChartComponent ]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(ChartComponent);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
fixture.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create', () => {
|
|
23
|
+
expect(component).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
EventEmitter,
|
|
5
|
+
Input,
|
|
6
|
+
OnChanges,
|
|
7
|
+
OnDestroy,
|
|
8
|
+
OnInit,
|
|
9
|
+
Output,
|
|
10
|
+
SimpleChanges,
|
|
11
|
+
} from '@angular/core';
|
|
12
|
+
import { ChartService } from '../service/chart.service';
|
|
13
|
+
import { IChartConfig } from '../model/i-chart-config';
|
|
14
|
+
|
|
15
|
+
import { BasePoint } from '../model/base-point';
|
|
16
|
+
import { Series } from '../model/series';
|
|
17
|
+
import { ZoomService } from '../service/zoom.service';
|
|
18
|
+
import { ScaleService } from '../service/scale.service';
|
|
19
|
+
import { BrushService } from '../service/brush.service';
|
|
20
|
+
import { AxesService } from '../service/axes.service';
|
|
21
|
+
import { ChartBounds } from '../model/chart-bounds';
|
|
22
|
+
|
|
23
|
+
import { IChartEvent } from '../model/i-chart-event';
|
|
24
|
+
import { PlotLine } from '../model/plotline';
|
|
25
|
+
import { Plotband } from '../model/plotband';
|
|
26
|
+
import { IPointMove } from '../model/i-point-move';
|
|
27
|
+
|
|
28
|
+
@Component({
|
|
29
|
+
selector: 'teta-chart',
|
|
30
|
+
templateUrl: './chart.component.html',
|
|
31
|
+
styleUrls: ['./chart.component.scss'],
|
|
32
|
+
providers: [
|
|
33
|
+
ChartService,
|
|
34
|
+
ZoomService,
|
|
35
|
+
ScaleService,
|
|
36
|
+
AxesService,
|
|
37
|
+
BrushService,
|
|
38
|
+
],
|
|
39
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
40
|
+
})
|
|
41
|
+
export class ChartComponent implements OnInit, OnChanges, OnDestroy {
|
|
42
|
+
legendSeries: Array<Series<BasePoint>>;
|
|
43
|
+
|
|
44
|
+
@Output()
|
|
45
|
+
plotBandsMove: EventEmitter<IChartEvent<Plotband>> = new EventEmitter<
|
|
46
|
+
IChartEvent<Plotband>
|
|
47
|
+
>();
|
|
48
|
+
|
|
49
|
+
@Output()
|
|
50
|
+
plotLinesMove: EventEmitter<IChartEvent<PlotLine>> = new EventEmitter<
|
|
51
|
+
IChartEvent<PlotLine>
|
|
52
|
+
>();
|
|
53
|
+
|
|
54
|
+
@Output()
|
|
55
|
+
pointMove: EventEmitter<IChartEvent<IPointMove>> = new EventEmitter<
|
|
56
|
+
IChartEvent<IPointMove>
|
|
57
|
+
>();
|
|
58
|
+
|
|
59
|
+
@Input() set config(config: IChartConfig) {
|
|
60
|
+
this._config = Object.assign(
|
|
61
|
+
{
|
|
62
|
+
bounds: new ChartBounds(),
|
|
63
|
+
},
|
|
64
|
+
config
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get config() {
|
|
69
|
+
return this._config;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private _config;
|
|
73
|
+
|
|
74
|
+
constructor(private svc: ChartService, private zoomService: ZoomService) {}
|
|
75
|
+
|
|
76
|
+
ngOnChanges(changes: SimpleChanges) {}
|
|
77
|
+
|
|
78
|
+
ngOnInit(): void {
|
|
79
|
+
this.svc.plotbandMove.subscribe((_) => {
|
|
80
|
+
this.plotBandsMove.emit(_);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
this.svc.plotlineMove.subscribe((_) => {
|
|
84
|
+
this.plotLinesMove.emit(_);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
this.svc.pointMove.subscribe((_) => {
|
|
88
|
+
this.pointMove.emit(_);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
ngAfterViewInit() {}
|
|
93
|
+
|
|
94
|
+
ngOnDestroy() {
|
|
95
|
+
this.zoomService.broadcastSubscribtion?.unsubscribe();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<ng-container *ngIf="size | async as s">
|
|
2
|
+
<teta-tooltip [size]="s"></teta-tooltip>
|
|
3
|
+
<svg
|
|
4
|
+
[tetaZoomable]
|
|
5
|
+
[tetaBrushable]
|
|
6
|
+
[size]="s"
|
|
7
|
+
[config]="config"
|
|
8
|
+
[attr.width]="s.width"
|
|
9
|
+
[attr.height]="s.height"
|
|
10
|
+
[attr.viewBox]="'0 0 '+s.width+' '+s.height"
|
|
11
|
+
(mouseleave)="mouseLeave($event)"
|
|
12
|
+
(mousemove)="mouseMove($event)">
|
|
13
|
+
<ng-container *ngIf="getVisibleRect(s) as rect">
|
|
14
|
+
<defs>
|
|
15
|
+
<clipPath [attr.id]="'visible-window-' + id()">
|
|
16
|
+
<rect [attr.x]="rect.left" [attr.y]="rect.top" [attr.width]="rect.width" [attr.height]="rect.height"></rect>
|
|
17
|
+
</clipPath>
|
|
18
|
+
</defs>
|
|
19
|
+
|
|
20
|
+
<g class="y-axis-container">
|
|
21
|
+
<g *ngFor="let item of yAxes | keyvalue"
|
|
22
|
+
teta-y-axis
|
|
23
|
+
[axis]="item.value"
|
|
24
|
+
[size]="s"
|
|
25
|
+
[attr.transform]="getTranslate(item.value, s)"></g>
|
|
26
|
+
</g>
|
|
27
|
+
<g class="x-axis-container">
|
|
28
|
+
<g *ngFor="let item of xAxes | keyvalue"
|
|
29
|
+
teta-x-axis
|
|
30
|
+
|
|
31
|
+
[axis]="item.value"
|
|
32
|
+
[size]="s"
|
|
33
|
+
[attr.transform]="getTranslate(item.value, s)"></g>
|
|
34
|
+
</g>
|
|
35
|
+
<g [attr.clip-path]="'url(#visible-window-'+ id() +')'">
|
|
36
|
+
<g [attr.transform]="'translate('+ rect.left +', '+ rect.top +')'">
|
|
37
|
+
<g class="gridlines" teta-gridlines [size]="s"></g>
|
|
38
|
+
|
|
39
|
+
<g class="x-axis-plotline-container">
|
|
40
|
+
<ng-container *ngFor="let axis of config.xAxis; let i = index">
|
|
41
|
+
<g teta-plot-line *ngFor="let plotline of axis.plotlines" [plotline]="plotline" [size]="s"
|
|
42
|
+
[axis]="xAxes.get(i)"></g>
|
|
43
|
+
</ng-container>
|
|
44
|
+
</g>
|
|
45
|
+
|
|
46
|
+
<g class="y-axis-plotline-container">
|
|
47
|
+
<ng-container *ngFor="let axis of config.yAxis; let i = index">
|
|
48
|
+
<g teta-plot-line *ngFor="let plotline of axis.plotlines" [plotline]="plotline" [size]="s"
|
|
49
|
+
[axis]="yAxes.get(i)"></g>
|
|
50
|
+
</ng-container>
|
|
51
|
+
</g>
|
|
52
|
+
|
|
53
|
+
<g class="x-axis-plotband-container">
|
|
54
|
+
<ng-container *ngFor="let axis of config.xAxis; let i = index">
|
|
55
|
+
<g teta-plot-band *ngFor="let plotband of axis.plotbands" [plotband]="plotband" [size]="s"
|
|
56
|
+
[axis]="xAxes.get(i)"></g>
|
|
57
|
+
</ng-container>
|
|
58
|
+
</g>
|
|
59
|
+
<g class="y-axis-plotband-container">
|
|
60
|
+
<ng-container *ngFor="let axis of config.yAxis; let i = index">
|
|
61
|
+
<g teta-plot-band *ngFor="let plotband of axis.plotbands" [plotband]="plotband" [size]="s"
|
|
62
|
+
[axis]="yAxes.get(i)"></g>
|
|
63
|
+
</ng-container>
|
|
64
|
+
</g>
|
|
65
|
+
<g class="series-tooltip-line-marker"></g>
|
|
66
|
+
<g class="series-container">
|
|
67
|
+
<g teta-series-host
|
|
68
|
+
*ngFor="let series of config.series"
|
|
69
|
+
[series]="series"
|
|
70
|
+
[size]="s"></g>
|
|
71
|
+
</g>
|
|
72
|
+
</g>
|
|
73
|
+
</g>
|
|
74
|
+
</ng-container>
|
|
75
|
+
</svg>
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
</ng-container>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { ChartContainerComponent } from './chart-container.component';
|
|
4
|
+
|
|
5
|
+
describe('SeriesComponent', () => {
|
|
6
|
+
let component: ChartContainerComponent;
|
|
7
|
+
let fixture: ComponentFixture<ChartContainerComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
declarations: [ ChartContainerComponent ]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(ChartContainerComponent);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
fixture.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create', () => {
|
|
23
|
+
expect(component).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|