qingshan007 commented on issue #29710:
URL: https://github.com/apache/superset/issues/29710#issuecomment-2572222006
**Problem Investigation:**
After investigation, it was found that the rendering type was incorrect
Create a chart type that is always table
datasource type: table
On the chart construction page, switch datasets (virtual or physical):
datasource type: virtual
datasource type: physical
Without modifying or destroying the original logic of the newly created
dataset:
Locate to:
superset-frontend\src\explore\components\controls\DatasourceControl\index.jsx
1. Add judgment logic, where the physical dataset SQL field is always='',
and the virtual one is the SQL during construction:
````
const dynamicDatasourceType = datasource?.sql
? DatasourceType.Query
: DatasourceType.Table;
````
2. Use a new judgment:
```
{/* {datasourceIconLookup[datasource?.type]} */}
↓
{datasourceIconLookup[dynamicDatasourceType]}
```
3. Modify the icon:
```
// Assign icon for each DatasourceType. If no icon assingment is found in
the lookup, no icon will render
// export const datasourceIconLookup = {
// [DatasourceType.Query]: (
// <Icons. ConsoleSqlOutlined className="datasource-svg" />
// ),
// [DatasourceType.Table]: <Icons.DatasetPhysical
className="datasource-svg" />,
// };
↓
export const datasourceIconLookup = {
[DatasourceType.Query]: <Icons.DatasetVirtual className="datasource-svg" />,
[DatasourceType.Table]: <Icons.DatasetPhysical className="datasource-svg" />,
};
```
4. Result:
Switch datasets and display icons of corresponding types
Create a regular chart OR by entering it from the dataset page and
displaying the corresponding type of icon
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]