{"record":{"id":"5f84f18cd88958b7","repo":"OpenBB-finance/OpenBB","slug":"no-data-to-plot","errorCode":null,"errorMessage":"No data to plot.","messagePattern":"No data to plot\\.","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"warning","filePath":"openbb_platform/providers/imf/openbb_imf/views/maritime_chokepoint_info.py","lineNumber":34,"sourceCode":"        from openbb_charting.core.openbb_figure import OpenBBFigure\n        from plotly import graph_objects as go\n        from plotly.subplots import make_subplots\n    except Exception as e:\n        raise OpenBBError(\n            \"Could not import Charting modules. Install with `pip install openbb-charting`.\"\n            + f\" -> {e}\"\n        ) from e\n\n    if (\n        data is not None\n        and not isinstance(data, list)\n        or not all(isinstance(item, ImfMaritimeChokePointInfoData) for item in data)\n    ):\n        raise OpenBBError(\n            \"Invalid data format. Expected a list of ImfMaritimeChokePointInfoData.\"\n        )\n    if len(data) == 0:\n        raise OpenBBError(\"No data to plot.\")\n\n    df = DataFrame([item.model_dump() for item in data])\n    if theme == \"dark\":\n        geo_bgcolor = \"rgba(0,0,0,0)\"\n        landcolor = \"#3a5d3a\"\n        countrycolor = \"#cccccc\"\n        oceancolor = \"#223355\"\n        coastlinecolor = \"#cccccc\"\n        lakecolor = \"#0d47a1\"\n        rivercolor = \"#0d47a1\"\n        table_header_fill = \"#222e3c\"\n        table_header_font = \"#fff\"\n        table_cell_fill = [\"#232323\", \"#181818\"] * (len(df) // 2 + 1)\n        font_color = \"#fff\"\n        annotation_color = \"#aaa\"\n        plot_bgcolor = \"rgba(21,21,21,1)\"\n        paper_bgcolor = \"rgba(21,21,21,1)\"\n    else:","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/imf/openbb_imf/views/maritime_chokepoint_info.py#L16-L52","documentation":"Simple emptiness check in the maritime chokepoint chart view: before building the DataFrame, it requires a non-empty input list. Empty input means there is nothing to map or tabulate, and plotting would produce a broken figure, so it fails fast. Note data=None would raise TypeError at len() rather than this error.","triggerScenarios":"Calling plot_maritime_chokepoint_info([]) - typically because the upstream fetch returned no rows (e.g. a date filter with no matching chokepoint observations) and the caller forwarded the empty result straight to the chart view.","commonSituations":"Date ranges outside available data; filters (country/chokepoint) matching nothing; upstream EmptyDataError being swallowed and replaced with an empty list before plotting.","solutions":["Check the fetch result is non-empty before invoking the chart view.","Broaden or correct query filters (dates, chokepoint selection) so the fetch returns rows.","Handle upstream EmptyDataError explicitly rather than coercing to an empty list."],"exampleFix":"# before\nresult = obb.economy.imf.maritime_chokepoint(...).results\nplot_maritime_chokepoint_info(result)  # may raise 'No data to plot.'\n# after\nif not result:\n    print('No chokepoint data for the given filters')\nelse:\n    plot_maritime_chokepoint_info(result)","handlingStrategy":"validation","validationCode":"if not data:\n    raise SystemExit('No maritime chokepoint data for the given filters')\nplot_maritime_chokepoint_info(data)","typeGuard":"def has_rows(data: list | None) -> bool:\n    return bool(data)","tryCatchPattern":"from openbb_core.app.model.abstract.error import OpenBBError\ntry:\n    plot_maritime_chokepoint_info(data)\nexcept OpenBBError as e:\n    if str(e) == 'No data to plot.':\n        show_empty_state()  # expected when filters match nothing\n    else:\n        raise","preventionTips":["Check fetch results for emptiness before charting","Broaden date/chokepoint filters when empty","Handle upstream EmptyDataError explicitly rather than coercing to []"],"tags":["imf","empty-data","charting","openbberror"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}