{"spec_id":"bubble-map-geographic","library":"muix","language":"javascript","code":"// anyplot.ai\n// bubble-map-geographic: Bubble Map with Sized Geographic Markers\n// Library: muix 9.17.0 | JavaScript 22.23.4\n// Quality: 88/100 | Updated: 2026-11-08\nimport { ChartsDataProvider } from \"@mui/x-charts/ChartsDataProvider\";\nimport { ChartsWrapper } from \"@mui/x-charts/ChartsWrapper\";\nimport { ChartsSurface } from \"@mui/x-charts/ChartsSurface\";\nimport { ChartsLegend } from \"@mui/x-charts/ChartsLegend\";\nimport { ChartsGrid } from \"@mui/x-charts/ChartsGrid\";\nimport { ChartsXAxis } from \"@mui/x-charts/ChartsXAxis\";\nimport { ChartsYAxis } from \"@mui/x-charts/ChartsYAxis\";\nimport { ChartsTooltip } from \"@mui/x-charts/ChartsTooltip\";\nimport { ScatterPlot } from \"@mui/x-charts/ScatterChart\";\nimport { useXScale, useYScale, useDrawingArea } from \"@mui/x-charts/hooks\";\n\nconst t = window.ANYPLOT_TOKENS;\n\n// Constants\nconst MIN_RADIUS = 9; // px floor so the smallest values stay visible\nconst MAX_RADIUS = 46; // px radius of the largest value\nconst PAD_SHARE = 0.1; // map padding as a share of the data's longitude and latitude span\nconst BUBBLE_OPACITY = 0.6;\n\n// Columns: set these to your data's column names\nconst CITY = \"City\"; // role: label\nconst LAT = \"Latitude\"; // role: latitude\nconst LON = \"Longitude\"; // role: longitude\nconst POPULATION = \"Metro population (millions)\"; // role: value\nconst REGION = \"World region\"; // role: category\n\n// Data: replace this block with your own records, one object per row\n// Approximate 2023 metro-area population of 20 major world cities.\nconst data = [\n  { [CITY]: \"Tokyo\", [LON]: 139.7, [LAT]: 35.7, [POPULATION]: 37.4, [REGION]: \"Asia-Pacific\" },\n  { [CITY]: \"Delhi\", [LON]: 77.2, [LAT]: 28.6, [POPULATION]: 32.9, [REGION]: \"Asia-Pacific\" },\n  { [CITY]: \"Shanghai\", [LON]: 121.5, [LAT]: 31.2, [POPULATION]: 29.2, [REGION]: \"Asia-Pacific\" },\n  { [CITY]: \"Jakarta\", [LON]: 106.8, [LAT]: -6.2, [POPULATION]: 33.4, [REGION]: \"Asia-Pacific\" },\n  { [CITY]: \"Sydney\", [LON]: 151.2, [LAT]: -33.9, [POPULATION]: 5.3, [REGION]: \"Asia-Pacific\" },\n  { [CITY]: \"Moscow\", [LON]: 37.6, [LAT]: 55.8, [POPULATION]: 12.6, [REGION]: \"Europe\" },\n  { [CITY]: \"Istanbul\", [LON]: 29.0, [LAT]: 41.0, [POPULATION]: 15.5, [REGION]: \"Europe\" },\n  { [CITY]: \"Paris\", [LON]: 2.35, [LAT]: 48.85, [POPULATION]: 11.1, [REGION]: \"Europe\" },\n  { [CITY]: \"London\", [LON]: -0.1, [LAT]: 51.5, [POPULATION]: 9.6, [REGION]: \"Europe\" },\n  { [CITY]: \"Madrid\", [LON]: -3.7, [LAT]: 40.4, [POPULATION]: 6.7, [REGION]: \"Europe\" },\n  { [CITY]: \"Cairo\", [LON]: 31.2, [LAT]: 30.0, [POPULATION]: 21.3, [REGION]: \"Africa\" },\n  { [CITY]: \"Kinshasa\", [LON]: 15.3, [LAT]: -4.3, [POPULATION]: 15.6, [REGION]: \"Africa\" },\n  { [CITY]: \"Lagos\", [LON]: 3.4, [LAT]: 6.5, [POPULATION]: 15.4, [REGION]: \"Africa\" },\n  { [CITY]: \"Johannesburg\", [LON]: 28.0, [LAT]: -26.2, [POPULATION]: 6.2, [REGION]: \"Africa\" },\n  { [CITY]: \"Nairobi\", [LON]: 36.8, [LAT]: -1.3, [POPULATION]: 4.9, [REGION]: \"Africa\" },\n  { [CITY]: \"Sao Paulo\", [LON]: -46.6, [LAT]: -23.5, [POPULATION]: 22.6, [REGION]: \"Americas\" },\n  { [CITY]: \"Mexico City\", [LON]: -99.1, [LAT]: 19.4, [POPULATION]: 22.3, [REGION]: \"Americas\" },\n  { [CITY]: \"New York\", [LON]: -74.0, [LAT]: 40.7, [POPULATION]: 18.9, [REGION]: \"Americas\" },\n  { [CITY]: \"Buenos Aires\", [LON]: -58.4, [LAT]: -34.6, [POPULATION]: 15.4, [REGION]: \"Americas\" },\n  { [CITY]: \"Bogota\", [LON]: -74.1, [LAT]: 4.7, [POPULATION]: 11.2, [REGION]: \"Americas\" },\n];\n\n// Basemap geometry: simplified coastlines as [longitude, latitude] rings\nconst LAND: { name: string; ring: [number, number][] }[] = [\n  { name: \"North America\", ring: [\n    [-166, 68.5], [-163, 70], [-156, 71.3], [-148, 70.3], [-141, 69.6], [-133, 69.5], [-128, 70], [-115, 68.5],\n    [-108, 68], [-98, 67.8], [-94, 69], [-90, 68.5], [-85, 69.5], [-82, 67], [-86, 64], [-93, 61.5], [-94, 58.8],\n    [-90, 57], [-82, 55], [-80, 51.5], [-79, 55], [-77, 60], [-78, 62.5], [-72, 62], [-65, 60], [-62, 57], [-58, 54],\n    [-56, 52], [-60, 50], [-65, 49], [-64, 47], [-61, 45.5], [-66, 44], [-70, 43.5], [-70, 41.8], [-74, 40.5],\n    [-76, 38], [-76, 35], [-78.5, 33.8], [-81, 31.5], [-80, 27], [-80.5, 25.2], [-82, 26.5], [-82.8, 28], [-84, 30],\n    [-86, 30.4], [-89, 30.2], [-90, 29], [-94, 29.7], [-97.2, 27.5], [-97.5, 24], [-97.8, 22], [-96, 19],\n    [-94.5, 18.2], [-91, 18.7], [-90.5, 21], [-87, 21.5], [-87.5, 18.5], [-88.5, 16], [-86, 15.8], [-83.3, 15],\n    [-83.5, 11], [-81.5, 9], [-79.5, 9.5], [-77.4, 8.6], [-77.9, 7.2], [-80, 7.3], [-82.5, 8.2], [-85.7, 10],\n    [-86, 11.5], [-87.5, 13], [-91.5, 14], [-94.5, 16], [-96.5, 15.7], [-99.7, 16.8], [-103.5, 18.3], [-105.5, 20.5],\n    [-105.3, 22.5], [-108, 25.5], [-112.7, 31.5], [-114.8, 31.8], [-112.5, 28.5], [-110, 24], [-109.5, 23],\n    [-112, 24.8], [-114.2, 28], [-115.8, 30.4], [-117.1, 32.5], [-118.5, 34], [-120.6, 34.6], [-122.5, 37.7],\n    [-124, 40.4], [-124.2, 43], [-124, 46.2], [-124.7, 48.4], [-123, 49], [-127.5, 50.5], [-130, 54.5], [-133, 57.5],\n    [-137, 58.8], [-140, 59.8], [-146, 60.8], [-150, 59.5], [-152, 60.5], [-154, 58.5], [-158, 56.7], [-162, 55],\n    [-164.5, 54.5], [-158, 58.7], [-162, 59.8], [-165, 60.5], [-164.8, 63], [-161, 64.5], [-166, 65.3], [-168, 65.6],\n    [-164, 67],\n  ] },\n  { name: \"Baffin Island\", ring: [\n    [-62, 66.5], [-66, 68.5], [-70, 70.5], [-78, 72.8], [-88, 73.5], [-84, 70], [-80, 69], [-73, 68], [-77, 65.5],\n    [-73, 64], [-66, 62], [-64, 64],\n  ] },\n  { name: \"Victoria Island\", ring: [\n    [-118, 72.8], [-110, 73], [-102, 72.5], [-101, 69.5], [-108, 68.8], [-117, 69.5],\n  ] },\n  { name: \"Ellesmere Island\", ring: [\n    [-90, 76.5], [-78, 76.5], [-74, 79], [-62, 82], [-70, 83], [-88, 81.5], [-92, 79.5],\n  ] },\n  { name: \"Greenland\", ring: [\n    [-45, 60], [-43, 60], [-38, 65.5], [-32, 68], [-22, 70.5], [-21.5, 74], [-18, 77], [-19, 80], [-12, 81.5],\n    [-20, 82.5], [-32, 83.5], [-45, 82.7], [-60, 82], [-65, 80.5], [-73, 78.5], [-66, 76], [-58, 75.8], [-55, 72],\n    [-53, 69], [-51.5, 64], [-48, 61],\n  ] },\n  { name: \"Iceland\", ring: [\n    [-24, 65.5], [-22, 66.4], [-16, 66.5], [-13.6, 65.2], [-15, 64.3], [-18.5, 63.4], [-22.5, 63.8],\n  ] },\n  { name: \"Cuba\", ring: [\n    [-85, 21.9], [-82, 23.2], [-77.2, 22.2], [-74.2, 20.3], [-77.7, 19.9], [-80.5, 21.7], [-83.5, 22],\n  ] },\n  { name: \"Hispaniola\", ring: [[-74.4, 18.5], [-72.7, 19.9], [-69.6, 19.7], [-68.4, 18.6], [-71.5, 17.6]] },\n  { name: \"South America\", ring: [\n    [-77.4, 8.6], [-76, 9.5], [-75.5, 10.8], [-73, 11.5], [-71.5, 12.4], [-71.5, 10.8], [-68, 10.5], [-64, 10.6],\n    [-61.8, 10.7], [-60.5, 8.5], [-57, 6], [-54, 5.8], [-51.5, 4.5], [-50, 1.8], [-48.5, -1.2], [-44.5, -2.5],\n    [-40, -3], [-35.2, -5.5], [-35, -9], [-38.5, -13], [-39, -17.5], [-40.8, -22], [-44, -23], [-48.5, -26],\n    [-48.8, -28.5], [-51, -31], [-53.5, -34], [-56, -34.9], [-57.5, -36.2], [-57.5, -38.2], [-62.2, -38.8],\n    [-62.3, -40.6], [-65, -41], [-64.5, -42.5], [-67.5, -46], [-65.8, -47.8], [-69, -51], [-68.5, -52.4],\n    [-68.6, -54.8], [-67.5, -54.8], [-71, -55], [-74.5, -52.5], [-75.5, -48], [-74, -44], [-73.5, -40], [-73.5, -37],\n    [-71.6, -33], [-71.4, -28], [-70.4, -23.5], [-70.3, -18.4], [-71.4, -17.5], [-76.2, -14], [-78.5, -10],\n    [-79.9, -7], [-81.2, -5.5], [-80.4, -3.4], [-80.9, -1], [-80, 0.8], [-79, 1.7], [-77.8, 4], [-77.4, 7],\n  ] },\n  { name: \"Eurasia\", ring: [\n    [-5.6, 36], [-6.4, 36.8], [-7.4, 37.2], [-8.9, 37], [-8.8, 38.7], [-9.5, 39.4], [-8.7, 41.2], [-8.9, 42.6],\n    [-9.3, 43], [-7.7, 43.7], [-4.5, 43.4], [-1.8, 43.4], [-1.2, 44.6], [-1.2, 46.2], [-2.3, 47.2], [-4.6, 48],\n    [-3, 48.8], [-1.6, 48.6], [-1.4, 49.7], [0.2, 49.5], [1.6, 50.2], [2.5, 51.1], [3.6, 51.5], [4.6, 52.9],\n    [5.9, 53.4], [8, 53.6], [8.6, 54.9], [8.1, 55.5], [8.2, 56.8], [10.6, 57.7], [10.3, 56.5], [10.9, 56.3],\n    [9.9, 55], [10.9, 54], [12.5, 54.4], [14.2, 53.9], [16.5, 54.5], [18.6, 54.7], [19.6, 54.4], [21.1, 55.2],\n    [21, 56.8], [21.6, 57.4], [23.4, 59.1], [24, 59.3], [28, 59.5], [29.9, 59.9], [28, 60.5], [25, 60.2],\n    [22.9, 59.8], [21.4, 60.8], [21.6, 63.2], [23.5, 64.6], [25.3, 65.1], [24.6, 65.8], [22.3, 65.8], [21.2, 64.6],\n    [19, 63.4], [17.4, 62.4], [17.2, 61], [18.6, 60.2], [18.9, 59.4], [17, 57.5], [16.4, 56.5], [14.7, 56],\n    [13, 55.4], [12.8, 56.6], [11.8, 58.1], [10.9, 59], [10.6, 59.9], [9.8, 59], [8.1, 58.1], [6.6, 58.1],\n    [5.6, 58.9], [5, 60.5], [5.1, 61.9], [6.5, 62.7], [9, 63.7], [10.8, 64.8], [12.6, 66.1], [14.2, 67.5],\n    [16, 68.5], [18.8, 69.8], [22.5, 70.6], [25.8, 71.1], [28.5, 70.9], [31, 70], [33, 69.3], [36.5, 69], [41, 67],\n    [38, 66], [35, 64.5], [37.5, 63.8], [40.5, 64.6], [44, 66.3], [44.2, 68.3], [46.5, 68], [53, 68.6], [59, 68.6],\n    [61, 69.8], [66, 69.3], [68.5, 71], [70.5, 73.2], [73, 71.5], [73.5, 68.5], [76.5, 72], [80.5, 73.6],\n    [86.5, 74.5], [87.5, 75.5], [95, 76.1], [104, 77.7], [108, 76.7], [113, 75.9], [113.5, 73.5], [119, 73],\n    [127, 73.5], [129, 72], [132.5, 71.6], [139, 72.3], [146, 72.3], [152, 70.9], [160, 70], [161.5, 69.4],\n    [167, 69.7], [170.5, 70.1], [176, 69.6], [179.9, 68.9], [179.9, 65], [177, 64.7], [174.5, 61.8], [170.5, 60],\n    [166, 60.3], [163.5, 59.8], [162, 56.2], [160, 54], [158.3, 53], [156.7, 51], [156, 52.8], [155.5, 55.5],\n    [156.8, 57.8], [161, 60.5], [159.5, 61.7], [154, 59.3], [151, 59.2], [143, 59.4], [140, 58], [137, 54],\n    [140.5, 53], [141.3, 51.5], [140.5, 50], [140, 48], [138.5, 46.5], [135.5, 43.8], [132, 43.1], [130.7, 42.3],\n    [129.7, 41], [128, 39.5], [129.4, 37.5], [129.4, 35.4], [127.5, 34.6], [126.3, 34.7], [126.6, 37.2],\n    [125.2, 37.7], [125.2, 39.5], [124.4, 40], [122.2, 40.5], [121, 40.8], [119, 39.2], [118, 39.2], [117.7, 38.5],\n    [118.9, 37.3], [120.5, 37.8], [122.5, 37.4], [120.5, 36], [119.4, 35], [120.3, 34.3], [121.8, 31.8],\n    [121.5, 30.8], [122, 29.9], [120.5, 27.2], [119.5, 25.6], [117.5, 23.6], [114.2, 22.3], [111, 21.5],\n    [110.3, 20.3], [109.7, 21.6], [108, 21.6], [106.7, 20.5], [105.8, 19], [106.5, 17.6], [108.8, 15.2],\n    [109.3, 12.5], [109, 11.4], [106.8, 10.4], [104.8, 8.6], [105, 10], [104.4, 10.4], [103, 11.6], [101, 12.7],\n    [100, 13.5], [99.2, 10.5], [100.4, 8], [101.3, 6.9], [103.4, 4], [104.2, 1.4], [103.5, 1.3], [101.3, 2.8],\n    [100.3, 5.5], [98.3, 8.2], [98.5, 10.5], [97.8, 14.9], [97.6, 16.5], [95.3, 15.8], [94.3, 16.4], [94.4, 19],\n    [92.3, 20.7], [91.8, 22.4], [90.3, 21.9], [88.5, 21.7], [86.9, 20.8], [86, 19.9], [84.2, 18.3], [82.3, 16.6],\n    [80.3, 15.5], [80.1, 13.3], [79.8, 11], [79.3, 10.3], [78.2, 8.9], [77.5, 8.1], [76.4, 9.5], [75.6, 11.6],\n    [74.4, 14.6], [73.4, 16.5], [72.8, 19.2], [72.6, 21.3], [70.4, 20.9], [69, 22.3], [68.4, 23.6], [67.3, 24.7],\n    [66.7, 25.4], [64, 25.3], [61.5, 25.1], [58.8, 25.5], [57.3, 26.9], [56.4, 27.1], [54.7, 26.5], [51.5, 27.9],\n    [50.2, 29.9], [48.5, 30], [48, 29.2], [48.5, 28], [49.6, 26.8], [50.2, 26], [50.8, 24.8], [51.6, 24.2], [52, 24],\n    [54, 24.2], [55.8, 25.3], [56.3, 26.3], [56.4, 24.9], [57.8, 23.7], [59.8, 22.4], [58.5, 20.5], [57.8, 18.9],\n    [55.4, 17.7], [52.2, 15.6], [48.8, 14], [45, 12.8], [43.5, 12.7], [42.7, 15.6], [41.2, 19], [39.2, 21.5],\n    [38.5, 23.6], [36.5, 26], [35, 28.1], [34.9, 29.5], [34.3, 28], [32.6, 29.9], [32.3, 31.2], [34.2, 31.3],\n    [35, 32.8], [35.9, 34.6], [36.1, 36.8], [34.6, 36.8], [32.5, 36.1], [30.5, 36.4], [28, 36.7], [27.3, 37.5],\n    [26.3, 38.3], [26.6, 39.5], [26.2, 40.1], [29, 41.1], [31.5, 41.2], [34, 42], [35.2, 42], [37.5, 41], [40, 41],\n    [41.6, 41.5], [41.5, 42.6], [39.5, 44], [37.4, 44.8], [38.3, 47.2], [36.6, 45.3], [35, 45], [33.5, 44.5],\n    [32.5, 45.4], [33.6, 46.1], [31.7, 46.6], [30.7, 46.4], [29.6, 45.4], [28.7, 44.4], [28, 43.3], [27.9, 42],\n    [28.9, 41.3], [28, 41], [26.2, 40.6], [24, 40.9], [23.5, 40.2], [22.6, 40.5], [22.8, 39.3], [23.3, 38.2],\n    [24, 38], [22.9, 37], [22.6, 36.4], [21.7, 36.8], [21.1, 37.8], [21.4, 38.5], [20.7, 39.1], [20, 39.7],\n    [19.4, 40.3], [19.5, 41.8], [18.5, 42.4], [17, 43.2], [15.9, 43.6], [15.2, 44.3], [14.3, 45.3], [13.6, 45.7],\n    [12.4, 45.4], [12.3, 44.6], [13.6, 43.5], [14.6, 42.1], [16, 41.4], [18.5, 40.1], [17, 39.4], [16.6, 38.4],\n    [16.1, 37.9], [15.7, 38.2], [15.6, 40.1], [14.4, 40.6], [12.6, 41.4], [11.2, 42.4], [10.5, 43], [10.2, 43.9],\n    [8.8, 44.4], [7.6, 43.8], [6.2, 43.1], [4.6, 43.4], [3.1, 43.1], [3.2, 42], [2.1, 41.2], [0.8, 41], [0, 39.9],\n    [-0.3, 39.4], [0.2, 38.7], [-0.7, 37.6], [-2.1, 36.7], [-4.4, 36.7],\n  ] },\n  { name: \"Great Britain\", ring: [\n    [-5.7, 50.1], [-3, 50.7], [1.4, 51.2], [1.7, 52.7], [0.3, 53.4], [-0.1, 54.5], [-1.6, 55.6], [-2.1, 57.1],\n    [-1.8, 57.6], [-4, 57.6], [-3.1, 58.6], [-5, 58.6], [-6.2, 56.8], [-5.6, 55.3], [-4.9, 54.8], [-3.2, 54.6],\n    [-3, 53.4], [-4.6, 53.3], [-4, 52.3], [-5.1, 51.8], [-3.2, 51.4],\n  ] },\n  { name: \"Ireland\", ring: [\n    [-6, 52.2], [-6.2, 53.9], [-5.8, 54.6], [-7.3, 55.3], [-8.5, 54.4], [-10, 54.2], [-9.6, 53.3], [-10.3, 52],\n    [-9, 51.6], [-7.5, 52],\n  ] },\n  { name: \"Novaya Zemlya\", ring: [[52, 71.5], [56, 73], [60, 75.5], [68, 76.8], [64, 75.2], [57, 72.5], [55, 70.6]] },\n  { name: \"Africa\", ring: [\n    [32.3, 31.2], [31, 31.6], [29.8, 31.1], [27.3, 31.4], [25.1, 31.6], [23, 32.6], [21, 32.8], [20, 30.8],\n    [18.5, 30.4], [15.5, 31.6], [13, 32.9], [11.1, 33.3], [10.1, 34.3], [11, 35.6], [10.2, 37.2], [8.6, 36.9],\n    [5, 36.8], [1, 36.5], [-1.3, 35.3], [-3, 35.3], [-5.9, 35.8], [-6.5, 34.2], [-9, 32.6], [-9.8, 30.6],\n    [-11.5, 28.2], [-13.2, 27.6], [-14.5, 26.2], [-16, 23.8], [-17.1, 21], [-16, 19.5], [-16.5, 16.6], [-17.5, 14.7],\n    [-16.7, 13.1], [-16.7, 12.3], [-15.1, 11.2], [-13.7, 9.8], [-13.2, 8.9], [-12.2, 7.4], [-10.5, 6.2], [-7.6, 4.4],\n    [-5, 5.1], [-2, 4.8], [1, 6.1], [2.7, 6.4], [4.4, 6.3], [5.9, 4.3], [7.1, 4.4], [8.5, 4.6], [9.6, 3.6],\n    [9.4, 2.2], [9.6, 1], [9.3, -0.8], [10.1, -2.8], [11.8, -4.4], [12.3, -6.1], [13.4, -8.6], [13.6, -11.3],\n    [12, -15], [11.8, -17.3], [13.4, -21], [14.5, -22.9], [15.2, -26.6], [16.5, -28.6], [17.9, -31.5], [18.4, -34],\n    [20, -34.8], [22.5, -34], [25.6, -34], [27.8, -33.2], [30, -31.3], [32.6, -28.6], [32.9, -26], [35.4, -24.1],\n    [35.5, -21.3], [34.7, -19.8], [36.9, -17.6], [40.6, -14], [40.5, -10.5], [39, -6.5], [39.8, -3.8], [41, -2],\n    [43.5, 0.5], [46, 2], [48, 4.5], [49.8, 7.5], [51.2, 10.5], [51.3, 11.8], [49, 11.3], [45.5, 10.6], [43.4, 11.5],\n    [42.8, 12.5], [41.2, 14], [39.3, 15.9], [38.5, 18], [37.3, 22], [35.8, 23.9], [35.1, 24.8], [33.9, 27],\n    [32.6, 29.9],\n  ] },\n  { name: \"Madagascar\", ring: [\n    [49.3, -12], [50.3, -15.4], [49.9, -17], [48.4, -21.5], [47.1, -24.9], [45.2, -25.6], [43.7, -23.5],\n    [43.3, -21.5], [44.4, -19], [44, -17], [46.3, -15.8], [48, -13.6],\n  ] },\n  { name: \"Sri Lanka\", ring: [[79.9, 6], [79.7, 8.2], [80.1, 9.8], [81.2, 8.5], [81.9, 7.2], [80.6, 5.9]] },\n  { name: \"Taiwan\", ring: [[120.1, 23], [121, 25], [121.9, 25], [121.5, 23], [120.8, 21.9]] },\n  { name: \"Honshu, Kyushu & Shikoku\", ring: [\n    [130.2, 31.3], [131.4, 31.4], [132, 33], [133, 33.3], [134.7, 33.8], [135.8, 33.5], [136.9, 34.3], [138.8, 34.6],\n    [139.8, 35], [140.9, 36.3], [141, 38.3], [142, 39.6], [141.5, 40.5], [141.4, 41.4], [140, 40.8], [139.9, 39.5],\n    [139.5, 38.2], [138.5, 37.4], [137, 36.8], [136, 35.7], [133, 35.5], [131.5, 34.6], [130.9, 34], [129.7, 33.2],\n  ] },\n  { name: \"Hokkaido\", ring: [\n    [140, 41.5], [141.3, 42.4], [143.3, 42], [145.5, 43.3], [144.5, 44], [142, 45.5], [141.6, 44.3], [140.3, 43.2],\n  ] },\n  { name: \"Sakhalin\", ring: [\n    [142, 46], [143.5, 46.8], [142.7, 49.5], [143.2, 51.5], [142.5, 54.2], [141.7, 52], [142.2, 49],\n  ] },\n  { name: \"Luzon\", ring: [\n    [120.6, 18.5], [122.2, 18.5], [121.5, 15.5], [124.2, 12.6], [123.2, 13.5], [120.6, 14.2], [119.8, 16.3],\n  ] },\n  { name: \"Mindanao\", ring: [[122, 7], [123.6, 8.6], [125.4, 9.8], [126.6, 7.3], [125.5, 5.6], [124, 6.4]] },\n  { name: \"Borneo\", ring: [\n    [109, 1.5], [109.6, 2], [111.3, 2.7], [113, 3.2], [115.4, 5], [116.8, 7], [119.3, 5.4], [118, 4.3], [117.6, 0.8],\n    [116.5, -1.5], [116.4, -3.5], [114.5, -4], [111.7, -3], [110.2, -2.9], [109.5, -0.5],\n  ] },\n  { name: \"Sumatra\", ring: [\n    [95.3, 5.6], [97.5, 5.2], [100.4, 2.3], [103.7, -0.8], [106, -3.2], [105.8, -5.8], [104.5, -5.9], [102.3, -4],\n    [100.4, -0.8], [98.6, 1.8],\n  ] },\n  { name: \"Java\", ring: [\n    [105.2, -6.8], [106.5, -6], [108.5, -6.4], [110.4, -6.9], [112.6, -6.9], [114.4, -7.8], [112, -8.4],\n    [108.8, -7.8], [106.4, -7.4],\n  ] },\n  { name: \"Sulawesi\", ring: [\n    [119.4, -5.5], [118.8, -2.8], [119.9, 0.6], [124.9, 1.5], [121, 0.3], [123.3, -0.9], [121.3, -1.9],\n    [122.8, -4.6], [121, -4.8], [120.4, -5.6],\n  ] },\n  { name: \"New Guinea\", ring: [\n    [131, -1.2], [134, -0.9], [135, -3.3], [138, -1.6], [141, -2.6], [144.5, -3.8], [146, -5.5], [147.6, -6.1],\n    [147.2, -7.4], [148.4, -8.6], [150, -10.4], [147, -10.1], [144, -7.6], [142.6, -9.3], [141, -9.1], [139, -8.1],\n    [138, -8.4], [137.6, -5.2], [134.4, -3.9], [132, -2.8],\n  ] },\n  { name: \"Australia\", ring: [\n    [113.4, -22], [114.2, -21.8], [116.7, -20.6], [119, -20], [121, -19.5], [122.3, -17.2], [124, -16.3],\n    [125.8, -14.2], [127.8, -14.3], [129.6, -15], [130.4, -12.7], [132.6, -12.1], [136.7, -12.2], [135.9, -15.1],\n    [139.2, -17.4], [140.8, -17.4], [141.6, -15], [141.5, -12.6], [142.5, -10.7], [143.5, -12.8], [145.3, -14.9],\n    [146.3, -19], [149.3, -21.7], [150.9, -23.5], [153.1, -25.6], [153.6, -28.8], [153, -31], [151.3, -33.9],\n    [150.1, -36.3], [149.9, -37.6], [147, -38.6], [144.6, -38.2], [143.5, -38.8], [140.6, -38], [139.6, -36.9],\n    [138.1, -35.4], [138.5, -34.4], [137.8, -33], [137.4, -34.5], [136, -34.9], [134.2, -32.8], [131.1, -31.5],\n    [128, -32.2], [124, -33], [121.2, -33.9], [118, -35.1], [115, -34.3], [115.6, -31.6], [114.9, -29.1],\n    [113.4, -26.3], [114, -24.9],\n  ] },\n  { name: \"Tasmania\", ring: [[144.6, -40.7], [148.3, -40.9], [148, -43.2], [146.6, -43.6], [145.2, -42.2]] },\n  { name: \"New Zealand North Island\", ring: [\n    [172.7, -34.4], [174.6, -35.8], [175.9, -37.5], [178.5, -37.7], [177.9, -39.2], [176.9, -39.6], [175.3, -41.6],\n    [174.6, -41.2], [175, -39.9], [173.8, -39.3], [174.6, -38], [174.3, -36.6],\n  ] },\n  { name: \"New Zealand South Island\", ring: [\n    [172.6, -40.5], [174.2, -41.6], [173.3, -43], [172.7, -43.8], [171.2, -44.4], [170.6, -45.9], [169, -46.6],\n    [166.5, -46], [168.4, -44], [170.6, -42.9], [172.1, -41],\n  ] },\n];\n\n// Plot: reads only data, the geometry and the constants above\nconst { width: W, height: H } = window.ANYPLOT_SIZE;\nconst TITLE_H = 80;\nconst LEGEND_H = 44; // the region legend above the map adds its own height\nconst SIZE_LEGEND_W = 220;\nconst X_AXIS_H = 56;\nconst Y_AXIS_W = 72;\nconst MARGIN = { top: 12, right: 24, bottom: 12, left: 16 };\nconst CHART_W = W - SIZE_LEGEND_W;\nconst CHART_H = H - TITLE_H - LEGEND_H;\nconst DRAW_W = CHART_W - MARGIN.left - MARGIN.right - Y_AXIS_W;\nconst DRAW_H = CHART_H - MARGIN.top - MARGIN.bottom - X_AXIS_H;\n\n// Equirectangular view at the data's mean latitude: px per degree of latitude is\n// px per degree of longitude divided by cos(mean latitude); the padded data extent\n// grows along one axis until it fills the drawing area\nconst lons = data.map((d) => d[LON]);\nconst lats = data.map((d) => d[LAT]);\nconst lonMin = Math.min(...lons);\nconst lonMax = Math.max(...lons);\nconst latMin = Math.min(...lats);\nconst latMax = Math.max(...lats);\nconst cosMeanLat = Math.cos(((lats.reduce((s, v) => s + v, 0) / lats.length) * Math.PI) / 180);\nconst lonSpan0 = (lonMax - lonMin) * (1 + 2 * PAD_SHARE);\nconst latSpan0 = (latMax - latMin) * (1 + 2 * PAD_SHARE);\nconst latSpanFill = (DRAW_H * cosMeanLat * lonSpan0) / DRAW_W;\nconst lonSpan = latSpanFill >= latSpan0 ? lonSpan0 : (latSpan0 * DRAW_W) / (DRAW_H * cosMeanLat);\nconst latSpan = latSpanFill >= latSpan0 ? latSpanFill : latSpan0;\nconst lonCenter = (lonMin + lonMax) / 2;\nconst latCenter = (latMin + latMax) / 2;\n\n// Bubble area is proportional to the value: radius grows with the square root of its share of the maximum\nconst maxValue = Math.max(...data.map((d) => d[POPULATION]));\nconst bubbleRadius = (share: number) => Math.max(MIN_RADIUS, MAX_RADIUS * Math.sqrt(share));\n\n// One series per category in order of first appearance; within each region larger bubbles come first so\n// smaller ones draw on top (series draw in order, so a later region's bubble can cover an earlier one's)\nconst regions = [...new Set(data.map((d) => d[REGION]))];\nconst series = regions.map((region, i) => ({\n  type: \"scatter\" as const,\n  id: `region-${i}`,\n  label: region,\n  color: t.palette[i],\n  sizeAxisId: \"population\",\n  data: data\n    .filter((d) => d[REGION] === region)\n    .sort((a, b) => b[POPULATION] - a[POPULATION])\n    .map((d) => ({ id: d[CITY], x: d[LON], y: d[LAT], sizeValue: d[POPULATION] })),\n  valueFormatter: (v: { id: string; sizeValue: number }) => `${v.id} · ${POPULATION} ${v.sizeValue}`,\n}));\n\n// Size legend: three reference values, the largest rounded down to one significant digit\nconst magnitude = 10 ** Math.floor(Math.log10(maxValue));\nconst topRef = Math.floor(maxValue / magnitude) * magnitude;\nconst sizeRefs = [topRef / 10, topRef / 3, topRef].map((v) => Number(v.toPrecision(1)));\nconst sizeRefRadii = sizeRefs.map((v) => bubbleRadius(v / maxValue));\n\nconst TITLE = \"bubble-map-geographic · javascript · muix · anyplot.ai\";\nconst subtitle = `${data.length} cities · bubble area proportional to ${POPULATION.toLowerCase()} · color by ${REGION.toLowerCase()}`;\n\nfunction Basemap() {\n  const xScale = useXScale();\n  const yScale = useYScale();\n  const area = useDrawingArea();\n  return (\n    <g clipPath=\"url(#bubble-map-clip)\">\n      <defs>\n        <clipPath id=\"bubble-map-clip\">\n          <rect x={area.left} y={area.top} width={area.width} height={area.height} />\n        </clipPath>\n      </defs>\n      {LAND.map((land) => (\n        <path\n          key={land.name}\n          d={`M${land.ring.map(([lon, lat]) => `${xScale(lon)},${yScale(lat)}`).join(\"L\")}Z`}\n          fill={t.grid}\n          stroke={t.inkSoft}\n          strokeOpacity={0.55}\n          strokeWidth={0.8}\n        />\n      ))}\n    </g>\n  );\n}\n\nexport default function Chart() {\n  return (\n    <div style={{ width: W, height: H, display: \"flex\", flexDirection: \"column\", background: t.pageBg }}>\n      <div style={{ height: TITLE_H, display: \"flex\", flexDirection: \"column\", alignItems: \"center\", justifyContent: \"center\", gap: 6, paddingTop: 10 }}>\n        <div style={{ fontSize: 22, fontWeight: 600, color: t.ink }}>{TITLE}</div>\n        <div style={{ fontSize: 15, color: t.inkSoft }}>{subtitle}</div>\n      </div>\n      <div style={{ display: \"flex\", flexDirection: \"row\" }}>\n        <ChartsDataProvider\n          width={CHART_W}\n          height={CHART_H}\n          margin={MARGIN}\n          series={series}\n          xAxis={[\n            {\n              min: lonCenter - lonSpan / 2,\n              max: lonCenter + lonSpan / 2,\n              label: LON,\n              height: X_AXIS_H,\n              tickNumber: 10,\n              valueFormatter: (v: number) => `${Math.round(Math.abs(v))}°${v < 0 ? \"W\" : \"E\"}`,\n              labelStyle: { fontSize: 16, fill: t.ink },\n              tickLabelStyle: { fontSize: 14, fill: t.inkSoft },\n            },\n          ]}\n          yAxis={[\n            {\n              min: latCenter - latSpan / 2,\n              max: latCenter + latSpan / 2,\n              label: LAT,\n              width: Y_AXIS_W,\n              tickNumber: 8,\n              valueFormatter: (v: number) => `${Math.round(Math.abs(v))}°${v < 0 ? \"S\" : \"N\"}`,\n              labelStyle: { fontSize: 16, fill: t.ink },\n              tickLabelStyle: { fontSize: 14, fill: t.inkSoft },\n            },\n          ]}\n          zAxis={[{ id: \"population\", sizeMap: { type: \"continuous\", min: 0, max: maxValue, size: bubbleRadius } }]}\n          skipAnimation\n        >\n          <ChartsWrapper legendPosition={{ vertical: \"top\", horizontal: \"center\" }} legendDirection=\"horizontal\">\n            <ChartsLegend sx={{ fontSize: 15, color: t.inkSoft }} />\n            <ChartsSurface\n              sx={{\n                \"& .MuiChartsAxis-line\": { stroke: t.inkSoft },\n                \"& .MuiChartsAxis-tick\": { stroke: t.inkSoft },\n                \"& .MuiChartsGrid-line\": { stroke: t.grid, strokeWidth: 1 },\n                \"& .MuiScatterChart-marker\": { fillOpacity: BUBBLE_OPACITY, stroke: t.pageBg, strokeWidth: 1.2 },\n              }}\n            >\n              <Basemap />\n              <ChartsGrid horizontal vertical />\n              <ScatterPlot />\n              <ChartsXAxis />\n              <ChartsYAxis />\n            </ChartsSurface>\n            <ChartsTooltip trigger=\"item\" />\n          </ChartsWrapper>\n        </ChartsDataProvider>\n        <div\n          style={{\n            width: SIZE_LEGEND_W,\n            display: \"flex\",\n            flexDirection: \"column\",\n            justifyContent: \"center\",\n            paddingRight: 24,\n            boxSizing: \"border-box\",\n          }}\n        >\n          <div style={{ fontSize: 15, color: t.inkSoft, marginBottom: 14 }}>{POPULATION}</div>\n          {sizeRefs.map((v, i) => (\n            <div key={v} style={{ display: \"flex\", alignItems: \"center\", gap: 14, marginBottom: 12 }}>\n              <svg width={2 * MAX_RADIUS + 2} height={2 * sizeRefRadii[i] + 2}>\n                <circle\n                  cx={MAX_RADIUS + 1}\n                  cy={sizeRefRadii[i] + 1}\n                  r={sizeRefRadii[i]}\n                  fill={t.inkSoft}\n                  fillOpacity={BUBBLE_OPACITY}\n                  stroke={t.pageBg}\n                  strokeWidth={1.2}\n                />\n              </svg>\n              <span style={{ fontSize: 15, color: t.inkSoft }}>{v}</span>\n            </div>\n          ))}\n        </div>\n      </div>\n    </div>\n  );\n}\n"}