This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch fix/useUTC
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git

commit 556c4882b57d7355269d0dbfc8d270d1afe1fc8f
Author: 100pah <sushuang0...@gmail.com>
AuthorDate: Mon Nov 9 02:43:49 2020 +0800

    fix: comment incorrect implementation of tooltip.formatter: pattern on time 
axis temporarily
---
 src/util/format.ts | 48 +++++++++++++++++++++++++++---------------------
 1 file changed, 27 insertions(+), 21 deletions(-)

diff --git a/src/util/format.ts b/src/util/format.ts
index 049ffb5..1f59a74 100644
--- a/src/util/format.ts
+++ b/src/util/format.ts
@@ -79,7 +79,7 @@ export function encodeHTML(source: string): string {
  */
 export function makeValueReadable(
     value: unknown,
-    valueType?: DimensionType
+    valueType: DimensionType
 ): string {
     const USER_READABLE_DEFUALT_TIME_PATTERN = 'yyyy-MM-dd hh:mm:ss';
 
@@ -95,7 +95,6 @@ export function makeValueReadable(
     if (isTypeTime || isValueDate) {
         const date = isTypeTime ? parseDate(value) : value;
         if (!isNaN(+date)) {
-            // PENDING: add param `useUTC`?
             return timeFormat(date, USER_READABLE_DEFUALT_TIME_PATTERN);
         }
         else if (isValueDate) {
@@ -148,28 +147,35 @@ export function formatTpl(
         return '';
     }
 
-    const isTimeAxis = paramsList[0].axisType && 
paramsList[0].axisType.indexOf('time') >= 0;
-    if (isTimeAxis) {
-        const axisValue = paramsList[0].data[paramsList[0].axisIndex];
-        const date = parseDate(axisValue);
-        return timeFormat(date, tpl);
+    // TODO:
+    // This commented code is to support `tooltip.formatter: 
'{yyyy}-{mm}-{dd}'`, but not correct.
+    // It should ensure:
+    // (1) `useUTC` is not forgotten to be set as `true` or `false`.
+    //     The result based on useUTC are totally different, which should not 
be omitted.
+    // (2) Should not break the original funtion: tooltip.formatter: '{a0} 
{a1}'
+    // (3) Consider `series.encode: {x: 2}`, that is, `param.data[2]` is time 
axis value.
+    // const isTimeAxis = paramsList[0].axisType && 
paramsList[0].axisType.indexOf('time') >= 0;
+    // if (isTimeAxis) {
+    //     const axisValue = paramsList[0].data[paramsList[0].axisIndex];
+    //     const date = parseDate(axisValue);
+    //     return timeFormat(date, tpl);
+    // }
+
+    const $vars = paramsList[0].$vars || [];
+    for (let i = 0; i < $vars.length; i++) {
+        const alias = TPL_VAR_ALIAS[i];
+        tpl = tpl.replace(wrapVar(alias), wrapVar(alias, 0));
     }
-    else {
-        const $vars = paramsList[0].$vars || [];
-        for (let i = 0; i < $vars.length; i++) {
-            const alias = TPL_VAR_ALIAS[i];
-            tpl = tpl.replace(wrapVar(alias), wrapVar(alias, 0));
-        }
-        for (let seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) {
-            for (let k = 0; k < $vars.length; k++) {
-                const val = paramsList[seriesIdx][$vars[k]];
-                tpl = tpl.replace(
-                    wrapVar(TPL_VAR_ALIAS[k], seriesIdx),
-                    encode ? encodeHTML(val) : val
-                );
-            }
+    for (let seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) {
+        for (let k = 0; k < $vars.length; k++) {
+            const val = paramsList[seriesIdx][$vars[k]];
+            tpl = tpl.replace(
+                wrapVar(TPL_VAR_ALIAS[k], seriesIdx),
+                encode ? encodeHTML(val) : val
+            );
         }
     }
+
     return tpl;
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org
For additional commands, e-mail: commits-h...@echarts.apache.org

Reply via email to