{"record":{"id":"763b6508832176b2","repo":"apache/echarts","slug":"data-view-format-error","errorCode":null,"errorMessage":"Data view format error {}","messagePattern":"Data view format error (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/component/toolbox/feature/DataView.ts","lineNumber":420,"sourceCode":"                    // eslint-disable-next-line\n                    warn('It seems you have just provided one of `contentToOption` and `optionToContent` functions but missed the other one. Data change is ignored.')\n                }\n                close();\n                return;\n            }\n\n            let newOption;\n            try {\n                if (zrUtil.isFunction(contentToOption)) {\n                    newOption = contentToOption(viewMain, api.getOption());\n                }\n                else {\n                    newOption = parseContents(textarea.value, blockMetaList);\n                }\n            }\n            catch (e) {\n                close();\n                throw new Error('Data view format error ' + e);\n            }\n            if (newOption) {\n                api.dispatchAction({\n                    type: 'changeDataView',\n                    newOption: newOption\n                });\n            }\n\n            close();\n        });\n\n        closeButton.innerHTML = lang[1];\n        refreshButton.innerHTML = lang[2];\n        refreshButton.style.cssText =\n        closeButton.style.cssText = buttonStyle;\n\n        !model.get('readOnly') && buttonContainer.appendChild(refreshButton);\n        buttonContainer.appendChild(closeButton);","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/apache/echarts/blob/30076aedcd7b7f65d8dd8e8d9ece46ce778133a3/src/component/toolbox/feature/DataView.ts#L402-L438","documentation":"Runtime (NOT dev-only) error in the toolbox DataView feature: when an end user edits data in the DataView textarea and clicks save, the text is parsed back into an option (via parseContents or a custom contentToOption). If parsing throws, the original error is wrapped and re-thrown as 'Data view format error'. Fires in production.","triggerScenarios":"End user types malformed text into the DataView textarea (invalid array/row syntax) and triggers the save/refresh action; a custom contentToOption throws.","commonSituations":"Manual data editing in the data view tool; pasting broken/tab-misaligned data; a custom contentToOption returning invalid output.","solutions":["Correct the textarea content to the format expected by parseContents (rows of name + tab + value, or valid option structure)","Provide a robust contentToOption function that sanitizes input","Document the expected data format for end users"],"exampleFix":"// before: user pastes malformed rows in the DataView textarea\n\n// after: provide a lenient custom parser\ntoolbox: { feature: { dataView: {\n  contentToOption: (view, opt) => safeParse(view.querySelector('textarea').value)\n} } }","handlingStrategy":"try-catch","validationCode":"// provide a robust custom contentToOption so end-user input cannot throw\ntoolbox: { feature: { dataView: {\n  contentToOption: (view, opt) => {\n    try { return safeParse(view.querySelector('textarea').value); }\n    catch { return null; }\n  }\n} } }","typeGuard":null,"tryCatchPattern":"try {\n  chart.setOption(optionWith DataView);\n} catch (e) {\n  if (/Data view format/.test((e as Error).message)) {\n    alert('Please fix the data format in the DataView editor');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Provide a lenient contentToOption to sanitize end-user input","Document the expected data format to end users","Validate textarea contents before triggering refresh"],"tags":["toolbox","data-view","runtime","user-input"],"backgroundTag":null,"analyzedSha":"30076aedcd7b7f65d8dd8e8d9ece46ce778133a3","analyzedAt":"2026-08-12T12:42:28.134Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}