فهرست منبع

Fix: Table Panel and string values & numeric formatting (#16249)

Šimon Podlipský 6 سال پیش
والد
کامیت
00a07c855d
2فایلهای تغییر یافته به همراه7 افزوده شده و 2 حذف شده
  1. 1 1
      public/app/plugins/panel/table/renderer.ts
  2. 6 1
      public/app/plugins/panel/table/specs/renderer.test.ts

+ 1 - 1
public/app/plugins/panel/table/renderer.ts

@@ -177,7 +177,7 @@ export class TableRenderer {
           return '-';
         }
 
-        if (_.isString(v) || _.isArray(v)) {
+        if (isNaN(v) || _.isArray(v)) {
           return this.defaultCellFormatter(v, column.style);
         }
 

+ 6 - 1
public/app/plugins/panel/table/specs/renderer.test.ts

@@ -224,7 +224,12 @@ describe('when rendering table', () => {
       expect(html).toBe('<td>1.230 s</td>');
     });
 
-    it('number style should ignore string values', () => {
+    it('number column should format numeric string values', () => {
+      const html = renderer.renderCell(1, 0, '1230');
+      expect(html).toBe('<td>1.230 s</td>');
+    });
+
+    it('number style should ignore string non-numeric values', () => {
       const html = renderer.renderCell(1, 0, 'asd');
       expect(html).toBe('<td>asd</td>');
     });