t-viSNE: Interactive Assessment and Interpretation of t-SNE Projections https://doi.org/10.1109/TVCG.2020.2986996
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
t-viSNE/modules/d3-legend/indexRollupNext.js.map

1 line
54 KiB

6 years ago
{"version":3,"file":"indexRollupNext.js","sources":["src/legend.js","src/color.js","src/size.js","src/symbol.js","src/helpers.js","index.js"],"sourcesContent":["import { select } from 'd3-selection'\nimport { format, formatPrefix } from 'd3-format'\n\nconst d3_identity = (d) => d\n\nconst d3_reverse = (arr) => {\n const mirror = [];\n for (let i = 0, l = arr.length; i < l; i++) {\n mirror[i] = arr[l-i-1];\n }\n return mirror;\n}\n\n//Text wrapping code adapted from Mike Bostock\nconst d3_textWrapping = (text, width) => {\n text.each(function() {\n var text = select(this),\n words = text.text().split(/\\s+/).reverse(),\n word,\n line = [],\n lineNumber = 0,\n lineHeight = 1.2, //ems\n y = text.attr(\"y\"),\n dy = parseFloat(text.attr(\"dy\")) || 0,\n tspan = text.text(null)\n .append(\"tspan\")\n .attr(\"x\", 0)\n .attr(\"dy\", dy + \"em\");\n\n while (word = words.pop()) {\n line.push(word);\n tspan.text(line.join(\" \"));\n if (tspan.node().getComputedTextLength() > width && line.length > 1) {\n line.pop();\n tspan.text(line.join(\" \"));\n line = [word];\n tspan = text.append(\"tspan\")\n .attr(\"x\", 0)\n .attr(\"dy\", lineHeight + dy + \"em\").text(word);\n }\n }\n });\n}\n\n\nconst d3_mergeLabels = (gen=[], labels, domain, range) => {\n\n if (typeof labels === \"object\"){\n if(labels.length === 0) return gen;\n\n let i = labels.length;\n for (; i < gen.length; i++) {\n labels.push(gen[i]);\n }\n return labels;\n } else if (typeof labels === \"function\") {\n const customLabels = []\n const genLength = gen.length\n for (let i=0; i < genLength; i++){\n customLabels.push(labels({\n i,\n genLength,\n generatedLabels : gen,\n domain,\n range }))\n }\n return customLabels\n }\n\n return gen;\n }\n\nconst d3_linearLegend = (scale, cells, labelFormat) => {\n let data = [];\n\n if (cells.length > 1){\n data = cells;\n\n } else {\n const domain = scale.domain(),\n increment = (domain[domain.length - 1] - domain[0])/(cells - 1)\n let i = 0;\n\n for (; i < cells; i++){\n data.push(domain[0] + i*increment);\n }\n }\n\n const labels = data.map(labelFormat);\n return {data: data,\n labels: labels,\n feature: d => scale(d)};\n}\n\nconst d3_quantLegend = (scale, labelFormat, labelDelimiter) => {\n const labels = scale.range().map( d => {\n const invert = scale.invertExtent(d);\n return labelFormat(invert[0]) + \" \" + labelDelimiter + \" \" + labelFormat(invert[1]);\n });\n\n return {data: scale.range(),\n labels: labels,\n feature: d3_identity\n };\n}\n\nconst d3_ordinalLegend= scale => ({data: scale.domain(),\n labels: scale.domain(),\n feature: d => scale(d) }\n)\n\nconst d3_cellOver = (cellDispatcher, d, obj) => {\n cellDispatcher.call(\"cellover\", obj, d);\n}\n\nconst d3_cellOut = (cellDispatcher, d, obj) => {\n cellDispatcher.call(\"cellout\", obj, d);\n}\n\nconst d3_cellClick = (cellDispatcher, d, obj) => {\n cellDispatcher.call(\"cellclick\", obj, d);\n}\n\n\nexport default {\n\n d3_drawShapes: (shape, shapes, shapeHeight, shapeWidth, shapeRadius, path) => {\n if (shape === \"rect\"){\n shapes.attr(\"height\", shapeHeight)\n .attr(\"width\", shapeWidth);\n\n } else if (shape === \"circle\") {\n shapes.attr(\"r\", shapeRadius)\n\n } else if (shape === \"line\") {\n shapes.attr(\"x1\", 0).attr(\"x2\", shapeWidth).attr(\"y1\", 0).attr(\"y2\", 0);\n\n } else if (shape === \"path\") {\n shapes.attr(\"d\", path);\n }\n },\n\n d3_addText: function (svg, enter, labels, classPrefix, labelWidth){\n enter.append(\"text\").attr(\"class\", classPrefix + \"label\");\n const text = svg.selectAll(`g.${classPrefix}cell text.${classPrefix}label`)\n .data(labels)\n .text(d3_identity);\n\n