Closed FamousMai closed 2 months ago
The issue you're encountering seems to be related to the handling and rendering of ECharts JavaScript code within the Dify application. When the application attempts to process the provided ECharts code, it crashes, leading to a client-side exception.
Complex ECharts Configuration:
Error Handling and Validation:
Sanitization of User-Generated Code:
Add Error Boundaries:
Validate ECharts Configuration:
Log and Debug:
Update Dependencies:
echarts
and echarts-for-react
, are up to date to benefit from the latest bug fixes and improvements.By implementing these measures, you can improve the stability and performance of the Dify application when handling complex ECharts configurations.
To continue talking to Dosu, mention @dosu.
@zhujinle Can you take a look at this issue?
We have not registered the json information of China map to the system. You need to modify the code to register the China map. See ECharts Doc
The code attempts to access an undefined object that references an unregistered map, causing the program to crash.
And because of the problem of session cache, another rendering was performed when refreshing, which led to a new crash.
The best way at present is to delete cookies from the browser side, thereby disconnecting the link with the session history and preventing the application from rendering again.
ECharts has too many customizable items and there are too many maps that can be imported, I don’t have a very good way to solve the problem of map import. It seems that I can only disable geo syntax or limit chart types?
Will the system add support for Chinese maps by default in the future?
Can you add a judgment for unregistered maps? Otherwise, the content returned by the big model contains unregistered map json data, and it can't just crash.
Will the system add support for Chinese maps by default in the future?
Can you add a judgment for unregistered maps? Otherwise, the content returned by the big model contains unregistered map json data, and it can't just crash.
As mentioned above, I think ECharts has too many customizable items, and dify is not a project limited to China. Some of the default maps introduced manually may not be comprehensive enough to meet everyone's needs. This will still lead to this problem, and it may also cause too many registrations and affect system loading.
If you have a better on-demand registrations method, welcome to discuss or submit a PR
For the second issue, ECharts will handle numerical errors by itself during testing. I thought it would be the same for other issues, without considering maps and other situations😥. I will open a new PR to add an error boundary.
怎样才能百分百的输出echarts图表
Self Checks
Dify version
0.7.1
Cloud or Self Hosted
Cloud
Steps to reproduce
When I use the prompt 'Use ECharts to draw an example: Display pie charts on a map' to generate a chart with a large language model, it produces ECharts JavaScript code similar to the example below. This causes the application to immediately crash. Moreover, every time I click to enter the application, it crashes instantly, rendering the application completely unusable.
The second scenario that triggers this bug is when the aforementioned ECharts code is directly sent to the application, which also causes an immediate crash.