|
|
@@ -113,6 +113,26 @@ export function useCandlestickChart(goodscode: string) {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 格式化日期
|
|
|
+ * @param value
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+ const formatDate = (value: string) => {
|
|
|
+ switch (options.cycleType) {
|
|
|
+ case ChartCycleType.Day: {
|
|
|
+ return moment(value).format('YYYY-MM-DD')
|
|
|
+ }
|
|
|
+ case ChartCycleType.Hours2:
|
|
|
+ case ChartCycleType.Hours4: {
|
|
|
+ return moment(value).format('YYYY-MM-DD HH:00:00')
|
|
|
+ }
|
|
|
+ default: {
|
|
|
+ return moment(value).format('YYYY-MM-DD HH:mm:00')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 更新图表数据
|
|
|
*/
|
|
|
const updateChart = () => {
|
|
|
@@ -147,21 +167,7 @@ export function useCandlestickChart(goodscode: string) {
|
|
|
// } else {
|
|
|
// 判断时间差是否大于周期时间
|
|
|
if (lastIndex === -1 || diffTime > cycleMilliseconds) {
|
|
|
- const newtime = (() => {
|
|
|
- switch (options.cycleType) {
|
|
|
- case ChartCycleType.Day: {
|
|
|
- return moment(lasttime).format('YYYY-MM-DD')
|
|
|
- }
|
|
|
- case ChartCycleType.Hours2:
|
|
|
- case ChartCycleType.Hours4: {
|
|
|
- return moment(lasttime).format('YYYY-MM-DD HH:00:00')
|
|
|
- }
|
|
|
- default: {
|
|
|
- return moment(lasttime).format('YYYY-MM-DD HH:mm:00')
|
|
|
- }
|
|
|
- }
|
|
|
- })()
|
|
|
-
|
|
|
+ const newtime = formatDate(lasttime)
|
|
|
// 新增K线数据
|
|
|
candlestick.source.push({
|
|
|
date: newtime,
|