diff --git a/package.json b/package.json index 370d37a1b06..f078f74f983 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "start-test_dashboard": "node devtools/test_dashboard/server.js", "start-image_viewer": "node devtools/image_viewer/server.js", "baseline": "./tasks/baseline.sh", - "version": "npm run build && git add -A dist", + "version": "npm run build && git add -A dist src", "postversion": "git push && git push --tags" }, "dependencies": { @@ -54,7 +54,7 @@ "gl-line2d": "^1.2.1", "gl-line3d": "^1.0.1", "gl-mat4": "^1.1.2", - "gl-mesh3d": "^1.0.4", + "gl-mesh3d": "^1.0.7", "gl-plot2d": "^1.1.6", "gl-plot3d": "^1.3.0", "gl-scatter2d": "^1.0.5", @@ -62,7 +62,7 @@ "gl-scatter3d": "^1.0.4", "gl-select-box": "^1.0.1", "gl-spikes2d": "^1.0.1", - "gl-surface3d": "^1.1.0", + "gl-surface3d": "^1.1.1", "mouse-change": "^1.1.1", "mouse-wheel": "^1.0.2", "ndarray": "^1.0.16", diff --git a/src/assets/geo_assets.js b/src/assets/geo_assets.js index 49c1fec46fa..aa5fdc3e142 100644 --- a/src/assets/geo_assets.js +++ b/src/assets/geo_assets.js @@ -11,7 +11,7 @@ var saneTopojson = require('sane-topojson'); -// export the version found in the package.json -exports.version = require('../../package.json').version; +// package version injected by `npm run preprocess` +exports.version = '1.4.1'; exports.topojson = saneTopojson; diff --git a/src/constants/country-name_to_iso3.js b/src/constants/country-name_to_iso3.js new file mode 100644 index 00000000000..493ce1d2d00 --- /dev/null +++ b/src/constants/country-name_to_iso3.js @@ -0,0 +1,268 @@ +/** +* Copyright 2012-2016, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + +module.exports = { + DZA: 'algeria', + AGO: 'angola', + EGY: 'egypt', + BGD: 'bangladesh|^(?=.*east).*paki?stan', + NER: '\\bniger(?!ia)', + LIE: 'liechtenstein', + NAM: 'namibia', + BGR: 'bulgaria', + BOL: 'bolivia', + GHA: 'ghana|gold.?coast', + CCK: '\\bcocos|keeling', + PAK: '^(?!.*east).*paki?stan', + CPV: 'verde', + JOR: 'jordan', + LBR: 'liberia', + LBY: 'libya', + MYS: 'malaysia', + IOT: 'british.?indian.?ocean', + PRI: 'puerto.?rico', + MYT: 'mayotte', + PRK: '^(?=.*democrat).*\\bkorea|^(?=.*people).*\\bkorea|^(?=.*north).*\\bkorea|\\bd\\.?p\\.?r\\.?k', + PSE: 'palestin|\\bgaza|west.?bank', + TZA: 'tanzania', + BWA: 'botswana|bechuana', + KHM: 'cambodia|kampuchea|khmer|^p\\.?r\\.?k\\.?$', + UMI: 'minor.?outlying.?is', + TTO: 'trinidad|tobago', + PRY: 'paraguay', + HKG: 'hong.?kong', + SAU: '\\bsa\\w*.?arabia', + LBN: 'lebanon', + SVN: 'slovenia', + BFA: 'burkina|\\bfaso|upper.?volta', + SVK: '^(?!.*cze).*slovak', + MRT: 'mauritania', + HRV: 'croatia', + CHL: '\\bchile', + CHN: '^(?!.*\\bmac)(?!.*\\bhong)(?!.*\\btai).*china|^p\\.?r\\.?c\\.?$', + KNA: 'kitts|\\bnevis', + JAM: 'jamaica', + SMR: 'san.?marino', + GIB: 'gibraltar', + DJI: 'djibouti', + GIN: '^(?!.*eq)(?!.*span)(?!.*bissau)(?!.*portu)(?!.*new).*guinea', + FIN: 'finland', + URY: 'uruguay', + VAT: 'holy.?see|vatican|papal.?st', + STP: '\\bs(a|ã)o.?tom(e|é)', + SYC: 'seychell', + NPL: 'nepal', + CXR: 'christmas', + LAO: '\\blaos?\\b', + YEM: '^(?!.*arab)(?!.*north)(?!.*sana)(?!.*peo)(?!.*dem)(?!.*south)(?!.*aden)(?!.*\\bp\\.?d\\.?r).*yemen', + BVT: 'bouvet', + ZAF: '\\bs\\w*.?africa', + KIR: 'kiribati', + PHL: 'philippines', + SXM: '^(?!.*martin)(?!.*saba).*maarten', + ROU: 'r(o|u|ou)mania', + VIR: '^(?=.*\\bu\\.?\\s?s).*virgin|^(?=.*states).*virgin', + SYR: 'syria', + MAC: 'maca(o|u)', + NFK: 'norfolk', + NIC: 'nicaragua', + MLT: '\\bmalta', + KAZ: 'kazak', + TCA: 'turks', + PYF: 'french.?polynesia|tahiti', + NIU: 'niue', + DMA: 'dominica(?!n)', + GBR: 'united.?kingdom|britain|^u\\.?k\\.?$', + BEN: 'benin|dahome', + GUF: '^(?=.*french).*guiana', + BEL: '^(?!.*luxem).*belgium', + MSR: 'montserrat', + TGO: 'togo', + DEU: '^(?!.*east).*germany|^(?=.*\\bfed.*\\brep).*german', + GUM: '\\bguam', + LKA: 'sri.?lanka|ceylon', + SSD: '\\bs\\w*.?sudan', + FLK: 'falkland|malvinas', + PCN: 'pitcairn', + BES: '^(?=.*bonaire).*eustatius|^(?=.*carib).*netherlands|\\bbes.?islands', + GUY: 'guyana|british.?guiana', + CRI: 'costa.?rica', + COK: '\\bcook', + MAR: 'morocco|\\bmaroc', + MNP: 'mariana', + LSO: 'lesotho|basuto', + HUN: '^(?!.*austr).*hungary', + TKM: 'turkmen', + SUR: 'surinam|dutch.?guiana', + NLD: '^(?!.*\\bant)(?!.*\\bcarib).*netherlands', + BMU: 'bermuda', + HMD: 'heard.*mcdonald', + TCD: '\\bchad', + GEO: '^(?!.*south).*georgia', + MNE: '^(?!.*serbia).*montenegro', + MNG: 'mongolia', + MHL: 'marshall', + MTQ: 'martinique', + CSK: 'czechoslovakia', + BLZ: 'belize|^(?=.*british).*honduras', + DDR: 'german.?democratic.?republic|^(d|g)\\.?d\\.?r\\.?$|^(?=.*east).*germany', + MMR: 'myanmar|burma', + AFG: 'afghan', + BDI: 'burundi', + VGB: '^(?=.*\\bu\\.?\\s?k).*virgin|^(?=.*brit).*virgin|^(?=.*kingdom).*virgin', + BLR: 'belarus|byelo', + BLM: 'barth(e|é)lemy', + GRD: 'grenada', + TKL: 'tokelau', + GRC: 'greece|hellenic|hellas', + GRL: 'greenland', + SHN: 'helena', + AND: 'andorra', + MOZ: 'mozambique', + TJK: 'tajik', + THA: 'thailand|\\bsiam', + HTI: 'haiti', + MEX: '\\bmexic', + ANT: '^(?=.*\\bant).*(nether|dutch)', + ZWE: 'zimbabwe|^(?!.*northern).*rhodesia', + LCA: '\\blucia', + IND: 'india(?!.*ocea)', + LVA: 'latvia', + BTN: 'bhutan', + VCT: 'vincent', + VNM: '^(?!.*republic).*viet.?nam|^(?=.*socialist).*viet.?nam', + NOR: 'norway', + CZE: '^(?=.*rep).*czech|czechia|bohemia', + ATF: 'french.?southern|\\bfr.*\\bso.*\\ban.*\\b\\bt', + ATG: 'antigua', + FJI: 'fiji', + HND: '^(?!.*brit).*honduras', + MUS: 'mauritius', + DOM: 'dominican', + LUX: '^(?!.*belg).*luxem', + ISR: 'israel', + YUG: 'yugoslavia', + FSM: 'micronesia', + PER: 'peru', + REU: 'r(e|é)union', + IDN: 'indonesia', + VUT: 'vanuatu|new.?hebrides', + MKD: 'macedonia|^f\\.?y\\.?r\\.?o\\.?m\\.?$', + COD: '\\bdem.*congo|congo.*\\bdem|congo.*\\bdr|\\bdr.*congo|\\bd\\.?r\\.?c|\\bd\\.?r\\.?o\\.?c|\\br\\.?d\\.?c|belgian.?congo|congo.?free.?state|kinshasa|zaire|l\\w{1,2}opoldville', + COG: '^(?!.*\\bdem)(?!.*\\bdr)(?!.*kinshasa)(?!.*zaire)(?!.*belg)(?!.*l\\w{1,2}opoldville)(?!.*free).*\\bcongo', + ISL: 'iceland', + GLP: 'guadeloupe', + ETH: 'ethiopia|abyssinia', + COM: 'comoro', + COL: 'colombia', + NGA: 'nigeria', + TLS: '^(?=.*leste).*timor|^(?=.*east).*timor', + TWN: 'taiwan|taipei|formosa', + PRT: 'portugal', + MDA: 'moldov|b(a|e)ssarabia', + GGY: 'guernsey', + MDG: 'madagascar|malagasy', + ATA: 'antarctica', + ECU: 'ecuador', + SEN: 'senegal', + ESH: 'sahara', + MDV: 'maldive', + ASM: '^(?=.*americ).*samoa', + SPM: 'miquelon', + CUW: '^(?!.*bonaire).*\\bcura(c|ç)ao', + FRA: '^(?!.*\\bdep)(?!.*martinique).*france|french.?republic|\\bgaul', + LTU: 'lithuania', + RWA: 'rwanda', + ZMB: 'zambia|northern.?rhodesia', + GMB: 'gambia', + WLF: 'futuna|wallis', + JEY: 'jersey', + FRO: 'faroe|faeroe', + GTM: 'guatemala', + DNK: 'denmark', + IMN: '^(?=.*isle).*\\bman', + MAF: '^(?=.*collectivity).*martin|^(?=.*france).*martin(?!ique)|^(?=.*french).*martin(?!ique)', + AUS: 'australia', + AUT: '^(?!.*hungary).*austria|\\baust.*\\bemp', + SJM: 'svalbard', + VEN: 'venezuela', + PLW: 'palau', + KEN: 'kenya|british.?east.?africa|east.?africa.?prot', + TUR: 'turkey', + ALB: 'albania', + OMN: '\\boman|trucial', + TUV: 'tuvalu', + ALA: '\\b(a|å)land', + BRN: 'brunei', + TUN: 'tunisia', + RUS: '\\brussia|soviet.?union|u\\.?s\\.?s\\.?r|socialist.?republics', + BRB: 'barbados', + BRA: 'brazil', + CIV: 'ivoire|ivory', + SRB: '^(?!.*monte).*serbia', + GNQ: 'guine.*eq|eq.*guine|^(?=.*span).*guinea', + USA: '^(?!.*islands).*united.?states|^u\\.?s\\.?a\\.?$|^u\\.?s\\.?$', + QAT: 'qatar', + WSM: '^(?!.*amer).*samoa', + AZE: 'azerbaijan', + GNB: 'bissau|^(?=.*portu).*guinea', + SWZ: 'swaziland', + TON: 'tonga', + CAN: 'canada', + UKR: 'ukrain', + KOR: '^(?!.*democrat)(?!.*people)(?!.*north).*\\bkorea|\\br\\.?o\\.?k\\b', + AIA: 'anguill?a', + CAF: '\\bcen.*\\baf|^c\\.?a\\.?r\\.?$', + CHE: 'switz|swiss', + CYP: 'cyprus', + BIH: 'herzegovina|bosnia', + SGP: 'singapore', + SGS: 'south.?georgia|sandwich', + SOM: 'somali', + UZB: 'uzbek', + CMR: 'cameroon', + POL: 'poland', + EAZ: 'zanz', + KWT: 'kuwait', + ERI: 'eritrea', + GAB: 'gabon', + CYM: 'cayman', + ARE: 'emirates|^u\\.?a\\.?e\\.?$|united.?arab.?em', + EST: 'estonia', + MWI: 'malawi|nyasa', + ESP: 'spain', + IRQ: '\\biraq|mesopotamia', + SLV: 'el.?salvador', + MLI: '\\bmali\\b', + YMD: '^(?=.*peo).*yemen|^(?!.*rep)(?=.*dem).*yemen|^(?=.*south).*yemen|^(?=.*aden).*yemen|^(?=.*\\bp\\.?d\\.?r).*yemen', + IRL: 'ireland', + IRN: '\\biran|persia', + ABW: '^(?!.*bonaire).*\\baruba', + SLE: 'sierra', + PAN: 'panama', + SDN: '^(?!.*\\bs(?!u)).*sudan', + SLB: 'solomon', + NZL: 'new.?zealand', + MCO: 'monaco', + ITA: 'italy', + JPN: 'japan', + KGZ: 'kyrgyz|kirghiz', + UGA: 'uganda', + NCL: 'new.?caledonia', + PNG: 'papua|\\bp.*\\bn.*\\bguin.*|^p\\.?n\\.?g\\.?$|new.?guinea', + ARG: 'argentin', + SWE: 'sweden', + BHS: 'bahamas', + BHR: 'bahrain', + ARM: 'armenia', + NRU: 'nauru', + CUB: '\\bcuba' +}; diff --git a/src/constants/country-name_to_iso3.json b/src/constants/country-name_to_iso3.json deleted file mode 100644 index 86920182ae6..00000000000 --- a/src/constants/country-name_to_iso3.json +++ /dev/null @@ -1 +0,0 @@ -{"DZA":"algeria","AGO":"angola","EGY":"egypt","BGD":"bangladesh|^(?=.*east).*paki?stan","NER":"\\bniger(?!ia)","LIE":"liechtenstein","NAM":"namibia","BGR":"bulgaria","BOL":"bolivia","GHA":"ghana|gold.?coast","CCK":"\\bcocos|keeling","PAK":"^(?!.*east).*paki?stan","CPV":"verde","JOR":"jordan","LBR":"liberia","LBY":"libya","MYS":"malaysia","IOT":"british.?indian.?ocean","PRI":"puerto.?rico","MYT":"mayotte","PRK":"^(?=.*democrat).*\\bkorea|^(?=.*people).*\\bkorea|^(?=.*north).*\\bkorea|\\bd\\.?p\\.?r\\.?k","PSE":"palestin|\\bgaza|west.?bank","TZA":"tanzania","BWA":"botswana|bechuana","KHM":"cambodia|kampuchea|khmer|^p\\.?r\\.?k\\.?$","UMI":"minor.?outlying.?is","TTO":"trinidad|tobago","PRY":"paraguay","HKG":"hong.?kong","SAU":"\\bsa\\w*.?arabia","LBN":"lebanon","SVN":"slovenia","BFA":"burkina|\\bfaso|upper.?volta","SVK":"^(?!.*cze).*slovak","MRT":"mauritania","HRV":"croatia","CHL":"\\bchile","CHN":"^(?!.*\\bmac)(?!.*\\bhong)(?!.*\\btai).*china|^p\\.?r\\.?c\\.?$","KNA":"kitts|\\bnevis","JAM":"jamaica","SMR":"san.?marino","GIB":"gibraltar","DJI":"djibouti","GIN":"^(?!.*eq)(?!.*span)(?!.*bissau)(?!.*portu)(?!.*new).*guinea","FIN":"finland","URY":"uruguay","VAT":"holy.?see|vatican|papal.?st","STP":"\\bs(a|\u00e3)o.?tom(e|\u00e9)","SYC":"seychell","NPL":"nepal","CXR":"christmas","LAO":"\\blaos?\\b","YEM":"^(?!.*arab)(?!.*north)(?!.*sana)(?!.*peo)(?!.*dem)(?!.*south)(?!.*aden)(?!.*\\bp\\.?d\\.?r).*yemen","BVT":"bouvet","ZAF":"\\bs\\w*.?africa","KIR":"kiribati","PHL":"philippines","SXM":"^(?!.*martin)(?!.*saba).*maarten","ROU":"r(o|u|ou)mania","VIR":"^(?=.*\\bu\\.?\\s?s).*virgin|^(?=.*states).*virgin","SYR":"syria","MAC":"maca(o|u)","NFK":"norfolk","NIC":"nicaragua","MLT":"\\bmalta","KAZ":"kazak","TCA":"turks","PYF":"french.?polynesia|tahiti","NIU":"niue","DMA":"dominica(?!n)","GBR":"united.?kingdom|britain|^u\\.?k\\.?$","BEN":"benin|dahome","GUF":"^(?=.*french).*guiana","BEL":"^(?!.*luxem).*belgium","MSR":"montserrat","TGO":"togo","DEU":"^(?!.*east).*germany|^(?=.*\\bfed.*\\brep).*german","GUM":"\\bguam","LKA":"sri.?lanka|ceylon","SSD":"\\bs\\w*.?sudan","FLK":"falkland|malvinas","PCN":"pitcairn","BES":"^(?=.*bonaire).*eustatius|^(?=.*carib).*netherlands|\\bbes.?islands","GUY":"guyana|british.?guiana","CRI":"costa.?rica","COK":"\\bcook","MAR":"morocco|\\bmaroc","MNP":"mariana","LSO":"lesotho|basuto","HUN":"^(?!.*austr).*hungary","TKM":"turkmen","SUR":"surinam|dutch.?guiana","NLD":"^(?!.*\\bant)(?!.*\\bcarib).*netherlands","BMU":"bermuda","HMD":"heard.*mcdonald","TCD":"\\bchad","GEO":"^(?!.*south).*georgia","MNE":"^(?!.*serbia).*montenegro","MNG":"mongolia","MHL":"marshall","MTQ":"martinique","CSK":"czechoslovakia","BLZ":"belize|^(?=.*british).*honduras","DDR":"german.?democratic.?republic|^(d|g)\\.?d\\.?r\\.?$|^(?=.*east).*germany","MMR":"myanmar|burma","AFG":"afghan","BDI":"burundi","VGB":"^(?=.*\\bu\\.?\\s?k).*virgin|^(?=.*brit).*virgin|^(?=.*kingdom).*virgin","BLR":"belarus|byelo","BLM":"barth(e|\u00e9)lemy","GRD":"grenada","TKL":"tokelau","GRC":"greece|hellenic|hellas","GRL":"greenland","SHN":"helena","AND":"andorra","MOZ":"mozambique","TJK":"tajik","THA":"thailand|\\bsiam","HTI":"haiti","MEX":"\\bmexic","ANT":"^(?=.*\\bant).*(nether|dutch)","ZWE":"zimbabwe|^(?!.*northern).*rhodesia","LCA":"\\blucia","IND":"india(?!.*ocea)","LVA":"latvia","BTN":"bhutan","VCT":"vincent","VNM":"^(?!.*republic).*viet.?nam|^(?=.*socialist).*viet.?nam","NOR":"norway","CZE":"^(?=.*rep).*czech|czechia|bohemia","ATF":"french.?southern|\\bfr.*\\bso.*\\ban.*\\b\\bt","ATG":"antigua","FJI":"fiji","HND":"^(?!.*brit).*honduras","MUS":"mauritius","DOM":"dominican","LUX":"^(?!.*belg).*luxem","ISR":"israel","YUG":"yugoslavia","FSM":"micronesia","PER":"peru","REU":"r(e|\u00e9)union","IDN":"indonesia","VUT":"vanuatu|new.?hebrides","MKD":"macedonia|^f\\.?y\\.?r\\.?o\\.?m\\.?$","COD":"\\bdem.*congo|congo.*\\bdem|congo.*\\bdr|\\bdr.*congo|\\bd\\.?r\\.?c|\\bd\\.?r\\.?o\\.?c|\\br\\.?d\\.?c|belgian.?congo|congo.?free.?state|kinshasa|zaire|l\\w{1,2}opoldville","COG":"^(?!.*\\bdem)(?!.*\\bdr)(?!.*kinshasa)(?!.*zaire)(?!.*belg)(?!.*l\\w{1,2}opoldville)(?!.*free).*\\bcongo","ISL":"iceland","GLP":"guadeloupe","ETH":"ethiopia|abyssinia","COM":"comoro","COL":"colombia","NGA":"nigeria","TLS":"^(?=.*leste).*timor|^(?=.*east).*timor","TWN":"taiwan|taipei|formosa","PRT":"portugal","MDA":"moldov|b(a|e)ssarabia","GGY":"guernsey","MDG":"madagascar|malagasy","ATA":"antarctica","ECU":"ecuador","SEN":"senegal","ESH":"sahara","MDV":"maldive","ASM":"^(?=.*americ).*samoa","SPM":"miquelon","CUW":"^(?!.*bonaire).*\\bcura(c|\u00e7)ao","FRA":"^(?!.*\\bdep)(?!.*martinique).*france|french.?republic|\\bgaul","LTU":"lithuania","RWA":"rwanda","ZMB":"zambia|northern.?rhodesia","GMB":"gambia","WLF":"futuna|wallis","JEY":"jersey","FRO":"faroe|faeroe","GTM":"guatemala","DNK":"denmark","IMN":"^(?=.*isle).*\\bman","MAF":"^(?=.*collectivity).*martin|^(?=.*france).*martin(?!ique)|^(?=.*french).*martin(?!ique)","AUS":"australia","AUT":"^(?!.*hungary).*austria|\\baust.*\\bemp","SJM":"svalbard","VEN":"venezuela","PLW":"palau","KEN":"kenya|british.?east.?africa|east.?africa.?prot","TUR":"turkey","ALB":"albania","OMN":"\\boman|trucial","TUV":"tuvalu","ALA":"\\b(a|\u00e5)land","BRN":"brunei","TUN":"tunisia","RUS":"\\brussia|soviet.?union|u\\.?s\\.?s\\.?r|socialist.?republics","BRB":"barbados","BRA":"brazil","CIV":"ivoire|ivory","SRB":"^(?!.*monte).*serbia","GNQ":"guine.*eq|eq.*guine|^(?=.*span).*guinea","USA":"^(?!.*islands).*united.?states|^u\\.?s\\.?a\\.?$|^u\\.?s\\.?$","QAT":"qatar","WSM":"^(?!.*amer).*samoa","AZE":"azerbaijan","GNB":"bissau|^(?=.*portu).*guinea","SWZ":"swaziland","TON":"tonga","CAN":"canada","UKR":"ukrain","KOR":"^(?!.*democrat)(?!.*people)(?!.*north).*\\bkorea|\\br\\.?o\\.?k\\b","AIA":"anguill?a","CAF":"\\bcen.*\\baf|^c\\.?a\\.?r\\.?$","CHE":"switz|swiss","CYP":"cyprus","BIH":"herzegovina|bosnia","SGP":"singapore","SGS":"south.?georgia|sandwich","SOM":"somali","UZB":"uzbek","CMR":"cameroon","POL":"poland","EAZ":"zanz","KWT":"kuwait","ERI":"eritrea","GAB":"gabon","CYM":"cayman","ARE":"emirates|^u\\.?a\\.?e\\.?$|united.?arab.?em","EST":"estonia","MWI":"malawi|nyasa","ESP":"spain","IRQ":"\\biraq|mesopotamia","SLV":"el.?salvador","MLI":"\\bmali\\b","YMD":"^(?=.*peo).*yemen|^(?!.*rep)(?=.*dem).*yemen|^(?=.*south).*yemen|^(?=.*aden).*yemen|^(?=.*\\bp\\.?d\\.?r).*yemen","IRL":"ireland","IRN":"\\biran|persia","ABW":"^(?!.*bonaire).*\\baruba","SLE":"sierra","PAN":"panama","SDN":"^(?!.*\\bs(?!u)).*sudan","SLB":"solomon","NZL":"new.?zealand","MCO":"monaco","ITA":"italy","JPN":"japan","KGZ":"kyrgyz|kirghiz","UGA":"uganda","NCL":"new.?caledonia","PNG":"papua|\\bp.*\\bn.*\\bguin.*|^p\\.?n\\.?g\\.?$|new.?guinea","ARG":"argentin","SWE":"sweden","BHS":"bahamas","BHR":"bahrain","ARM":"armenia","NRU":"nauru","CUB":"\\bcuba"} \ No newline at end of file diff --git a/src/constants/gl2d_dashes.js b/src/constants/gl2d_dashes.js new file mode 100644 index 00000000000..3a8609ccac8 --- /dev/null +++ b/src/constants/gl2d_dashes.js @@ -0,0 +1,19 @@ +/** +* Copyright 2012-2016, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + +module.exports = { + solid: [1], + dot: [1, 1], + dash: [4, 1], + longdash: [8, 1], + dashdot: [4, 1, 1, 1], + longdashdot: [8, 1, 1, 1] +}; diff --git a/src/constants/gl2d_dashes.json b/src/constants/gl2d_dashes.json deleted file mode 100644 index 7b8e62a6be1..00000000000 --- a/src/constants/gl2d_dashes.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "solid": [1], - "dot": [1,1], - "dash": [4,1], - "longdash": [8,1], - "dashdot": [4,1,1,1], - "longdashdot": [8,1,1,1] -} diff --git a/src/constants/gl3d_dashes.js b/src/constants/gl3d_dashes.js new file mode 100644 index 00000000000..137c931e52c --- /dev/null +++ b/src/constants/gl3d_dashes.js @@ -0,0 +1,19 @@ +/** +* Copyright 2012-2016, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + +module.exports = { + solid: [[], 0], + dot: [[0.5, 1], 200], + dash: [[0.5, 1], 50], + longdash: [[0.5, 1], 10], + dashdot: [[0.5, 0.625, 0.875, 1], 50], + longdashdot: [[0.5, 0.7, 0.8, 1], 10] +}; diff --git a/src/constants/gl3d_dashes.json b/src/constants/gl3d_dashes.json deleted file mode 100644 index 08e999994f5..00000000000 --- a/src/constants/gl3d_dashes.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "solid": [[], 0], - "dot": [[0.5,1], 200], - "dash": [[0.5,1], 50], - "longdash": [[0.5,1], 10], - "dashdot": [[0.5,0.625,0.875,1], 50], - "longdashdot": [[0.5,0.7,0.8,1], 10] -} \ No newline at end of file diff --git a/src/constants/gl_markers.js b/src/constants/gl_markers.js new file mode 100644 index 00000000000..d7c5504b03e --- /dev/null +++ b/src/constants/gl_markers.js @@ -0,0 +1,21 @@ +/** +* Copyright 2012-2016, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + +module.exports = { + circle: '●', + 'circle-open': '○', + square: '■', + 'square-open': '□', + diamond: '◆', + 'diamond-open': '◇', + cross: '+', + x: '❌' +}; diff --git a/src/constants/gl_markers.json b/src/constants/gl_markers.json deleted file mode 100644 index 393faec6043..00000000000 --- a/src/constants/gl_markers.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "circle": "●", - "circle-open": "○", - "square": "■", - "square-open": "□", - "diamond": "◆", - "diamond-open": "◇", - "cross": "+", - "x": "❌" -} diff --git a/src/index.js b/src/index.js index 22f621b601d..7c32c585055 100644 --- a/src/index.js +++ b/src/index.js @@ -17,8 +17,8 @@ var Plotly = require('./plotly'); -// export the version found in the package.json -exports.version = require('../package.json').version; +// package version injected by `npm run preprocess` +exports.version = '1.4.1'; // plot api exports.plot = Plotly.plot; diff --git a/src/lib/geo_location_utils.js b/src/lib/geo_location_utils.js index 62dd9ed350d..91077d14e29 100644 --- a/src/lib/geo_location_utils.js +++ b/src/lib/geo_location_utils.js @@ -14,7 +14,7 @@ var locationUtils = module.exports = {}; var Plotly = require('../plotly'); // an hash object iso3 to regex string -var countryNameData = require('../constants/country-name_to_iso3.json'); +var countryNameData = require('../constants/country-name_to_iso3'); // make list of all country iso3 ids from at runtime var countryIds = Object.keys(countryNameData); diff --git a/src/traces/scatter3d/attributes.js b/src/traces/scatter3d/attributes.js index 4c4a5319da7..af468e3196f 100644 --- a/src/traces/scatter3d/attributes.js +++ b/src/traces/scatter3d/attributes.js @@ -10,7 +10,7 @@ 'use strict'; var scatterAttrs = require('../scatter/attributes'); -var MARKER_SYMBOLS = require('../../constants/gl_markers.json'); +var MARKER_SYMBOLS = require('../../constants/gl_markers'); var extendFlat = require('../../lib/extend').extendFlat; var scatterLineAttrs = scatterAttrs.line, diff --git a/src/traces/scatter3d/convert.js b/src/traces/scatter3d/convert.js index 580de599d52..def340e4e46 100644 --- a/src/traces/scatter3d/convert.js +++ b/src/traces/scatter3d/convert.js @@ -19,9 +19,8 @@ var Lib = require('../../lib'); var str2RgbaArray = require('../../lib/str2rgbarray'); var formatColor = require('../../lib/gl_format_color'); var makeBubbleSizeFn = require('../scatter/make_bubble_size_func'); - -var DASH_PATTERNS = require('../../constants/gl3d_dashes.json'); -var MARKER_SYMBOLS = require('../../constants/gl_markers.json'); +var DASH_PATTERNS = require('../../constants/gl3d_dashes'); +var MARKER_SYMBOLS = require('../../constants/gl_markers'); var calculateError = require('./calc_errors'); diff --git a/src/traces/scatter3d/index.js b/src/traces/scatter3d/index.js index fd866886a83..11d9fa46a48 100644 --- a/src/traces/scatter3d/index.js +++ b/src/traces/scatter3d/index.js @@ -12,7 +12,7 @@ var Scatter3D = {}; Scatter3D.plot = require('./convert'); Scatter3D.attributes = require('./attributes'); -Scatter3D.markerSymbols = require('../../constants/gl_markers.json'); +Scatter3D.markerSymbols = require('../../constants/gl_markers'); Scatter3D.supplyDefaults = require('./defaults'); Scatter3D.colorbar = require('../scatter/colorbar'); Scatter3D.calc = require('./calc'); diff --git a/src/traces/scattergl/attributes.js b/src/traces/scattergl/attributes.js index a012ecbac4c..31008d79120 100644 --- a/src/traces/scattergl/attributes.js +++ b/src/traces/scattergl/attributes.js @@ -9,8 +9,8 @@ 'use strict'; var scatterAttrs = require('../scatter/attributes'); -var DASHES = require('../../constants/gl2d_dashes.json'); -var MARKERS = require('../../constants/gl_markers.json'); +var DASHES = require('../../constants/gl2d_dashes'); +var MARKERS = require('../../constants/gl_markers'); var extendFlat = require('../../lib/extend').extendFlat; var scatterLineAttrs = scatterAttrs.line, diff --git a/src/traces/scattergl/convert.js b/src/traces/scattergl/convert.js index 13e77ac90e1..892841c76a4 100644 --- a/src/traces/scattergl/convert.js +++ b/src/traces/scattergl/convert.js @@ -24,9 +24,9 @@ var formatColor = require('../../lib/gl_format_color'); var subTypes = require('../scatter/subtypes'); var makeBubbleSizeFn = require('../scatter/make_bubble_size_func'); var getTraceColor = require('../scatter/get_trace_color'); +var MARKER_SYMBOLS = require('../../constants/gl_markers'); +var DASHES = require('../../constants/gl2d_dashes'); -var MARKER_SYMBOLS = require('../../constants/gl_markers.json'); -var DASHES = require('../../constants/gl2d_dashes.json'); var AXES = ['xaxis', 'yaxis']; diff --git a/tasks/header.js b/tasks/header.js index baf7dbdfdf9..1d1566f47e0 100644 --- a/tasks/header.js +++ b/tasks/header.js @@ -43,6 +43,11 @@ glob(path.join(constants.pathToSrc, '**/*.js'), function(err, files) { var header = comments[0]; + // error out if no header is found + if(!header || header.loc.start.line > 1) { + throw new Error(file + ' : has no header information.'); + } + // if header and license are the same, do nothing if(isCorrect(header)) return; diff --git a/tasks/preprocess.js b/tasks/preprocess.js index 32a53265c3a..c6819d19019 100644 --- a/tasks/preprocess.js +++ b/tasks/preprocess.js @@ -4,6 +4,7 @@ var sass = require('node-sass'); var pullCSS = require('./util/pull_css'); var pullFontSVG = require('./util/pull_font_svg'); +var updateVersion = require('./util/update_version'); var constants = require('./util/constants'); @@ -28,3 +29,7 @@ fs.copy(constants.pathToTopojsonSrc, constants.pathToTopojsonDist, { clobber: true }, function(err) { if(err) throw err; } ); + +// inject package version into source index files +updateVersion(constants.pathToPlotlySrc); +updateVersion(constants.pathToPlotlyGeoAssetsSrc); diff --git a/tasks/util/update_version.js b/tasks/util/update_version.js new file mode 100644 index 00000000000..96e36e16d49 --- /dev/null +++ b/tasks/util/update_version.js @@ -0,0 +1,30 @@ +var fs = require('fs'); + +var falafel = require('falafel'); + +var pkg = require('../../package.json'); + + +module.exports = function updateVersion(pathToFile) { + fs.readFile(pathToFile, 'utf-8', function(err, code) { + var out = falafel(code, function(node) { + if(isVersionNode(node)) node.update('\'' + pkg.version + '\''); + }); + + fs.writeFile(pathToFile, out, function(err) { + if(err) throw err; + }); + }); +}; + +function isVersionNode(node) { + return ( + node.type === 'Literal' && + node.parent && + node.parent.type === 'AssignmentExpression' && + node.parent.left && + node.parent.left.object && + node.parent.left.property && + node.parent.left.property.name === 'version' + ); +} diff --git a/test/jasmine/tests/plot_api_test.js b/test/jasmine/tests/plot_api_test.js index 8deb46899af..de3a660ce80 100644 --- a/test/jasmine/tests/plot_api_test.js +++ b/test/jasmine/tests/plot_api_test.js @@ -1,12 +1,22 @@ -var Plotly = require('@src/plotly'); +var Plotly = require('@src'); +var PlotlyInternal = require('@src/plotly'); var Plots = require('@src/plots/plots'); +var Lib = require('@src/lib'); var Scatter = require('@src/traces/scatter'); var Bar = require('@src/traces/bar'); var Legend = require('@src/components/legend'); +var pkg = require('../../../package.json'); -describe('Test graph_obj', function() { + +describe('Test plot api', function() { 'use strict'; + describe('Plotly.version', function() { + it('should be the same as in the package.json', function() { + expect(Plotly.version).toEqual(pkg.version); + }); + }); + describe('Plotly.restyle', function() { beforeEach(function() { spyOn(Plotly, 'plot'); @@ -67,7 +77,7 @@ describe('Test graph_obj', function() { {'name': 'd'} ] }; - spyOn(Plotly, 'redraw'); + spyOn(PlotlyInternal, 'redraw'); }); it('should throw an error when indices are omitted', function() { @@ -103,7 +113,7 @@ describe('Test graph_obj', function() { Plotly.deleteTraces(gd, -1); expect(gd.data).toEqual(expectedData); - expect(Plotly.redraw).toHaveBeenCalled(); + expect(PlotlyInternal.redraw).toHaveBeenCalled(); }); @@ -115,7 +125,7 @@ describe('Test graph_obj', function() { Plotly.deleteTraces(gd, [0, 3]); expect(gd.data).toEqual(expectedData); - expect(Plotly.redraw).toHaveBeenCalled(); + expect(PlotlyInternal.redraw).toHaveBeenCalled(); }); @@ -127,7 +137,7 @@ describe('Test graph_obj', function() { Plotly.deleteTraces(gd, [3, 0]); expect(gd.data).toEqual(expectedData); - expect(Plotly.redraw).toHaveBeenCalled(); + expect(PlotlyInternal.redraw).toHaveBeenCalled(); }); @@ -138,8 +148,8 @@ describe('Test graph_obj', function() { beforeEach(function() { gd = { data: [{'name': 'a'}, {'name': 'b'}] }; - spyOn(Plotly, 'redraw'); - spyOn(Plotly, 'moveTraces'); + spyOn(PlotlyInternal, 'redraw'); + spyOn(PlotlyInternal, 'moveTraces'); }); it('should throw an error when traces is not an object or an array of objects', function() { @@ -186,8 +196,8 @@ describe('Test graph_obj', function() { expect(gd.data[2].uid).toBeDefined(); expect(gd.data[3].name).toBeDefined(); expect(gd.data[3].uid).toBeDefined(); - expect(Plotly.redraw).toHaveBeenCalled(); - expect(Plotly.moveTraces).not.toHaveBeenCalled(); + expect(PlotlyInternal.redraw).toHaveBeenCalled(); + expect(PlotlyInternal.moveTraces).not.toHaveBeenCalled(); }); it('should work when newIndices is defined', function() { @@ -196,8 +206,8 @@ describe('Test graph_obj', function() { expect(gd.data[2].uid).toBeDefined(); expect(gd.data[3].name).toBeDefined(); expect(gd.data[3].uid).toBeDefined(); - expect(Plotly.redraw).not.toHaveBeenCalled(); - expect(Plotly.moveTraces).toHaveBeenCalledWith(gd, [-2, -1], [1, 3]); + expect(PlotlyInternal.redraw).not.toHaveBeenCalled(); + expect(PlotlyInternal.moveTraces).toHaveBeenCalledWith(gd, [-2, -1], [1, 3]); }); @@ -207,8 +217,8 @@ describe('Test graph_obj', function() { expect(gd.data[2].uid).toBeDefined(); expect(gd.data[3].name).toBeDefined(); expect(gd.data[3].uid).toBeDefined(); - expect(Plotly.redraw).not.toHaveBeenCalled(); - expect(Plotly.moveTraces).toHaveBeenCalledWith(gd, [-2, -1], [-3, -1]); + expect(PlotlyInternal.redraw).not.toHaveBeenCalled(); + expect(PlotlyInternal.moveTraces).toHaveBeenCalledWith(gd, [-2, -1], [-3, -1]); }); @@ -216,8 +226,8 @@ describe('Test graph_obj', function() { Plotly.addTraces(gd, {'name': 'c'}, 0); expect(gd.data[2].name).toBeDefined(); expect(gd.data[2].uid).toBeDefined(); - expect(Plotly.redraw).not.toHaveBeenCalled(); - expect(Plotly.moveTraces).toHaveBeenCalledWith(gd, [-1], [0]); + expect(PlotlyInternal.redraw).not.toHaveBeenCalled(); + expect(PlotlyInternal.moveTraces).toHaveBeenCalledWith(gd, [-1], [0]); }); }); @@ -233,7 +243,7 @@ describe('Test graph_obj', function() { {'name': 'd'} ] }; - spyOn(Plotly, 'redraw'); + spyOn(PlotlyInternal, 'redraw'); }); it('throw an error when index arrays are unequal', function() { @@ -301,7 +311,7 @@ describe('Test graph_obj', function() { Plotly.moveTraces(gd, 0, 1); expect(gd.data).toEqual(expectedData); - expect(Plotly.redraw).toHaveBeenCalled(); + expect(PlotlyInternal.redraw).toHaveBeenCalled(); }); @@ -315,7 +325,7 @@ describe('Test graph_obj', function() { Plotly.moveTraces(gd, [3, 1], [0, 3]); expect(gd.data).toEqual(expectedData); - expect(Plotly.redraw).toHaveBeenCalled(); + expect(PlotlyInternal.redraw).toHaveBeenCalled(); }); @@ -329,7 +339,7 @@ describe('Test graph_obj', function() { Plotly.moveTraces(gd, [3, 0]); expect(gd.data).toEqual(expectedData); - expect(Plotly.redraw).toHaveBeenCalled(); + expect(PlotlyInternal.redraw).toHaveBeenCalled(); }); @@ -343,7 +353,7 @@ describe('Test graph_obj', function() { Plotly.moveTraces(gd, 1, -2); expect(gd.data).toEqual(expectedData); - expect(Plotly.redraw).toHaveBeenCalled(); + expect(PlotlyInternal.redraw).toHaveBeenCalled(); }); }); @@ -367,7 +377,7 @@ describe('Test graph_obj', function() { }; } - spyOn(Plotly, 'redraw'); + spyOn(PlotlyInternal, 'redraw'); spyOn(Plotly.Queue, 'add'); }); @@ -470,7 +480,7 @@ describe('Test graph_obj', function() { {x: [1,2,3,4,5], marker: {size: [2,3,4,5,6]}} ]); - expect(Plotly.redraw).toHaveBeenCalled(); + expect(PlotlyInternal.redraw).toHaveBeenCalled(); }); it('should extend and window traces with update keys', function() { @@ -523,11 +533,11 @@ describe('Test graph_obj', function() { {x: [], marker: {size: []}} ]); - expect(Plotly.redraw).toHaveBeenCalled(); + expect(PlotlyInternal.redraw).toHaveBeenCalled(); }); it('prepend is the inverse of extend - no maxPoints', function() { - var cachedData = Plotly.Lib.extendDeep([], gd.data); + var cachedData = Lib.extendDeep([], gd.data); Plotly.extendTraces(gd, { x: [[3, 4], [4, 5]], 'marker.size': [[0, -1], [5, 6]] @@ -545,7 +555,7 @@ describe('Test graph_obj', function() { it('extend is the inverse of prepend - no maxPoints', function() { - var cachedData = Plotly.Lib.extendDeep([], gd.data); + var cachedData = Lib.extendDeep([], gd.data); Plotly.prependTraces(gd, { x: [[3, 4], [4, 5]], 'marker.size': [[0, -1], [5, 6]] @@ -564,7 +574,7 @@ describe('Test graph_obj', function() { it('prepend is the inverse of extend - with maxPoints', function() { var maxPoints = 3; - var cachedData = Plotly.Lib.extendDeep([], gd.data); + var cachedData = Lib.extendDeep([], gd.data); Plotly.extendTraces(gd, { x: [[3, 4], [4, 5]], 'marker.size': [[0, -1], [5, 6]]