{"id":5244,"library":"gviz-api","title":"Python API for Google Visualization","description":"gviz-api is a helper Python library for developers implementing data sources for visualizations built on the Google Visualization API. It allows for creating `DataTable` objects in Python and serializing them into JSON string, JSON response, or JavaScript string formats consumable by client-side Google Charts. The current version is 1.10.0, released in October 2021, and the project appears to be stable but not frequently updated.","status":"active","version":"1.10.0","language":"python","source_language":"en","source_url":"https://github.com/google/google-visualization-python","tags":["google-visualization","data-table","json","charting","web-api","data-source"],"install":[{"cmd":"pip install gviz-api","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The primary class for creating data tables.","symbol":"DataTable","correct":"from gviz_api import DataTable"},{"note":"Import the module directly to access its functions and classes.","symbol":"gviz_api","correct":"import gviz_api"}],"quickstart":{"code":"import gviz_api\nimport datetime\n\n# Define the schema of the table.\n# The structure is: [(id, type, optional_label), ...]\ndescription = [\n    (\"name\", \"string\", \"Meal\"),\n    (\"diet\", \"string\", \"Diet Type\"),\n    (\"calories\", \"number\", \"Calories\"),\n    (\"healthy\", \"boolean\", \"Healthy?\"),\n    (\"serving_date\", \"date\", \"Serving Date\")\n]\n\n# Load the data. Data rows must match the schema order.\ndata = [\n    (\"Breakfast\", \"vegan\", 250, True, datetime.date(2024, 4, 13)),\n    (\"Lunch\", \"vegetarian\", 400, True, datetime.date(2024, 4, 13)),\n    (\"Dinner\", \"carnivore\", 700, False, datetime.date(2024, 4, 12)),\n    (\"Snack\", \"omnivore\", 150, True, datetime.date(2024, 4, 13)),\n]\n\n# Create a DataTable object.\ndata_table = gviz_api.DataTable(description)\ndata_table.AppendData(data)\n\n# Output as JSON string (for embedding in a webpage)\njson_string = data_table.ToJSon(columns_order=(\"name\", \"diet\", \"calories\", \"healthy\", \"serving_date\"), order_by=\"calories\")\nprint(\"JSON String:\\n\", json_string)\n\n# Output as JSON response string (for a data source URL)\n# req_id is often 0 for simple requests.\njson_response = data_table.ToJSonResponse(columns_order=(\"name\", \"calories\"), order_by=\"calories\", req_id=0)\nprint(\"\\nJSON Response (for data source):\\n\", json_response)\n\n# Output as JavaScript string (for direct script injection, often for debugging)\njavascript_string = data_table.ToJS(table_id=\"myDataTable\", columns_order=(\"name\", \"calories\"), order_by=\"calories\")\nprint(\"\\nJavaScript String (for embedding):\\n\", javascript_string)\n","lang":"python","description":"This quickstart demonstrates how to define a table schema, populate it with data, and output the `DataTable` in different formats (JSON, JSON Response, JavaScript string) suitable for consumption by Google Charts."},"warnings":[{"fix":"While functional for its intended purpose, users should be aware that active feature development or frequent bug fixes may not be available. Consider community forks or alternative solutions for new requirements.","message":"The gviz-api library is stable but has not seen significant updates since its last release in October 2021. It originated as an 'automatically exported' project, indicating limited ongoing development on GitHub.","severity":"gotcha","affected_versions":"1.10.0 and earlier"},{"fix":"Ensure all data elements conform exactly to their declared Python types before appending to the `DataTable`. For example, use `int(value)` or `float(value)` explicitly for numeric conversions.","message":"The library enforces strict type checking based on the schema definition. It does not perform automatic type coercion. Providing data that does not precisely match the declared type (e.g., a string '123' for a numeric column) will raise a `TypeError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Plan your table schema carefully before initialization. If dynamic column modification or individual row deletion is needed, preprocess your data into the final desired structure before creating the `DataTable`.","message":"Once a `DataTable` object is created with a schema, the column definitions (schema) cannot be modified. Additionally, individual rows cannot be removed, though new rows can be appended, or the entire data can be overwritten.","severity":"gotcha","affected_versions":"All versions"},{"fix":"You must include the Google Charts JavaScript library in your web page and write JavaScript code to fetch the data generated by `gviz-api` and draw the desired visualization.","message":"This Python library is purely for generating data in a format compatible with the Google Visualization API. It does not provide any functionality for rendering charts or visualizations itself. Rendering must be handled by client-side JavaScript in a web browser.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'1.10.0':58 '2021':62 'allow':28 'api':2,8,26,84 'appear':66 'built':21 'chart':53,81 'client':50 'client-sid':49 'consum':47 'creat':30 'current':55 'data':17,78,86 'data-sourc':85 'data-t':77 'datat':31 'develop':15 'format':46 'frequent':72 'googl':4,24,52,75 'google-visu':74 'gviz':7 'gviz-api':6 'helper':11 'implement':16 'javascript':44 'json':39,41,80 'librari':13 'object':32 'octob':61 'project':65 'python':1,12,34 'releas':59 'respons':42 'serial':36 'side':51 'sourc':18,87 'stabl':69 'string':40,45 'tabl':79 'updat':73 'version':56 'visual':5,20,25,76 'web':83 'web-api':82","created_at":"2026-04-14T01:25:26.452481+00:00","updated_at":"2026-04-16T15:31:06.978554+00:00","problems":[{"fix":"Install the library using pip: `pip install gviz-api`. Ensure your import statement is `import gviz_api`.","cause":"The 'gviz-api' library is not installed in your Python environment or the import statement is incorrect.","error":"ModuleNotFoundError: No module named 'gviz_api'"},{"fix":"Ensure all data elements conform exactly to their declared Python types before appending to the `DataTable`. Explicitly convert values using functions like `int()`, `float()`, `str()`, or `datetime.date()` as needed.","cause":"The `gviz-api` library enforces strict type checking; data provided for a column does not precisely match its declared Python type (e.g., a string for a numeric column).","error":"TypeError: Value ... of type ... is not valid for column ... of type ..."},{"fix":"Review the `table_description` dictionary passed to the `gviz_api.DataTable` constructor, ensuring column definitions are correct and that subsequent `AppendData()` calls provide rows matching this schema.","cause":"The schema (column description) provided to `gviz_api.DataTable` is malformed, or the data being added does not conform to the defined schema.","error":"DataTableException: Error in a column description or in the description structure."},{"fix":"Check that the `gviz_api.DataTable` object and any intermediate results are correctly instantiated and populated with valid data before attempting to call methods or access attributes on them.","cause":"A method or attribute was accessed on a `gviz_api.DataTable` object (or a component derived from it) that was `None`, indicating it was not properly initialized or did not successfully process data.","error":"AttributeError: 'NoneType' object has no attribute '...'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.10.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/google/google-visualization-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/gviz-api/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["gcp","data","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-07-28","install_tag":null}}