You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "villebro (via GitHub)" <gi...@apache.org> on 2023/06/23 06:50:32 UTC

[GitHub] [superset] villebro commented on a diff in pull request #24492: fix(charts): big-number display broken in echarts

villebro commented on code in PR #24492:
URL: https://github.com/apache/superset/pull/24492#discussion_r1239383575


##########
superset-frontend/plugins/plugin-chart-echarts/src/types.ts:
##########
@@ -168,4 +171,21 @@ export interface TreePathInfo {
   value: number | number[];
 }
 
+export class EchartsChartPlugin<
+  T extends SqlaFormData = SqlaFormData,
+  P extends ChartProps = ChartProps,
+> extends ChartPlugin<T, P> {
+  constructor(props: any) {
+    const { metadata } = props;
+    const mergedProps = {
+      ...props,
+      metadata: new ChartMetadata({
+        parseMethod: 'json',
+        ...metadata,
+      }),
+    };
+    super(mergedProps);

Review Comment:
   nit: Maybe we don't need to create the intermediate `mergedProps`, but could just inline it in `super()`



##########
superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/index.test.ts:
##########
@@ -0,0 +1,28 @@
+/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License.  You may obtain a copy of the License at
++ *
++ *   http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing,
++ * software distributed under the License is distributed on an
++ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
++ * KIND, either express or implied.  See the License for the
++ * specific language governing permissions and limitations
++ * under the License.
++ */
+import { EchartsTimeseriesChartPlugin } from '@superset-ui/plugin-chart-echarts';
+
+describe('@superset-ui/plugin-chart-echarts', () => {
+  it('exists', () => {
+    const chart = new EchartsTimeseriesChartPlugin().configure({
+      key: 'echarts_timeseries',
+    });
+    expect(chart.metadata.parseMethod).toEqual('json');
+  });
+});

Review Comment:
   Looking at the test suite, maybe we could simplify and make this more comprehensive by moving this test into `test/index.test.ts` and have a section there that ensures `parseMethod` is correctly defined for all plugins.
   
   Bycatch: I also noticed that the `exists` test there doesn't cover all plugins. While you're at it, can you add the missing plugins, too?



##########
superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/index.test.ts:
##########
@@ -0,0 +1,28 @@
+/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License.  You may obtain a copy of the License at
++ *
++ *   http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing,
++ * software distributed under the License is distributed on an
++ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
++ * KIND, either express or implied.  See the License for the
++ * specific language governing permissions and limitations
++ * under the License.
++ */
+import { EchartsTimeseriesChartPlugin } from '@superset-ui/plugin-chart-echarts';
+
+describe('@superset-ui/plugin-chart-echarts', () => {
+  it('exists', () => {

Review Comment:
   nit: let's replace `describe` and `it` with just `test` blocks.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org