{"record":{"id":"a1084e29ed415673","repo":"OpenBB-finance/OpenBB","slug":"failed-to-automatically-create-a-generic-chart-wit-a1084e","errorCode":null,"errorMessage":"Failed to automatically create a generic chart with the data provided.","messagePattern":"Failed to automatically create a generic chart with the data provided\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"openbb_platform/obbject_extensions/charting/openbb_charting/charting.py","lineNumber":658,"sourceCode":"        kwargs[\"provider\"] = self._obbject.provider  # pylint: disable=protected-access\n        kwargs[\"extra\"] = self._obbject.extra  # pylint: disable=protected-access\n        try:\n            if has_data:\n                self.show(data=data_as_df, render=render, **kwargs)\n            else:\n                self.show(**kwargs, render=render)\n        except Exception:  # pylint: disable=W0718\n            try:\n                fig = self.create_line_chart(data=data_as_df, render=False, **kwargs)\n                fig = self._set_chart_style(fig)  # type: ignore\n                content = fig.show(external=True, **kwargs).to_plotly_json()  # type: ignore\n                self._obbject.chart = Chart(\n                    fig=fig, content=content, format=self._format\n                )\n                if render:\n                    return fig.show(**kwargs)  # type: ignore\n            except Exception as e:  # pylint: disable=W0718\n                raise RuntimeError(\n                    \"Failed to automatically create a generic chart with the data provided.\"\n                ) from e\n\n    def _set_chart_style(self, figure: \"Figure\"):\n        \"\"\"Set the user preference for light or dark mode.\"\"\"\n        return figure\n\n    def toggle_chart_style(self):\n        \"\"\"Toggle the chart style between light and dark mode.\"\"\"\n        import plotly.io as pio  # pylint: disable=import-outside-toplevel\n\n        if not hasattr(self._obbject.chart, \"fig\"):\n            raise ValueError(\n                \"Error: No chart has been created. Please create a chart first.\"\n            )\n        current = self._charting_settings.chart_style\n        new = \"light\" if current == \"dark\" else \"dark\"\n        self._charting_settings.chart_style = new","sourceCodeStart":640,"sourceCodeEnd":676,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/obbject_extensions/charting/openbb_charting/charting.py#L640-L676","documentation":"The sibling auto-chart fallback in Charting.to_chart: after the specific chart path fails, it tries create_line_chart on the converted DataFrame; if that also raises, the exception is chained into this RuntimeError. The underlying exception is available via __cause__ (unlike error 170 it is not embedded in the message), so 'raise ... from e' preserves the real reason.","triggerScenarios":"Calling obbject.charting.to_chart() with data that converts to an empty or fully non-numeric DataFrame; passing data kwarg of unsupported type (nested dicts, scalar) that breaks basemodel_to_df; specific chart view failed and generic line chart cannot handle the shape.","commonSituations":"Non-tabular API results auto-charted; None/NaN-only frames after dropna; custom data structures passed as data kwarg.","solutions":["Inspect exc.__cause__ to get the real underlying error","Pre-convert data to a clean numeric DataFrame and call create_line_chart or to_chart(data=df) directly","Check data is not empty and has at least one numeric column before charting"],"exampleFix":"# before\nobj.charting.to_chart(data=weird_nested_dict)\n\n# after\ndf = pd.DataFrame(weird_nested_dict['rows'])\nobj.charting.to_chart(data=df)","handlingStrategy":"try-catch","validationCode":"df = convert_to_basemodel(data)\nassert df is not None and not df.empty, 'cannot build generic chart from empty data'","typeGuard":null,"tryCatchPattern":"try:\n    obj.charting.to_chart(data=data)\nexcept RuntimeError as e:\n    root = e.__cause__  # real underlying exception\n    logging.error('to_chart failed: %s', root)","preventionTips":["Inspect __cause__ of the RuntimeError for the true failure","Pre-clean data into a numeric DataFrame","Ensure at least one numeric column before generic charting"],"tags":["openbb","charting","to-chart","fallback-failure"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}