An interactive Shiny for Python web app for visualizing China's national climate policy targets — developed by the Macro and Green Finance Lab at Peking University (MGF@PKU).
This tool is designed as a template for research, presentation, and educational purposes. It is not intended for local hosting by the general public — instead, it showcases how one might integrate real-time GitHub-hosted datasets into a Shiny app.
This app visualizes a curated dataset of China's national climate policy targets across sectors such as GHG Emissions, Energy/Power, Buildings, Transport, LULUCF, Circular Economy, Pollution, and Finance. Features include:
- 📅 Bar chart showing climate target announcements by year
- 🏷️ Bar chart showing climate targets by category
Powered by:
shinyfor interactivityplotlyfor interactive chartspolarsfor fast data wrangling- GitHub API for real-time data retrieval
- Two interactive Plotly bar charts (by announcement year and by target category)
- Integrated GitHub data sync (fetches latest release from
MGFPKU/target_dataset) - Bilingual UI (Chinese / English, controlled by
LANGUAGEenv var)
This app uses GitHub as a remote data backend. If you're customizing or extending the app:
git clone https://github.com/MGFPKU/target_visualization.git
cd target_visualizationWe use uv for fast dependency resolution:
uv sync
⚠️ We do not publish a GitHub token in this repo. If you need access for development or testing, contact the maintainers for a personal access token (PAT) with read-only access to the dataset repository.
You'll need to set the token in a .env file like:
GITHUB_TOKEN=ghp_...
LANGUAGE=ENBelow is what each variable does:
GITHUB_TOKEN: a GitHub Personal Access Token (PAT) with read access to theMGFPKU/target_datasetrepository. The app uses this token to downloaddataset.xlsxfrom the latest release. Keep this token private (do not commit it).LANGUAGE: set the UI language for the app. UseENfor English orCNfor Chinese. The value controls which translations are displayed in the interface.
python -m shiny run --reload app.pyThen open your browser to:
http://localhost:8000Or more conveniently, install the shiny extension to Positron/VS Code and press the Run button.
The repository layout and purpose of key files:
.env # Environment variables (not committed, create locally following setup instructions)
app.py # Main Shiny app (UI + server, renders Plotly charts)
data.py # Data fetching and processing logic
i18n.py # Translation helper; reads LANGUAGE to switch UI
translation.json # Translation strings used by `i18n.py`
sheets.json # Sheet names and source sheet config for dataset.xlsx
pyproject.toml # Project metadata / build config (managed by uv)
.python-version # Python version pinning for uv
requirements.txt # Dependency pins (optional with pyproject)
LICENSE # License
README.md # Project documentation (this file)
.gitignore # Git ignore rules
Notes:
- Edit
app.pyto change high-level UI or chart logic. data.pyhandles fetching and parsingdataset.xlsxfrom the latest GitHub release.
If you use the MGF dataset in your research or writing, please cite us as follows:
Macro and Green Finance Lab, Peking University (MGF@PKU)
"China's National Climate Targets Database"
https://mgflab.nsd.pku.edu.cn/MGFsjk/zczz/index.htm, 2025.
The dataset is hosted in a private GitHub repository (MGFPKU/target_dataset) along with our data collection scripts. We apologize for the inconvenience. But the dataset provided through the app is updated in real-time and contains most information available on the original source.
Developed by Dianyi Yang (@kv9898) for the Macro and Green Finance Lab at Peking University (MGF@PKU).
If you use or adapt this project for academic or institutional purposes, please cite the dataset accordingly and feel free to reach out for collaboration or inquiries.