db id: 84139ed7e0244e3fbc862a225f279a71

dataQuery: 860548f3d7354715bdf10ca7f1206732

config id: 8d9e83eddc4d46dd8a6b2df33e04a94e

https://api.notion-charts.app/embedded/chart/8d9e83eddc4d46dd8a6b2df33e04a94e?token=77a4eaf3-9d97-4b41-b985-b5d7af43abec

localhost:3000/embedded/chart/8d9e83eddc4d46dd8a6b2df33e04a94e?token=77a4eaf3-9d97-4b41-b985-b5d7af43abec

https://api.notion-charts.app/embedded/chart/8d9e83eddc4d46dd8a6b2df33e04a94e?token=77a4eaf3-9d97-4b41-b985-b5d7af43abec

{
	"database": {
		"id":"84139ed7e0244e3fbc862a225f279a71"
	},
	"chart": {
		"title": {
			"show": true,
			"text": "Documentation progress",
			"left": "center"
		},
		"dataset": {
			"source": []
		},
		"xAxis": {
			"type": "category",
			"splitLine": {
				"show": false
			}
		},
		"yAxis": {
			"type": "value"
		},
		"series": [
			{
				"name": "Padding",
				"type": "bar",
				"stack": "Total",
				"itemStyle": {
					"borderColor": "transparent",
					"color": "transparent"
				},
				"emphasis": {
					"itemStyle": {
						"borderColor": "transparent",
						"color": "transparent"
					}
				},
				"encode": {
					"y": "padding"
				}
			},
			{
				"name": "Progress",
				"stack": "Total",
				"type": "bar",
				"encode": {
					"y": "value"
				},
				"label": {
					"show": true,
					"position": "inside"
				}
			}
		]
	},
	"data_query": {
		"id": "860548f3d7354715bdf10ca7f1206732"
	}
}
	
SELECT 
	'Total' as "label",
	count(*) as "value",
	0 as "padding"
FROM :database
WHERE "Status" IS NOT NULL
GROUP BY "label", "padding"
UNION
( SELECT
	a.*,
	b.total - (sum(a."value") OVER (ORDER BY a."value" DESC)) as "padding"
	FROM (
		SELECT
			DISTINCT "Status" as "label",
			count(*) as "value"
		FROM :database 
		WHERE "Status" IS NOT NULL
		GROUP BY "label"
	) a
	LEFT JOIN (
			SELECT 
				count(*) as "total" 
			FROM :database
			WHERE "Status" IS NOT NULL
	) b on 1=1
	ORDER BY "value" DESC )
ORDER BY "value" DESC ;