@amcharts/amcharts5 5.2.2 → 5.2.5
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/.internal/charts/hierarchy/ForceDirected.d.ts +2 -2
- package/.internal/charts/hierarchy/ForceDirected.d.ts.map +1 -1
- package/.internal/charts/hierarchy/ForceDirected.js +6 -0
- package/.internal/charts/hierarchy/ForceDirected.js.map +1 -1
- package/.internal/charts/hierarchy/Tree.d.ts +7 -0
- package/.internal/charts/hierarchy/Tree.d.ts.map +1 -1
- package/.internal/charts/hierarchy/Tree.js +14 -3
- package/.internal/charts/hierarchy/Tree.js.map +1 -1
- package/.internal/charts/map/MapChart.d.ts +2 -1
- package/.internal/charts/map/MapChart.d.ts.map +1 -1
- package/.internal/charts/map/MapChart.js +2 -1
- package/.internal/charts/map/MapChart.js.map +1 -1
- package/.internal/charts/stock/StockChart.js +1 -1
- package/.internal/charts/stock/StockChart.js.map +1 -1
- package/.internal/charts/stock/drawing/LabelSeries.js +1 -1
- package/.internal/charts/stock/drawing/LabelSeries.js.map +1 -1
- package/.internal/charts/stock/toolbar/DateRangeSelector.d.ts +14 -0
- package/.internal/charts/stock/toolbar/DateRangeSelector.d.ts.map +1 -1
- package/.internal/charts/stock/toolbar/DateRangeSelector.js +6 -2
- package/.internal/charts/stock/toolbar/DateRangeSelector.js.map +1 -1
- package/.internal/charts/stock/toolbar/IconControl.d.ts +3 -1
- package/.internal/charts/stock/toolbar/IconControl.d.ts.map +1 -1
- package/.internal/charts/stock/toolbar/IconControl.js +3 -1
- package/.internal/charts/stock/toolbar/IconControl.js.map +1 -1
- package/.internal/charts/stock/toolbar/PeriodSelector.d.ts.map +1 -1
- package/.internal/charts/stock/toolbar/PeriodSelector.js +8 -0
- package/.internal/charts/stock/toolbar/PeriodSelector.js.map +1 -1
- package/.internal/charts/stock/toolbar/StockToolbarCSS.js +23 -24
- package/.internal/charts/stock/toolbar/StockToolbarCSS.js.map +1 -1
- package/.internal/charts/xy/XYChart.d.ts +12 -0
- package/.internal/charts/xy/XYChart.d.ts.map +1 -1
- package/.internal/charts/xy/XYChart.js +137 -118
- package/.internal/charts/xy/XYChart.js.map +1 -1
- package/.internal/charts/xy/axes/DateAxis.d.ts.map +1 -1
- package/.internal/charts/xy/axes/DateAxis.js +35 -16
- package/.internal/charts/xy/axes/DateAxis.js.map +1 -1
- package/.internal/charts/xy/axes/GaplessDateAxis.d.ts.map +1 -1
- package/.internal/charts/xy/axes/GaplessDateAxis.js +15 -1
- package/.internal/charts/xy/axes/GaplessDateAxis.js.map +1 -1
- package/.internal/charts/xy/series/XYSeries.d.ts.map +1 -1
- package/.internal/charts/xy/series/XYSeries.js +4 -8
- package/.internal/charts/xy/series/XYSeries.js.map +1 -1
- package/.internal/core/util/EventDispatcher.d.ts +6 -0
- package/.internal/core/util/EventDispatcher.d.ts.map +1 -1
- package/.internal/core/util/EventDispatcher.js +20 -0
- package/.internal/core/util/EventDispatcher.js.map +1 -1
- package/.internal/core/util/Modal.d.ts.map +1 -1
- package/.internal/core/util/Modal.js +5 -2
- package/.internal/core/util/Modal.js.map +1 -1
- package/.internal/core/util/TextFormatter.d.ts.map +1 -1
- package/.internal/core/util/TextFormatter.js +1 -9
- package/.internal/core/util/TextFormatter.js.map +1 -1
- package/.internal/core/util/Time.js +8 -9
- package/.internal/core/util/Time.js.map +1 -1
- package/.internal/core/util/Timezone.d.ts +1 -0
- package/.internal/core/util/Timezone.d.ts.map +1 -1
- package/.internal/core/util/Timezone.js +28 -1
- package/.internal/core/util/Timezone.js.map +1 -1
- package/.internal/themes/DefaultTheme.d.ts.map +1 -1
- package/.internal/themes/DefaultTheme.js +1 -0
- package/.internal/themes/DefaultTheme.js.map +1 -1
- package/CHANGELOG.md +34 -0
- package/examples/javascript/flow-chord/package.json +1 -1
- package/examples/javascript/flow-chord-directed/package.json +1 -1
- package/examples/javascript/flow-chord-non-ribbon/package.json +1 -1
- package/examples/javascript/flow-sankey/package.json +1 -1
- package/examples/javascript/gauge/package.json +1 -1
- package/examples/javascript/gauge-bands/package.json +1 -1
- package/examples/javascript/hierarchy-force-directed/package.json +1 -1
- package/examples/javascript/hierarchy-pack/package.json +1 -1
- package/examples/javascript/hierarchy-partition/package.json +1 -1
- package/examples/javascript/hierarchy-sunburst/package.json +1 -1
- package/examples/javascript/hierarchy-tree/package.json +1 -1
- package/examples/javascript/hierarchy-treemap/package.json +1 -1
- package/examples/javascript/json/package.json +1 -1
- package/examples/javascript/map-animating-along-lines/package.json +1 -1
- package/examples/javascript/map-day-and-night/package.json +1 -1
- package/examples/javascript/map-globe-rotate-to-country/package.json +1 -1
- package/examples/javascript/map-globe-with-projected-circles/package.json +1 -1
- package/examples/javascript/map-with-bubbles/package.json +1 -1
- package/examples/javascript/map-zoom-to-country/package.json +1 -1
- package/examples/javascript/misc-40-charts/package.json +1 -1
- package/examples/javascript/misc-microchart-grid/package.json +1 -1
- package/examples/javascript/pie-chart/package.json +1 -1
- package/examples/javascript/pie-donut-chart/package.json +1 -1
- package/examples/javascript/pie-variable-radius/package.json +1 -1
- package/examples/javascript/radar-column-iwatch-style/package.json +1 -1
- package/examples/javascript/radar-heat-map/package.json +1 -1
- package/examples/javascript/radar-line/package.json +1 -1
- package/examples/javascript/radar-time-line/package.json +1 -1
- package/examples/javascript/sliced-funnel/package.json +1 -1
- package/examples/javascript/sliced-pictorial-stacked/package.json +1 -1
- package/examples/javascript/sliced-pyramid/package.json +1 -1
- package/examples/javascript/stock-chart/package.json +1 -1
- package/examples/javascript/stock-chart-comparing-stocks/package.json +1 -1
- package/examples/javascript/stock-chart-data-granularity/package.json +1 -1
- package/examples/javascript/stock-chart-data-grouping/package.json +1 -1
- package/examples/javascript/stock-chart-intraday/package.json +1 -1
- package/examples/javascript/stock-chart-live/index.js +155 -103
- package/examples/javascript/stock-chart-live/package.json +1 -1
- package/examples/javascript/stock-chart-volume-separate-panel/package.json +1 -1
- package/examples/javascript/venn-diagram/package.json +1 -1
- package/examples/javascript/wordcloud-with-data/package.json +1 -1
- package/examples/javascript/wordcloud-with-text/package.json +1 -1
- package/examples/javascript/xy-100-percent-stacked-column/package.json +1 -1
- package/examples/javascript/xy-animated-bullet-at-the-end-of-the-series/package.json +1 -1
- package/examples/javascript/xy-bubble/package.json +1 -1
- package/examples/javascript/xy-candlestick/package.json +1 -1
- package/examples/javascript/xy-clustered-column/package.json +1 -1
- package/examples/javascript/xy-column/package.json +1 -1
- package/examples/javascript/xy-comparing-series-google-analytics-style/package.json +1 -1
- package/examples/javascript/xy-data-grouping/package.json +1 -1
- package/examples/javascript/xy-draggable-range/package.json +1 -1
- package/examples/javascript/xy-drawing-series-with-mouse-or-touch/package.json +1 -1
- package/examples/javascript/xy-dumbbell plot/package.json +1 -1
- package/examples/javascript/xy-evenly-spaced-date-axis/package.json +1 -1
- package/examples/javascript/xy-line/package.json +1 -1
- package/examples/javascript/xy-line-highlight-on-legend-hover/package.json +1 -1
- package/examples/javascript/xy-live-data/package.json +1 -1
- package/examples/javascript/xy-multiple-synced-value-axes/package.json +1 -1
- package/examples/javascript/xy-ohlc/package.json +1 -1
- package/examples/javascript/xy-real-time-data-sorting/package.json +1 -1
- package/examples/javascript/xy-smoothed-line/package.json +1 -1
- package/examples/javascript/xy-stacked-and-clustered-column/package.json +1 -1
- package/examples/javascript/xy-stacked-column/package.json +1 -1
- package/examples/javascript/xy-stacked-step/package.json +1 -1
- package/examples/javascript/xy-stock/package.json +1 -1
- package/examples/javascript/xy-stock-comparing/package.json +1 -1
- package/examples/typescript/flow-chord/package.json +1 -1
- package/examples/typescript/flow-chord-directed/package.json +1 -1
- package/examples/typescript/flow-chord-non-ribbon/package.json +1 -1
- package/examples/typescript/flow-sankey/package.json +1 -1
- package/examples/typescript/gauge/package.json +1 -1
- package/examples/typescript/gauge-bands/package.json +1 -1
- package/examples/typescript/hierarchy-force-directed/package.json +1 -1
- package/examples/typescript/hierarchy-pack/package.json +1 -1
- package/examples/typescript/hierarchy-partition/package.json +1 -1
- package/examples/typescript/hierarchy-sunburst/package.json +1 -1
- package/examples/typescript/hierarchy-tree/package.json +1 -1
- package/examples/typescript/hierarchy-treemap/package.json +1 -1
- package/examples/typescript/json/package.json +1 -1
- package/examples/typescript/map-animating-along-lines/package.json +1 -1
- package/examples/typescript/map-day-and-night/package.json +1 -1
- package/examples/typescript/map-globe-rotate-to-country/package.json +1 -1
- package/examples/typescript/map-globe-with-projected-circles/package.json +1 -1
- package/examples/typescript/map-with-bubbles/package.json +1 -1
- package/examples/typescript/map-zoom-to-country/package.json +1 -1
- package/examples/typescript/misc-40-charts/package.json +1 -1
- package/examples/typescript/misc-microchart-grid/package.json +1 -1
- package/examples/typescript/pie-chart/package.json +1 -1
- package/examples/typescript/pie-donut-chart/package.json +1 -1
- package/examples/typescript/pie-variable-radius/package.json +1 -1
- package/examples/typescript/radar-column-iwatch-style/package.json +1 -1
- package/examples/typescript/radar-heat-map/package.json +1 -1
- package/examples/typescript/radar-line/package.json +1 -1
- package/examples/typescript/radar-time-line/package.json +1 -1
- package/examples/typescript/sliced-funnel/package.json +1 -1
- package/examples/typescript/sliced-pictorial-stacked/package.json +1 -1
- package/examples/typescript/sliced-pyramid/package.json +1 -1
- package/examples/typescript/stock-chart/package.json +1 -1
- package/examples/typescript/stock-chart-comparing-stocks/package.json +1 -1
- package/examples/typescript/stock-chart-data-granularity/package.json +1 -1
- package/examples/typescript/stock-chart-data-grouping/package.json +1 -1
- package/examples/typescript/stock-chart-intraday/package.json +1 -1
- package/examples/typescript/stock-chart-live/index.ts +160 -108
- package/examples/typescript/stock-chart-live/package.json +1 -1
- package/examples/typescript/stock-chart-volume-separate-panel/package.json +1 -1
- package/examples/typescript/venn-diagram/package.json +1 -1
- package/examples/typescript/wordcloud-with-data/package.json +1 -1
- package/examples/typescript/wordcloud-with-text/package.json +1 -1
- package/examples/typescript/xy-100-percent-stacked-column/package.json +1 -1
- package/examples/typescript/xy-animated-bullet-at-the-end-of-the-series/package.json +1 -1
- package/examples/typescript/xy-bubble/package.json +1 -1
- package/examples/typescript/xy-candlestick/package.json +1 -1
- package/examples/typescript/xy-clustered-column/package.json +1 -1
- package/examples/typescript/xy-column/package.json +1 -1
- package/examples/typescript/xy-comparing-series-google-analytics-style/package.json +1 -1
- package/examples/typescript/xy-data-grouping/package.json +1 -1
- package/examples/typescript/xy-draggable-range/package.json +1 -1
- package/examples/typescript/xy-drawing-series-with-mouse-or-touch/package.json +1 -1
- package/examples/typescript/xy-dumbbell plot/package.json +1 -1
- package/examples/typescript/xy-evenly-spaced-date-axis/package.json +1 -1
- package/examples/typescript/xy-line/package.json +1 -1
- package/examples/typescript/xy-line-highlight-on-legend-hover/package.json +1 -1
- package/examples/typescript/xy-live-data/package.json +1 -1
- package/examples/typescript/xy-multiple-synced-value-axes/package.json +1 -1
- package/examples/typescript/xy-ohlc/package.json +1 -1
- package/examples/typescript/xy-real-time-data-sorting/package.json +1 -1
- package/examples/typescript/xy-smoothed-line/package.json +1 -1
- package/examples/typescript/xy-stacked-and-clustered-column/package.json +1 -1
- package/examples/typescript/xy-stacked-column/package.json +1 -1
- package/examples/typescript/xy-stacked-step/package.json +1 -1
- package/examples/typescript/xy-stock/package.json +1 -1
- package/examples/typescript/xy-stock-comparing/package.json +1 -1
- package/package.json +3 -3
|
@@ -3,148 +3,170 @@ import * as am5xy from "@amcharts/amcharts5/xy";
|
|
|
3
3
|
import * as am5stock from "@amcharts/amcharts5/stock";
|
|
4
4
|
import am5themes_Animated from "@amcharts/amcharts5/themes/Animated";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
6
|
// Create root element
|
|
12
7
|
// -------------------------------------------------------------------------------
|
|
13
8
|
// https://www.amcharts.com/docs/v5/getting-started/#Root_element
|
|
14
9
|
let root = am5.Root.new("chartdiv");
|
|
15
10
|
|
|
16
|
-
|
|
17
11
|
// Set themes
|
|
18
12
|
// -------------------------------------------------------------------------------
|
|
19
13
|
// https://www.amcharts.com/docs/v5/concepts/themes/
|
|
20
|
-
root.setThemes([
|
|
21
|
-
am5themes_Animated.new(root)
|
|
22
|
-
]);
|
|
23
|
-
|
|
14
|
+
root.setThemes([am5themes_Animated.new(root)]);
|
|
24
15
|
|
|
25
16
|
// Create a stock chart
|
|
26
17
|
// -------------------------------------------------------------------------------
|
|
27
18
|
// https://www.amcharts.com/docs/v5/charts/stock-chart/#Instantiating_the_chart
|
|
28
|
-
let stockChart = root.container.children.push(
|
|
29
|
-
})
|
|
30
|
-
|
|
19
|
+
let stockChart = root.container.children.push(
|
|
20
|
+
am5stock.StockChart.new(root, {})
|
|
21
|
+
);
|
|
31
22
|
|
|
32
23
|
// Set global number format
|
|
33
24
|
// -------------------------------------------------------------------------------
|
|
34
25
|
// https://www.amcharts.com/docs/v5/concepts/formatters/formatting-numbers/
|
|
35
26
|
root.numberFormatter.set("numberFormat", "#,###.00");
|
|
36
27
|
|
|
37
|
-
|
|
38
28
|
// Create a main stock panel (chart)
|
|
39
29
|
// -------------------------------------------------------------------------------
|
|
40
30
|
// https://www.amcharts.com/docs/v5/charts/stock-chart/#Adding_panels
|
|
41
|
-
let mainPanel = stockChart.panels.push(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
let mainPanel = stockChart.panels.push(
|
|
32
|
+
am5stock.StockPanel.new(root, {
|
|
33
|
+
wheelY: "zoomX",
|
|
34
|
+
panX: true,
|
|
35
|
+
panY: true
|
|
36
|
+
})
|
|
37
|
+
);
|
|
47
38
|
|
|
48
39
|
// Create value axis
|
|
49
40
|
// -------------------------------------------------------------------------------
|
|
50
41
|
// https://www.amcharts.com/docs/v5/charts/xy-chart/axes/
|
|
51
|
-
let valueAxis = mainPanel.yAxes.push(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
42
|
+
let valueAxis = mainPanel.yAxes.push(
|
|
43
|
+
am5xy.ValueAxis.new(root, {
|
|
44
|
+
renderer: am5xy.AxisRendererY.new(root, {
|
|
45
|
+
pan: "zoom"
|
|
46
|
+
}),
|
|
47
|
+
extraMin: 0.1, // adds some space for for main series
|
|
48
|
+
tooltip: am5.Tooltip.new(root, {}),
|
|
49
|
+
numberFormat: "#,###.00",
|
|
50
|
+
extraTooltipPrecision: 2
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
let dateAxis = mainPanel.xAxes.push(
|
|
55
|
+
am5xy.GaplessDateAxis.new(root, {
|
|
56
|
+
baseInterval: {
|
|
57
|
+
timeUnit: "minute",
|
|
58
|
+
count: 1
|
|
59
|
+
},
|
|
60
|
+
renderer: am5xy.AxisRendererX.new(root, {}),
|
|
61
|
+
tooltip: am5.Tooltip.new(root, {})
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
// add range which will show current value
|
|
66
|
+
let currentValueDataItem = valueAxis.createAxisRange(valueAxis.makeDataItem({ value: 0 }));
|
|
67
|
+
let currentLabel = currentValueDataItem.get("label");
|
|
68
|
+
if (currentLabel) {
|
|
69
|
+
currentLabel.setAll({
|
|
70
|
+
fill: am5.color(0xffffff),
|
|
71
|
+
background: am5.Rectangle.new(root, { fill: am5.color(0x000000) })
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let currentGrid = currentValueDataItem.get("grid");
|
|
76
|
+
if (currentGrid) {
|
|
77
|
+
currentGrid.setAll({ strokeOpacity: 0.5, strokeDasharray: [2, 5] });
|
|
78
|
+
}
|
|
69
79
|
|
|
70
80
|
|
|
71
81
|
// Add series
|
|
72
82
|
// -------------------------------------------------------------------------------
|
|
73
83
|
// https://www.amcharts.com/docs/v5/charts/xy-chart/series/
|
|
74
|
-
let valueSeries = mainPanel.series.push(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
84
|
+
let valueSeries = mainPanel.series.push(
|
|
85
|
+
am5xy.CandlestickSeries.new(root, {
|
|
86
|
+
name: "AMCH",
|
|
87
|
+
clustered: false,
|
|
88
|
+
valueXField: "Date",
|
|
89
|
+
valueYField: "Close",
|
|
90
|
+
highValueYField: "High",
|
|
91
|
+
lowValueYField: "Low",
|
|
92
|
+
openValueYField: "Open",
|
|
93
|
+
calculateAggregates: true,
|
|
94
|
+
xAxis: dateAxis,
|
|
95
|
+
yAxis: valueAxis,
|
|
96
|
+
legendValueText:
|
|
97
|
+
"open: [bold]{openValueY}[/] high: [bold]{highValueY}[/] low: [bold]{lowValueY}[/] close: [bold]{valueY}[/]",
|
|
98
|
+
legendRangeValueText: ""
|
|
99
|
+
})
|
|
100
|
+
);
|
|
89
101
|
|
|
90
102
|
// Set main value series
|
|
91
103
|
// -------------------------------------------------------------------------------
|
|
92
104
|
// https://www.amcharts.com/docs/v5/charts/stock-chart/#Setting_main_series
|
|
93
105
|
stockChart.set("stockSeries", valueSeries);
|
|
94
106
|
|
|
95
|
-
|
|
96
107
|
// Add a stock legend
|
|
97
108
|
// -------------------------------------------------------------------------------
|
|
98
109
|
// https://www.amcharts.com/docs/v5/charts/stock-chart/stock-legend/
|
|
99
|
-
let valueLegend = mainPanel.plotContainer.children.push(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
110
|
+
let valueLegend = mainPanel.plotContainer.children.push(
|
|
111
|
+
am5stock.StockLegend.new(root, {
|
|
112
|
+
stockChart: stockChart
|
|
113
|
+
})
|
|
114
|
+
);
|
|
103
115
|
|
|
104
116
|
// Set main series
|
|
105
117
|
// -------------------------------------------------------------------------------
|
|
106
118
|
// https://www.amcharts.com/docs/v5/charts/stock-chart/#Setting_main_series
|
|
107
119
|
valueLegend.data.setAll([valueSeries]);
|
|
108
120
|
|
|
109
|
-
|
|
110
121
|
// Add cursor(s)
|
|
111
122
|
// -------------------------------------------------------------------------------
|
|
112
123
|
// https://www.amcharts.com/docs/v5/charts/xy-chart/cursor/
|
|
113
|
-
mainPanel.set(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
mainPanel.set(
|
|
125
|
+
"cursor",
|
|
126
|
+
am5xy.XYCursor.new(root, {
|
|
127
|
+
yAxis: valueAxis,
|
|
128
|
+
xAxis: dateAxis,
|
|
129
|
+
snapToSeries: [valueSeries],
|
|
130
|
+
snapToSeriesBy: "y!"
|
|
131
|
+
})
|
|
132
|
+
);
|
|
120
133
|
|
|
121
134
|
// Add scrollbar
|
|
122
135
|
// -------------------------------------------------------------------------------
|
|
123
136
|
// https://www.amcharts.com/docs/v5/charts/xy-chart/scrollbars/
|
|
124
|
-
let scrollbar = mainPanel.set(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
137
|
+
let scrollbar = mainPanel.set(
|
|
138
|
+
"scrollbarX",
|
|
139
|
+
am5xy.XYChartScrollbar.new(root, {
|
|
140
|
+
orientation: "horizontal",
|
|
141
|
+
height: 50
|
|
142
|
+
})
|
|
143
|
+
);
|
|
128
144
|
stockChart.toolsContainer.children.push(scrollbar);
|
|
129
145
|
|
|
130
|
-
let sbDateAxis = scrollbar.chart.xAxes.push(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
let sbDateAxis = scrollbar.chart.xAxes.push(
|
|
147
|
+
am5xy.GaplessDateAxis.new(root, {
|
|
148
|
+
baseInterval: {
|
|
149
|
+
timeUnit: "minute",
|
|
150
|
+
count: 1
|
|
151
|
+
},
|
|
152
|
+
renderer: am5xy.AxisRendererX.new(root, {})
|
|
153
|
+
})
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
let sbValueAxis = scrollbar.chart.yAxes.push(
|
|
157
|
+
am5xy.ValueAxis.new(root, {
|
|
158
|
+
renderer: am5xy.AxisRendererY.new(root, {})
|
|
159
|
+
})
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
let sbSeries = scrollbar.chart.series.push(
|
|
163
|
+
am5xy.LineSeries.new(root, {
|
|
164
|
+
valueYField: "Close",
|
|
165
|
+
valueXField: "Date",
|
|
166
|
+
xAxis: sbDateAxis,
|
|
167
|
+
yAxis: sbValueAxis
|
|
168
|
+
})
|
|
169
|
+
);
|
|
148
170
|
|
|
149
171
|
sbSeries.fills.template.setAll({
|
|
150
172
|
visible: true,
|
|
@@ -162,17 +184,33 @@ seriesSwitcher.events.on("selected", function(ev) {
|
|
|
162
184
|
setSeriesType(ev.item.id);
|
|
163
185
|
});
|
|
164
186
|
|
|
165
|
-
function getNewSettings(series
|
|
166
|
-
let newSettings
|
|
167
|
-
am5.array.each(
|
|
168
|
-
|
|
169
|
-
|
|
187
|
+
function getNewSettings(series) {
|
|
188
|
+
let newSettings = [];
|
|
189
|
+
am5.array.each(
|
|
190
|
+
[
|
|
191
|
+
"name",
|
|
192
|
+
"valueYField",
|
|
193
|
+
"highValueYField",
|
|
194
|
+
"lowValueYField",
|
|
195
|
+
"openValueYField",
|
|
196
|
+
"calculateAggregates",
|
|
197
|
+
"valueXField",
|
|
198
|
+
"xAxis",
|
|
199
|
+
"yAxis",
|
|
200
|
+
"legendValueText",
|
|
201
|
+
"stroke",
|
|
202
|
+
"fill"
|
|
203
|
+
],
|
|
204
|
+
function(setting) {
|
|
205
|
+
newSettings[setting] = series.get(setting);
|
|
206
|
+
}
|
|
207
|
+
);
|
|
170
208
|
return newSettings;
|
|
171
209
|
}
|
|
172
210
|
|
|
173
|
-
function setSeriesType(seriesType
|
|
211
|
+
function setSeriesType(seriesType) {
|
|
174
212
|
// Get current series and its settings
|
|
175
|
-
let currentSeries = stockChart.get("stockSeries")
|
|
213
|
+
let currentSeries = stockChart.get("stockSeries");
|
|
176
214
|
let newSettings = getNewSettings(currentSeries);
|
|
177
215
|
|
|
178
216
|
// Remove previous series
|
|
@@ -188,9 +226,11 @@ function setSeriesType(seriesType: string) {
|
|
|
188
226
|
case "candlestick":
|
|
189
227
|
case "procandlestick":
|
|
190
228
|
newSettings.clustered = false;
|
|
191
|
-
series = mainPanel.series.push(
|
|
229
|
+
series = mainPanel.series.push(
|
|
230
|
+
am5xy.CandlestickSeries.new(root, newSettings)
|
|
231
|
+
);
|
|
192
232
|
if (seriesType == "procandlestick") {
|
|
193
|
-
series.columns.template.get("themeTags")
|
|
233
|
+
series.columns.template.get("themeTags").push("pro");
|
|
194
234
|
}
|
|
195
235
|
break;
|
|
196
236
|
case "ohlc":
|
|
@@ -260,19 +300,18 @@ setInterval(function() {
|
|
|
260
300
|
let previousDate = lastDataObject.Date;
|
|
261
301
|
let previousValue = lastDataObject.Close;
|
|
262
302
|
|
|
263
|
-
value = previousValue + (Math.random() < 0.
|
|
303
|
+
value = am5.math.round(previousValue + (Math.random() < 0.5 ? 1 : -1) * Math.random() * 2, 2);
|
|
264
304
|
|
|
265
305
|
let high = lastDataObject.High;
|
|
266
306
|
let low = lastDataObject.Low;
|
|
267
307
|
let open = lastDataObject.Open;
|
|
268
308
|
|
|
269
309
|
if (am5.time.checkChange(date, previousDate, "minute")) {
|
|
270
|
-
|
|
271
310
|
open = value;
|
|
272
311
|
high = value;
|
|
273
312
|
low = value;
|
|
274
313
|
|
|
275
|
-
let
|
|
314
|
+
let dObj1 = {
|
|
276
315
|
Date: date,
|
|
277
316
|
Close: value,
|
|
278
317
|
Open: value,
|
|
@@ -280,11 +319,10 @@ setInterval(function() {
|
|
|
280
319
|
High: value
|
|
281
320
|
};
|
|
282
321
|
|
|
283
|
-
valueSeries.data.push(
|
|
284
|
-
sbSeries.data.push(
|
|
322
|
+
valueSeries.data.push(dObj1);
|
|
323
|
+
sbSeries.data.push(dObj1);
|
|
285
324
|
previousDate = date;
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
325
|
+
} else {
|
|
288
326
|
if (value > high) {
|
|
289
327
|
high = value;
|
|
290
328
|
}
|
|
@@ -293,7 +331,7 @@ setInterval(function() {
|
|
|
293
331
|
low = value;
|
|
294
332
|
}
|
|
295
333
|
|
|
296
|
-
let
|
|
334
|
+
let dObj2 = {
|
|
297
335
|
Date: date,
|
|
298
336
|
Close: value,
|
|
299
337
|
Open: open,
|
|
@@ -301,8 +339,22 @@ setInterval(function() {
|
|
|
301
339
|
High: high
|
|
302
340
|
};
|
|
303
341
|
|
|
304
|
-
valueSeries.data.setIndex(valueSeries.data.length - 1,
|
|
305
|
-
sbSeries.data.setIndex(sbSeries.data.length - 1,
|
|
342
|
+
valueSeries.data.setIndex(valueSeries.data.length - 1, dObj2);
|
|
343
|
+
sbSeries.data.setIndex(sbSeries.data.length - 1, dObj2);
|
|
344
|
+
}
|
|
345
|
+
// update current value
|
|
346
|
+
if (currentLabel) {
|
|
347
|
+
currentValueDataItem.animate({ key: "value", to: value, duration: 500, easing: am5.ease.out(am5.ease.cubic) });
|
|
348
|
+
currentLabel.set("text", stockChart.getNumberFormatter().format(value));
|
|
349
|
+
let bg = currentLabel.get("background");
|
|
350
|
+
if (bg) {
|
|
351
|
+
if(value < open){
|
|
352
|
+
bg.set("fill", root.interfaceColors.get("negative"));
|
|
353
|
+
}
|
|
354
|
+
else{
|
|
355
|
+
bg.set("fill", root.interfaceColors.get("positive"));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
306
358
|
}
|
|
307
359
|
}
|
|
308
|
-
}, 1000)
|
|
360
|
+
}, 1000);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "amcharts5-example-xy-animated-bullet-at-the-end-of-the-series",
|
|
4
4
|
"version": "0.1.0",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@amcharts/amcharts5": "^5.2.
|
|
6
|
+
"@amcharts/amcharts5": "^5.2.5",
|
|
7
7
|
"source-map-loader": "^3.0.0",
|
|
8
8
|
"ts-loader": "^9.2.2",
|
|
9
9
|
"typescript": "^4.3.4",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "amcharts5-example-xy-comparing-series-google-analytics-style",
|
|
4
4
|
"version": "0.1.0",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@amcharts/amcharts5": "^5.2.
|
|
6
|
+
"@amcharts/amcharts5": "^5.2.5",
|
|
7
7
|
"source-map-loader": "^3.0.0",
|
|
8
8
|
"ts-loader": "^9.2.2",
|
|
9
9
|
"typescript": "^4.3.4",
|