{
    "debug": false,
    "$schema": "https://cstm.rivm.nl/regiobeeld/Regiobeeld-app-acc/schema/figure-config.schema.json",
    "identifier": "ouderenzorg_thuiswonend_uitsplitsing",
    "figure": {
        "type": "figure-highcharts-regiobeeld",
        "title": "Ouderen die thuis wonen uitgesplitst naar <%= filters.opties_ouderenzorg_uitsplitsing_thuiswonend.label.toLowerCase() %> in Nederland",
        "subtitle": "65 jaar en ouder", 
        "credits": "{appConfig.credits.CBS_Huishoudinkomen}",
        "watch": [
            "opties_ouderenzorg_uitsplitsing_thuiswonend",
            "regio_ZK"
        ],
        "settings": {
            "series": {
                "name": {"if": [{"condition": ["{opties_ouderenzorg_uitsplitsing_thuiswonend}","leeftijd"],
                        "then": "leeftijd"},
                        {"condition": ["{opties_ouderenzorg_uitsplitsing_thuiswonend}","geslacht"],
                        "then": "geslacht"}
                        ]},
                "data": [
                    {
                        "y": "percentage"
                    }
                ]
            },
            "options": {
                "chart": {
                    "type": "column"
                },
                "xAxis": {
                    "labels": {
                    "format": "\\{chart.series.0.userOptions.data.(pos).props.formatted.jaar\\}"
                    }
                },
                "yAxis": {
                    "title": {
                        "text": {"if": [{"condition": ["{opties_ouderenzorg_uitsplitsing_thuiswonend}","leeftijd"],
                        "then": "Percentage"},
                        {"condition": ["{opties_ouderenzorg_uitsplitsing_thuiswonend}","leeftijd","ne"],
                        "then": "Percentage (65+)"}]} 
                    },
                    "min": 0,
                    "max": 100,
                    "allowDecimals": true
                },
                "plotOptions": {
                    "series": {
                        "stacking": null
                    }
                }
            },
            "formatters": {}
        }
    },
    "dataset": {
        "type": "local-static-default",
        "settings": {
            "src": [
                "data/rivm/wozo_ouderenzorg_20260729/wozo_ouderenzorg_20260729--NL01.json"
            ],
            "tableGrouping": {
                "row": "jaar",
                "column": {"if": [{"condition": ["{opties_ouderenzorg_uitsplitsing_thuiswonend}","leeftijd"],
                        "then": "leeftijd"},
                        {"condition": ["{opties_ouderenzorg_uitsplitsing_thuiswonend}","geslacht"],
                        "then": "geslacht"}
                       ]},
                "minColumnCount": 2
            },
            "columns": [
                {
                    "label": "Indicator",
                    "data": "hoofdcategorie",
                    "show": false
                },
                {
                    "label": "Leeftijd",
                    "data": "leeftijd",
                    "show": {"if": [{"condition": ["{opties_ouderenzorg_uitsplitsing_thuiswonend}", "leeftijd"], "then": ["tooltip"]}]}
                },
                {
                    "label": "Geslacht",
                    "data": "geslacht",
                    "show": {"if": [{"condition": ["{opties_ouderenzorg_uitsplitsing_thuiswonend}", "geslacht"], "then": ["tooltip"]}]}
                },
                {
                    "label": "Geo_id",
                    "data": "geo_id",
                    "show": false
                },
                {
                    "label": "Regio",
                    "data": "regio",
                    "show": false
                },
                {
                    "label": "Jaar",
                    "data": "jaar",
                    "show": true
                },
                {
                    "label": "Percentage",
                    "data": "percentage",
                    "show": true,
                    "numberFormat": 0,
                    "suffix": "%",
                    "align": "right"
                }
            ],
            "select": [
                [
                    "geo_id"
                ],
                [
                    "jaar"
                ],
                [
                    "hoofdcategorie"
                ],
                [
                    "leeftijd"
                ],
                [
                    "geslacht"
                ],
                [
                    "percentage"
                ],
                [
                    "regio"
                ]
            ],
            "where": {
                "and": [
                    ["percentage", null, "ne"],
                    {
                    "if": [
                        {
                        "condition": ["{opties_ouderenzorg_uitsplitsing_thuiswonend}", "geslacht"],
                        "then": {
                            "and": [
                            ["hoofdcategorie", "Ouderen die thuis wonen"],
                            ["geslacht", "Totaal mannen en vrouwen", "ne"]
                            ]
                        }
                        },
                        {
                        "condition": ["{opties_ouderenzorg_uitsplitsing_thuiswonend}", "leeftijd"],
                        "then": {
                            "and": [
                            ["hoofdcategorie", "Ouderen die thuis wonen"],
                            ["leeftijd", "Totaal leeftijd", "ne"]
                            ]
                        }
                        }
                    ]
                    }
                ]
                },
            "join": [
                {
                    "dataset": {
                        "type": "local-static-default",
                        "settings": {
                            "src": [
                                "data/regio/ref_gem_regio_gem2023_20240507/ref_gem_regio_gem2023_20240507--NL01.json"
                            ],
                            "select": [
                                [
                                    "geo_nm",
                                    "regio"
                                ]
                            ]
                        }
                    },
                    "on": [
                        "geo_id",
                        "geo_id"
                    ]
                }
            ], "order": ["order"]
        }
    },
    "filters": [
        {
            "identifier": "opties_ouderenzorg_uitsplitsing_thuiswonend",
            "type": "filter-default",
            "settings": {
                "label": "Selecteer een uitsplitsing:",
                "defaultValue": "leeftijd",     
                "dataset": {
                    "type": "local-static-default",
                    "settings": {
                        "src": ["data/filterOpties/filteropties_ouderenzorg_uitsplitsingen_20260729.json"],
                        "where": {
                            "or": [
                                ["value", "leeftijd"],
                                ["value", "geslacht"]
                            ]
                        }
                    }
                }
            }
        }
    ]
}