Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision 00e4dbd184a8eecfc8921431fcd1ecc2f966177e authored by Sanmisan on 13 October 2023, 20:18:23 UTC, committed by GitHub on 13 October 2023, 20:18:23 UTC
Update README.md
teaser img
1 parent b49b4e1
  • Files
  • Changes
  • ba30466
  • /
  • src
  • /
  • components
  • /
  • mapLinter
  • /
  • mapGenerator.js
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:00e4dbd184a8eecfc8921431fcd1ecc2f966177e
directory badge
swh:1:dir:d0f70c56fb911ccedd47d48a8d54285cd62c650e
content badge
swh:1:cnt:106d22061c643551e1d7b3dd7354cad90214987d

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
mapGenerator.js
import React, {Component} from "react";
import '../../styles/MapLinter.css';
//import {Card} from 'antd';
import embed from 'vega-embed';

class MapGenerator extends Component {
    constructor(props){
        super(props);
        this.canvasRef = React.createRef();
    }

    drawVegaMap = (selectedCaseData, spec, selectRawCase) => {

        if(selectRawCase === 'county_unemployment'){

            spec.data.values = selectedCaseData.geo;
            //spec.transform[0].from.data.values = selectedCaseData.data.data;
            //console.log(spec);
            const result = embed(this.canvasRef.current, spec)
            .then((re)=>{
                // result should be stored into the state
                console.log(re);
            })
            .catch((err)=>{
                //console.log(err);
            });

        }else if(selectRawCase === 'state_shipment_norm'){
            /** SPATICL CASE 1 with un classed map */
            let unclass_spec_string = 
            `{
                "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
                "width": 550,
                "height": 300,
                "background": "#F3F8FB",
                "title": "Value of Freight Shipments by State: 2002",
                "data": {
                    "values": "state_shipment",
                    "format": {
                        "property": "features"
                    }
                },
                "mark": "geoshape",
                "projection": {
                    "type": "albersUsa"
                },
                "encoding": {
                    "stroke": {
                        "value": "black"
                    },
                    "strokeWidth": {
                        "value": 1
                    },
                    "color": {
                        "field": "properties.shipment",
                        "type": "quantitative",
                        "scale": {
                            "range": ["#ffffff","#D9E6EB","#BAC9C9","#BAC9d4","#151719"],
                            "type": "threshold",
                            "domain": [50, 249, 399, 600]
                        },
                        "legend": {
                            "title": "billion $"
                        }
                    }         
                },
                "usermeta": {
                    "embedOptions": {
                        "actions": false
                    }
                }
            }`;

            let unclass_spec = JSON.parse(unclass_spec_string);
            unclass_spec.data.values = this.props.state_shipment;
            /** Preprocess the vega spec */
            //spec.data.values = selectedCaseData.geo;
            //spec.projection.fit = selectedCaseData.geo.features;
            const result = embed(this.canvasRef.current, unclass_spec)
            .then((re)=>{
                // result should be stored into the state
                //console.log('Original Choropleth Map');
                
            })
            .catch((err)=>{
                this.props.onVegaParseError(err, true);
                //console.log(err);
            });

        }else if(selectRawCase === 'montreal_pop_density'){
            /** Preprocess the vega spec */
            spec.data.values = selectedCaseData.geo;
            //spec.projection.fit = selectedCaseData.geo.features;
            const result = embed(this.canvasRef.current, spec)
            .then((re)=>{
                // result should be stored into the state
                //console.log('Original Choropleth Map');
                
            })
            .catch((err)=>{
                //this.props.onVegaParseError(err, true);
                //console.log(err);
            });
            
        }else if(selectRawCase === 'georgia_pctBach'){

            /** Preprocess the vega spec */
            spec.data.values = selectedCaseData.geo;

            //spec.projection.fit = selectedCaseData.geo.features;
            const result = embed(this.canvasRef.current, spec)
            .then((re)=>{
                // result should be stored into the state
                //console.log('Original Choropleth Map');
                
            })
            .catch((err)=>{
                //this.props.onVegaParseError(err, true);
                //console.log(err);
            });

        }else if(selectRawCase === 'chicago_income'){
            /** Preprocess the vega spec */
            spec.data.values = selectedCaseData.geo;

            //spec.projection.fit = selectedCaseData.geo.features;
            const result = embed(this.canvasRef.current, spec)
            .then((re)=>{
                // result should be stored into the state
                //console.log('Original Choropleth Map');
                
            })
            .catch((err)=>{
                //this.props.onVegaParseError(err, true);
                //console.log(err);
            });
        }else{
             /** Preprocess the vega spec */
             spec.data.values = selectedCaseData.geo;

             //spec.projection.fit = selectedCaseData.geo.features;
             const result = embed(this.canvasRef.current, spec)
             .then((re)=>{
                 // result should be stored into the state
                 //console.log('Original Choropleth Map');
                 
             })
             .catch((err)=>{
                 //this.props.onVegaParseError(err, true);
                 //console.log(err);
             });
        }
        
    };


    /** class function section */
    componentDidMount(){
        if(this.props.selectRawCase !== null){
            this.drawVegaMap(this.props.selectedCaseData, this.props.vegaLiteSpec, this.props.selectRawCase);
        }
        
    }

    componentWillReceiveProps(nextProps, nextContext){
        if(nextProps.selectRawCase !== null){
            this.drawVegaMap(nextProps.selectedCaseData, nextProps.vegaLiteSpec, nextProps.selectRawCase);
        }
        
    }

    /** render components */
    render(){

        return(
            <div ref={this.canvasRef}></div>
        );
    }
}
export default MapGenerator;
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API