Compare commits

..

1 Commits

Author SHA1 Message Date
Daniel Quathamer 9520aa9a85 Obsolete files #5 2 months ago
  1. 21
      superx/style/LICENSE_bulma_tooltip_1.2.0.txt
  2. 2
      superx/style/bulma-tooltip.min.css
  3. 15286
      superx/style/bulma.css
  4. 137
      superx/xml/js/viz/viz_functions.js

21
superx/style/LICENSE_bulma_tooltip_1.2.0.txt

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2020 CreativeBulma
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

2
superx/style/bulma-tooltip.min.css vendored

File diff suppressed because one or more lines are too long

15286
superx/style/bulma.css vendored

File diff suppressed because it is too large Load Diff

137
superx/xml/js/viz/viz_functions.js

@ -2406,78 +2406,69 @@ var captionEmptyTarget=getCommonChartPropertyFromModel(myCommonChartProperties,"
renderWorldMap(myCommonChartProperties,mySvg,data); renderWorldMap(myCommonChartProperties,mySvg,data);
} }
function renderWorldMap(myCommonChartProperties, mySvg, data) { function renderWorldMap(myCommonChartProperties,mySvg,data)
const worldWidth = getCommonChartPropertyFromModel(myCommonChartProperties, "width"); {
const worldHeight = getCommonChartPropertyFromModel(myCommonChartProperties, "height"); const worldWidth = 960;
const worldHeight = 600;
const worldTooltip = d3.select(".vizTooltip");
const worldTooltip = d3.select(".vizTooltip");
const worldColor = d3.scaleSequential(d3.interpolateBlues)
.domain([0, 1]); // Domain matches the output of logColor const worldColor = d3.scaleSequential(d3.interpolateBlues)
.domain([0, 1]); // Domain matches the output of logColor
const worldSvg = d3.select("#world-map")
.attr("width", worldWidth) const worldLogColor = d3.scaleLog()
.attr("height", worldHeight); .domain([1, 41227]) // Adjust this domain to fit your data range
.range([0, 1]);
// Calculate the scale and translation dynamically based on width and height
const scale = Math.min(worldWidth / 6.28, worldHeight / 3.14); const worldSvg = d3.select("#world-map")
const translate = [worldWidth / 2, worldHeight / 2]; .attr("width", worldWidth)
.attr("height", worldHeight);
const worldProjection = d3.geoMercator()
.scale(scale) const worldProjection = d3.geoMercator()
.translate(translate); .scale(100)
.translate([worldWidth / 2, worldHeight / 1.5]);
const worldPath = d3.geoPath().projection(worldProjection);
const worldPath = d3.geoPath().projection(worldProjection);
var d = getWorldMapData(data); var d=getWorldMapData(data);
// Load the world data files
// Load the world data files Promise.all([
Promise.all([ d3.json("https://raw.githubusercontent.com/holtzy/D3-graph-gallery/master/DATA/world.geojson"),
d3.json("https://raw.githubusercontent.com/holtzy/D3-graph-gallery/master/DATA/world.geojson"), /*d3.csv("/superx/viz_worldmap/data.csv", d => ({
/*d3.csv("/superx/viz_worldmap/data.csv", d => ({ iso3: d.iso3,
iso3: d.iso3, value: +d.value
value: +d.value }))*/
}))*/ d
d ]).then(([worldGeojson, worldData]) => {
]).then(([worldGeojson, worldData]) => { const worldDataMap = new Map(worldData.map(d => [d.iso3, d.value]));
const worldDataMap = new Map(worldData.map(d => [d.iso3, d.value]));
mySvg.append("g")
// Find the maximum value in the data .selectAll("path")
const maxValue = d3.max(worldData, d => d.value); .data(worldGeojson.features)
.enter().append("path")
// Update the worldLogColor domain based on the maximum value .attr("d", worldPath)
const worldLogColor = d3.scaleLog() .attr("fill", d => {
.domain([1, maxValue]) // Use the maximum value from the data const value = worldDataMap.get(d.id); // Use `d.id` to access ISO 3 codes
.range([0, 1]); if (value === 0) return "#ccc"; // Handle zero values separately
return value ? worldColor(worldLogColor(value)) : "#ccc";
mySvg.append("g") })
.selectAll("path") .on("mouseover", function (event, d) {
.data(worldGeojson.features) const value = worldDataMap.get(d.id);
.enter().append("path") worldTooltip.transition()
.attr("d", worldPath) .duration(200)
.attr("fill", d => { .style("opacity", .9);
const value = worldDataMap.get(d.id); // Use `d.id` to access ISO 3 codes worldTooltip.html(d.properties.name + "<br>" + (value ? value : "No data"))
if (value === 0) return "#ccc"; // Handle zero values separately .style("left", (event.pageX) + "px")
return value ? worldColor(worldLogColor(value)) : "#ccc"; .style("top", (event.pageY - 28) + "px");
}) })
.on("mouseover", function (event, d) { .on("mouseout", function () {
const value = worldDataMap.get(d.id); worldTooltip.transition()
worldTooltip.transition() .duration(500)
.duration(200) .style("opacity", 0);
.style("opacity", .9); });
worldTooltip.html(d.properties.name + "<br>" + (value ? value : "No data")) }).catch(error => {
.style("left", (event.pageX) + "px") console.error('Error loading or parsing data:', error);
.style("top", (event.pageY - 28) + "px"); });
})
.on("mouseout", function () {
worldTooltip.transition()
.duration(500)
.style("opacity", 0);
});
}).catch(error => {
console.error('Error loading or parsing data:', error);
});
}
function getWorldMapData(data) function getWorldMapData(data)
{ {
var myData=[]; var myData=[];
@ -2489,7 +2480,7 @@ for (var i = 0; i < data.length; i++)
} }
return myData; return myData;
} }
}
function makeSankeyD3(myCommonChartProperties,mySvg,data,metaData,chartElem) function makeSankeyD3(myCommonChartProperties,mySvg,data,metaData,chartElem)
{ {
// load the data // load the data

Loading…
Cancel
Save