Socket
Socket
Sign inDemoInstall

ortelius

Package Overview
Dependencies
39
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1-beta.1 to 0.0.1-beta.2

dist/main.36a380efb8ddd3dba605.css

5

package.json
{
"name": "ortelius",
"version": "0.0.1-beta.1",
"version": "0.0.1-beta.2",
"description": "a tool for making good-looking maps",

@@ -37,2 +37,5 @@ "main": "index.js",

"d3-scale-chromatic": "^1.3.3",
"d3-selection": "^1.4.0",
"d3-svg-legend": "^2.25.6",
"d3-transition": "^1.2.0",
"prop-types": "^15.7.2",

@@ -39,0 +42,0 @@ "react": "^16.8.0",

29

src/utils/createColorScale.js

@@ -1,15 +0,26 @@

import { scaleLinear } from 'd3-scale';
import { scaleLinear, scaleThreshold } from 'd3-scale';
import { interpolateViridis } from 'd3-scale-chromatic';
export default function createColorScale(data) {
const scaleData = data.map(datum => datum.value);
export default function createColorScale(
config = { type: 'linear', range: [interpolateViridis(0), interpolateViridis(1)] },
dataById
) {
const { type } = config;
const min = Math.min(...scaleData);
const max = Math.max(...scaleData);
if (type === 'linear') {
const scaleData = Object.values(dataById).map(datum => datum.value);
const scale = scaleLinear()
.domain([min, max])
.range([interpolateViridis(0), interpolateViridis(1)]);
const min = Math.min(...scaleData);
const max = Math.max(...scaleData);
return scale;
return scaleLinear()
.domain([min, max])
.range([interpolateViridis(0), interpolateViridis(1)]);
}
if (type === 'threshold') {
return scaleThreshold()
.domain(config.domain)
.range(config.range);
}
}
import { geoPath as d3GeoPath } from 'd3-geo';
export function createGeoPath({ projection, width, height, geojson }) {
return d3GeoPath().projection(projection.fitExtent([[0, 0], [width, height]], geojson));
return d3GeoPath().projection(projection.fitSize([width, height], geojson));
}
export default function createGeoFeatures(features, geoPathParams) {
const geoPath = createGeoPath(geoPathParams);
// const geoPath = createGeoPath(geoPathParams);

@@ -15,7 +15,7 @@ return features.map(feature => {

id,
geoProperties: properties,
path: geoPath(feature),
bounds: geoPath.bounds(feature)
geoProperties: properties
// path: geoPath(feature),
// bounds: geoPath.bounds(feature)
};
});
}
import { csvParse } from 'd3-dsv';
function castToFloat(valueToCast, idKey) {
export function castToFloat(valueToCast, idKey) {
try {

@@ -5,0 +5,0 @@ const value = parseFloat(valueToCast);

@@ -1,10 +0,17 @@

import { feature as topo2geo } from 'topojson';
import * as topojson from 'topojson';
export default function prepareGeoJson(ext, fetchedData, filter) {
export default function prepareGeoJson(
format = 'topojson',
fetchedData,
filter = geoJson => geoJson,
simplifyFactor = 0
) {
let geoJson = fetchedData;
if (ext === 'json') {
if (format === 'topojson') {
const topoJsonKey = Object.keys(fetchedData.objects)[0];
let topoJson = topojson.presimplify(fetchedData);
topoJson = topojson.simplify(topoJson, simplifyFactor);
geoJson = topo2geo(fetchedData, fetchedData.objects[topoJsonKey]);
geoJson = topojson.feature(topoJson, topoJson.objects[topoJsonKey]);
}

@@ -11,0 +18,0 @@

export default ({ bounds, width, height }) => {
const dx = bounds[1][0] - bounds[0][0];
const dy = bounds[1][1] - bounds[0][1];
const scale = Math.max(1, Math.min(20, 0.9 / Math.max(dx / width, dy / height)));
const scale = Math.max(1, Math.min(10, 0.9 / Math.max(dx / width, dy / height)));

@@ -6,0 +6,0 @@ const x = (bounds[0][0] + bounds[1][0]) / 2;

import React from 'react';
import ReactDOM from 'react-dom';
import SimpleMap from './SimpleMap';
import DynamicMap from './DynamicMap';
import { csvParse } from 'd3-dsv';
const mapFactory = Factory => ({ container, ...rest }) => {
const containerElem = document.querySelector(container);
import Choropleth from './Choropleth';
ReactDOM.render(
React.createElement(Factory, {
...rest
}),
containerElem
);
};
export default {
createMap: ({ container, type, ...rest }) => {
const containerElem = document.querySelector(container);
let Factory;
export default {
createSimpleMap: mapFactory(SimpleMap),
createDynamicMap: mapFactory(DynamicMap)
if (type === 'choropleth') {
Factory = Choropleth;
}
ReactDOM.render(
React.createElement(Factory, {
...rest
}),
containerElem
);
},
fetchCSV: async urls => {
const rawCSV = await Promise.all(urls.map(url => fetch(url).then(response => response.text())));
return rawCSV.map(csvParse);
},
fetchJSON: async items =>
Promise.all(items.map(({ url }) => fetch(url).then(response => response.json())))
};
import React from 'react';
import PropTypes from 'prop-types';
export default function Legend() {
return null;
import * as d3 from 'utils/d3-custom.js';
export default class Legend extends React.PureComponent {
constructor(props) {
super(props);
this.legendContainer = React.createRef();
}
componentDidMount() {
const { labels, labelWrap, scale } = this.props;
const legend = d3
.legendColor()
.labelFormat(d3.format('.2f'))
.labels(labels)
.labelWrap(labelWrap)
.scale(scale);
d3.select(this.legendContainer.current).call(legend);
}
render() {
return <g className="legend" ref={this.legendContainer} />;
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc