├── corona.cases.csv ├── corona_status.csv ├── corona_status.json ├── exportdata.rb ├── corona_status.color.json ├── index.html └── datamaps.ind.min.js /corona.cases.csv: -------------------------------------------------------------------------------- 1 | 1 Andhra Pradesh 7 0 0 0 2 | 2 Bihar 2 0 0 1 3 | 3 Chhattisgarh 1 0 0 0 4 | 4 Delhi 30 1 6 1 5 | 5 Gujarat 29 0 0 1 6 | 6 Haryana 12 14 11 0 7 | 7 Himachal Pradesh 3 0 0 1 8 | 8 Karnataka 37 0 2 1 9 | 9 Kerala 87 8 4 0 10 | 10 Madhya Pradesh 7 0 0 0 11 | 11 Maharashtra 84 3 0 2 12 | 12 Odisha 2 0 0 0 13 | 13 Puducherry 1 0 0 0 14 | 14 Punjab 21 0 0 1 15 | 15 Rajasthan 31 2 3 0 16 | 16 Tamil Nadu 10 2 1 0 17 | 17 Telengana 22 10 1 0 18 | 18 Chandigarh 6 0 0 0 19 | 19 Jammu and Kashmir 4 0 0 0 20 | 20 Ladakh 13 0 0 0 21 | 21 Uttar Pradesh 32 1 9 0 22 | 22 Uttarakhand 3 0 0 0 23 | 23 West Bengal 7 0 0 1 -------------------------------------------------------------------------------- /corona_status.csv: -------------------------------------------------------------------------------- 1 | AP,7,9.86,0,0.0,0,0.0,0,0.0 2 | BR,2,2.82,0,0.0,0,0.0,1,50.0 3 | CT,1,1.41,0,0.0,0,0.0,0,0.0 4 | DL,28,39.44,1,7.14,5,45.45,1,50.0 5 | GJ,29,40.85,0,0.0,0,0.0,1,50.0 6 | HR,12,16.9,14,100.0,11,100.0,0,0.0 7 | HP,3,4.23,0,0.0,0,0.0,1,50.0 8 | KA,33,46.48,0,0.0,2,18.18,1,50.0 9 | KL,60,84.51,7,50.0,3,27.27,0,0.0 10 | MP,6,8.45,0,0.0,0,0.0,0,0.0 11 | MH,71,100.0,3,21.43,0,0.0,2,100.0 12 | OD,2,2.82,0,0.0,0,0.0,0,0.0 13 | PY,1,1.41,0,0.0,0,0.0,0,0.0 14 | PB,21,29.58,0,0.0,0,0.0,1,50.0 15 | RJ,26,36.62,2,14.29,3,27.27,0,0.0 16 | TN,7,9.86,2,14.29,1,9.09,0,0.0 17 | TS,22,30.99,10,71.43,1,9.09,0,0.0 18 | CH,6,8.45,0,0.0,0,0.0,0,0.0 19 | JK,4,5.63,0,0.0,0,0.0,0,0.0 20 | LK,13,18.31,0,0.0,0,0.0,0,0.0 21 | UP,30,42.25,1,7.14,9,81.82,0,0.0 22 | UK,3,4.23,0,0.0,0,0.0,0,0.0 23 | WB,7,9.86,0,0.0,0,0.0,1,50.0 24 | -------------------------------------------------------------------------------- /corona_status.json: -------------------------------------------------------------------------------- 1 | [{"centered":"AP","radius":3.0,"state":"Andhra Pradesh","info":[7,8.05,0,0.0,0,0.0,0,0.0]},{"centered":"BR","radius":1.0,"state":"Bihar","info":[2,2.3,0,0.0,0,0.0,1,50.0]},{"centered":"CT","radius":1.0,"state":"Chhattisgarh","info":[1,1.15,0,0.0,0,0.0,0,0.0]},{"centered":"DL","radius":11.0,"state":"Delhi","info":[30,34.48,1,7.14,6,54.55,1,50.0]},{"centered":"GJ","radius":11.0,"state":"Gujarat","info":[29,33.33,0,0.0,0,0.0,1,50.0]},{"centered":"HR","radius":5.0,"state":"Haryana","info":[12,13.79,14,100.0,11,100.0,0,0.0]},{"centered":"HP","radius":2.0,"state":"Himachal Pradesh","info":[3,3.45,0,0.0,0,0.0,1,50.0]},{"centered":"KA","radius":13.0,"state":"Karnataka","info":[37,42.53,0,0.0,2,18.18,1,50.0]},{"centered":"KL","radius":31.0,"state":"Kerala","info":[87,100.0,8,57.14,4,36.36,0,0.0]},{"centered":"MP","radius":3.0,"state":"Madhya Pradesh","info":[7,8.05,0,0.0,0,0.0,0,0.0]},{"centered":"MH","radius":29.0,"state":"Maharashtra","info":[84,96.55,3,21.43,0,0.0,2,100.0]},{"centered":"OD","radius":1.0,"state":"Odisha","info":[2,2.3,0,0.0,0,0.0,0,0.0]},{"centered":"PY","radius":1.0,"state":"Puducherry","info":[1,1.15,0,0.0,0,0.0,0,0.0]},{"centered":"PB","radius":8.0,"state":"Punjab","info":[21,24.14,0,0.0,0,0.0,1,50.0]},{"centered":"RJ","radius":11.0,"state":"Rajasthan","info":[31,35.63,2,14.29,3,27.27,0,0.0]},{"centered":"TN","radius":4.0,"state":"Tamil Nadu","info":[10,11.49,2,14.29,1,9.09,0,0.0]},{"centered":"TS","radius":8.0,"state":"Telengana","info":[22,25.29,10,71.43,1,9.09,0,0.0]},{"centered":"CH","radius":3.0,"state":"Chandigarh","info":[6,6.9,0,0.0,0,0.0,0,0.0]},{"centered":"JK","radius":2.0,"state":"Jammu and Kashmir","info":[4,4.6,0,0.0,0,0.0,0,0.0]},{"centered":"LK","radius":5.0,"state":"Ladakh","info":[13,14.94,0,0.0,0,0.0,0,0.0]},{"centered":"UP","radius":12.0,"state":"Uttar Pradesh","info":[32,36.78,1,7.14,9,81.82,0,0.0]},{"centered":"UK","radius":2.0,"state":"Uttarakhand","info":[3,3.45,0,0.0,0,0.0,0,0.0]},{"centered":"WB","radius":3.0,"state":"West Bengal","info":[7,8.05,0,0.0,0,0.0,1,50.0]}] 2 | -------------------------------------------------------------------------------- /exportdata.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: false 3 | 4 | require 'csv' 5 | require 'json' 6 | 7 | require 'chroma' 8 | 9 | INDIAN_STATES = { 10 | AN: 'Andaman & Nicobar Island', 11 | AP: 'Andhra Pradesh', 12 | AR: 'Arunanchal Pradesh', 13 | AS: 'Assam', 14 | BR: 'Bihar', 15 | CH: 'Chandigarh', 16 | CT: 'Chhattisgarh', 17 | DD: 'Daman & Diu', 18 | DL: 'Delhi', 19 | DN: 'Dadara & Nagar Havelli', 20 | GA: 'Goa', 21 | GJ: 'Gujarat', 22 | HP: 'Himachal Pradesh', 23 | HR: 'Haryana', 24 | JH: 'Jharkhand', 25 | JK: 'Jammu and Kashmir', 26 | KA: 'Karnataka', 27 | KL: 'Kerala', 28 | LD: 'Lakshadweep', 29 | MH: 'Maharashtra', 30 | ML: 'Meghalaya', 31 | MN: 'Manipur', 32 | MP: 'Madhya Pradesh', 33 | MZ: 'Mizoram', 34 | NL: 'Nagaland', 35 | OD: 'Odisha', 36 | PB: 'Punjab', 37 | PY: 'Puducherry', 38 | RJ: 'Rajasthan', 39 | SK: 'Sikkim', 40 | TN: 'Tamil Nadu', 41 | TR: 'Tripura', 42 | TS: 'Telengana', 43 | UK: 'Uttarakhand', 44 | UP: 'Uttar Pradesh', 45 | WB: 'West Bengal', 46 | LK: 'Ladakh' 47 | } 48 | 49 | def heatmap_color_for(value, type) 50 | n = (255.0 * value).floor 51 | if type == 'death' 52 | r = 255 - n 53 | g = 255 - n 54 | b = 255 - n 55 | elsif type == 'cured' 56 | r = 255 - n 57 | g = 255 58 | b = 255 - n 59 | else 60 | r = 255 61 | g = 255 - n 62 | b = 255 - n 63 | end 64 | 65 | color = ['rgb(', r, ',', g, ',', b, ')'].join('') 66 | Chroma.paint(color).to_hex 67 | end 68 | 69 | data = CSV.read('corona.cases.csv', col_sep: "\t", converters: %i[numeric]) 70 | 71 | total = 0 72 | foreign = 0 73 | cured = 0 74 | death = 0 75 | data.each do |e| 76 | total = e[2] if total < e[2] 77 | foreign = e[3] if foreign < e[3] 78 | cured = e[4] if cured < e[4] 79 | death = e[5] if death < e[5] 80 | end 81 | 82 | json = [] 83 | colormap = { 84 | 'total' => { "fills": { defaultFill: 'white' }, "states": {} }, 85 | 'cured' => { "fills": { defaultFill: 'white' }, "states": {} }, 86 | 'death' => { "fills": { defaultFill: 'white' }, "states": {} } 87 | } 88 | 89 | MAX = { 'total' => total, 'cured' => cured, 'death' => death } 90 | 91 | data.each do |e| 92 | [['total', 2], ['cured', 4], ['death', 5]].each do |type| 93 | color = heatmap_color_for(1.0 * e[type.last] / MAX[type.first], type.first) 94 | colormap[type.first][:states][INDIAN_STATES.key(e[1])] = { 95 | fillKey: color, 96 | info: [ 97 | e[2], 98 | (100.0 * e[2] / total).round(2), 99 | e[3], 100 | (100.0 * e[3] / foreign).round(2), 101 | e[4], 102 | (100.0 * e[4] / cured).round(2), 103 | e[5], 104 | (100.0 * e[5] / death.round(2)) 105 | ] 106 | } 107 | colormap[type.first][:fills][color] = color 108 | end 109 | 110 | json << 111 | { 112 | centered: INDIAN_STATES.key(e[1]), 113 | radius: 1.0 + (30 * e[2] / total).round(2), 114 | state: e[1], 115 | info: [ 116 | e[2], 117 | (100.0 * e[2] / total).round(2), 118 | e[3], 119 | (100.0 * e[3] / foreign).round(2), 120 | e[4], 121 | (100.0 * e[4] / cured).round(2), 122 | e[5], 123 | (100.0 * e[5] / death.round(2)) 124 | ] 125 | } 126 | end 127 | 128 | out = File.open('corona_status.json', 'w') 129 | out.puts JSON.generate(json) 130 | out.close 131 | 132 | out = File.open('corona_status.color.json', 'w') 133 | out.puts JSON.generate(colormap) 134 | out.close 135 | -------------------------------------------------------------------------------- /corona_status.color.json: -------------------------------------------------------------------------------- 1 | {"total":{"fills":{"defaultFill":"white","#ffebeb":"#ffebeb","#fffafa":"#fffafa","#fffdfd":"#fffdfd","#ffa8a8":"#ffa8a8","#ffaaaa":"#ffaaaa","#ffdcdc":"#ffdcdc","#fff7f7":"#fff7f7","#ff9393":"#ff9393","#ff0000":"#ff0000","#ff0909":"#ff0909","#ffc2c2":"#ffc2c2","#ffa5a5":"#ffa5a5","#ffe2e2":"#ffe2e2","#ffbfbf":"#ffbfbf","#ffeeee":"#ffeeee","#fff4f4":"#fff4f4","#ffd9d9":"#ffd9d9","#ffa2a2":"#ffa2a2"},"states":{"AP":{"fillKey":"#ffebeb","info":[7,8.05,0,0.0,0,0.0,0,0.0]},"BR":{"fillKey":"#fffafa","info":[2,2.3,0,0.0,0,0.0,1,50.0]},"CT":{"fillKey":"#fffdfd","info":[1,1.15,0,0.0,0,0.0,0,0.0]},"DL":{"fillKey":"#ffa8a8","info":[30,34.48,1,7.14,6,54.55,1,50.0]},"GJ":{"fillKey":"#ffaaaa","info":[29,33.33,0,0.0,0,0.0,1,50.0]},"HR":{"fillKey":"#ffdcdc","info":[12,13.79,14,100.0,11,100.0,0,0.0]},"HP":{"fillKey":"#fff7f7","info":[3,3.45,0,0.0,0,0.0,1,50.0]},"KA":{"fillKey":"#ff9393","info":[37,42.53,0,0.0,2,18.18,1,50.0]},"KL":{"fillKey":"#ff0000","info":[87,100.0,8,57.14,4,36.36,0,0.0]},"MP":{"fillKey":"#ffebeb","info":[7,8.05,0,0.0,0,0.0,0,0.0]},"MH":{"fillKey":"#ff0909","info":[84,96.55,3,21.43,0,0.0,2,100.0]},"OD":{"fillKey":"#fffafa","info":[2,2.3,0,0.0,0,0.0,0,0.0]},"PY":{"fillKey":"#fffdfd","info":[1,1.15,0,0.0,0,0.0,0,0.0]},"PB":{"fillKey":"#ffc2c2","info":[21,24.14,0,0.0,0,0.0,1,50.0]},"RJ":{"fillKey":"#ffa5a5","info":[31,35.63,2,14.29,3,27.27,0,0.0]},"TN":{"fillKey":"#ffe2e2","info":[10,11.49,2,14.29,1,9.09,0,0.0]},"TS":{"fillKey":"#ffbfbf","info":[22,25.29,10,71.43,1,9.09,0,0.0]},"CH":{"fillKey":"#ffeeee","info":[6,6.9,0,0.0,0,0.0,0,0.0]},"JK":{"fillKey":"#fff4f4","info":[4,4.6,0,0.0,0,0.0,0,0.0]},"LK":{"fillKey":"#ffd9d9","info":[13,14.94,0,0.0,0,0.0,0,0.0]},"UP":{"fillKey":"#ffa2a2","info":[32,36.78,1,7.14,9,81.82,0,0.0]},"UK":{"fillKey":"#fff7f7","info":[3,3.45,0,0.0,0,0.0,0,0.0]},"WB":{"fillKey":"#ffebeb","info":[7,8.05,0,0.0,0,0.0,1,50.0]}}},"cured":{"fills":{"defaultFill":"white","#ffffff":"#ffffff","#74ff74":"#74ff74","#00ff00":"#00ff00","#d1ffd1":"#d1ffd1","#a3ffa3":"#a3ffa3","#baffba":"#baffba","#e8ffe8":"#e8ffe8","#2fff2f":"#2fff2f"},"states":{"AP":{"fillKey":"#ffffff","info":[7,8.05,0,0.0,0,0.0,0,0.0]},"BR":{"fillKey":"#ffffff","info":[2,2.3,0,0.0,0,0.0,1,50.0]},"CT":{"fillKey":"#ffffff","info":[1,1.15,0,0.0,0,0.0,0,0.0]},"DL":{"fillKey":"#74ff74","info":[30,34.48,1,7.14,6,54.55,1,50.0]},"GJ":{"fillKey":"#ffffff","info":[29,33.33,0,0.0,0,0.0,1,50.0]},"HR":{"fillKey":"#00ff00","info":[12,13.79,14,100.0,11,100.0,0,0.0]},"HP":{"fillKey":"#ffffff","info":[3,3.45,0,0.0,0,0.0,1,50.0]},"KA":{"fillKey":"#d1ffd1","info":[37,42.53,0,0.0,2,18.18,1,50.0]},"KL":{"fillKey":"#a3ffa3","info":[87,100.0,8,57.14,4,36.36,0,0.0]},"MP":{"fillKey":"#ffffff","info":[7,8.05,0,0.0,0,0.0,0,0.0]},"MH":{"fillKey":"#ffffff","info":[84,96.55,3,21.43,0,0.0,2,100.0]},"OD":{"fillKey":"#ffffff","info":[2,2.3,0,0.0,0,0.0,0,0.0]},"PY":{"fillKey":"#ffffff","info":[1,1.15,0,0.0,0,0.0,0,0.0]},"PB":{"fillKey":"#ffffff","info":[21,24.14,0,0.0,0,0.0,1,50.0]},"RJ":{"fillKey":"#baffba","info":[31,35.63,2,14.29,3,27.27,0,0.0]},"TN":{"fillKey":"#e8ffe8","info":[10,11.49,2,14.29,1,9.09,0,0.0]},"TS":{"fillKey":"#e8ffe8","info":[22,25.29,10,71.43,1,9.09,0,0.0]},"CH":{"fillKey":"#ffffff","info":[6,6.9,0,0.0,0,0.0,0,0.0]},"JK":{"fillKey":"#ffffff","info":[4,4.6,0,0.0,0,0.0,0,0.0]},"LK":{"fillKey":"#ffffff","info":[13,14.94,0,0.0,0,0.0,0,0.0]},"UP":{"fillKey":"#2fff2f","info":[32,36.78,1,7.14,9,81.82,0,0.0]},"UK":{"fillKey":"#ffffff","info":[3,3.45,0,0.0,0,0.0,0,0.0]},"WB":{"fillKey":"#ffffff","info":[7,8.05,0,0.0,0,0.0,1,50.0]}}},"death":{"fills":{"defaultFill":"white","#ffffff":"#ffffff","#808080":"#808080","#000000":"#000000"},"states":{"AP":{"fillKey":"#ffffff","info":[7,8.05,0,0.0,0,0.0,0,0.0]},"BR":{"fillKey":"#808080","info":[2,2.3,0,0.0,0,0.0,1,50.0]},"CT":{"fillKey":"#ffffff","info":[1,1.15,0,0.0,0,0.0,0,0.0]},"DL":{"fillKey":"#808080","info":[30,34.48,1,7.14,6,54.55,1,50.0]},"GJ":{"fillKey":"#808080","info":[29,33.33,0,0.0,0,0.0,1,50.0]},"HR":{"fillKey":"#ffffff","info":[12,13.79,14,100.0,11,100.0,0,0.0]},"HP":{"fillKey":"#808080","info":[3,3.45,0,0.0,0,0.0,1,50.0]},"KA":{"fillKey":"#808080","info":[37,42.53,0,0.0,2,18.18,1,50.0]},"KL":{"fillKey":"#ffffff","info":[87,100.0,8,57.14,4,36.36,0,0.0]},"MP":{"fillKey":"#ffffff","info":[7,8.05,0,0.0,0,0.0,0,0.0]},"MH":{"fillKey":"#000000","info":[84,96.55,3,21.43,0,0.0,2,100.0]},"OD":{"fillKey":"#ffffff","info":[2,2.3,0,0.0,0,0.0,0,0.0]},"PY":{"fillKey":"#ffffff","info":[1,1.15,0,0.0,0,0.0,0,0.0]},"PB":{"fillKey":"#808080","info":[21,24.14,0,0.0,0,0.0,1,50.0]},"RJ":{"fillKey":"#ffffff","info":[31,35.63,2,14.29,3,27.27,0,0.0]},"TN":{"fillKey":"#ffffff","info":[10,11.49,2,14.29,1,9.09,0,0.0]},"TS":{"fillKey":"#ffffff","info":[22,25.29,10,71.43,1,9.09,0,0.0]},"CH":{"fillKey":"#ffffff","info":[6,6.9,0,0.0,0,0.0,0,0.0]},"JK":{"fillKey":"#ffffff","info":[4,4.6,0,0.0,0,0.0,0,0.0]},"LK":{"fillKey":"#ffffff","info":[13,14.94,0,0.0,0,0.0,0,0.0]},"UP":{"fillKey":"#ffffff","info":[32,36.78,1,7.14,9,81.82,0,0.0]},"UK":{"fillKey":"#ffffff","info":[3,3.45,0,0.0,0,0.0,0,0.0]},"WB":{"fillKey":"#808080","info":[7,8.05,0,0.0,0,0.0,1,50.0]}}}} 2 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |