GitHub - Seungwoo321/vue-datamaps: It is a Vue port of the javascript-based DataMaps (original) (raw)

Vue Datamaps

All Contributors

It is a Vue port of the javascript-based DataMaps

npm npm npm jsdelivr

Contributors

Live demo

link

Run demo

project clone

$ git clone https://github.com/Seungwoo321/vue-datamaps.git

install dependencies

$ npm install

run

$ npm run dev

Installation

install

$ npm install vue-datamaps

Base Usage

Required

Global

main.js

import Vue from 'vue' import VueDatamaps from 'vue-datamaps'

Vue.use(VueDatamaps)

vue template

Component Style

vue template

Example

vue-datamaps-demo-basic.png

Basic:

vue-datamaps-demo-state-label.png

State Labels:

{{ popupData }}

vue-datamaps-demo-bubbles.png

Bubbles:

Yield: {{ popupData.yeild }}
Exploded on {{ popupData.date }} by the {{ popupData.country }}

vue-datamaps-demo-arcs.png

Arcs:

vue-datamaps-demo-graticules.png

Projections & Graticules:

vue-datamaps-demo-zoom.png

Zoom:

{{ popupData.name }}

vue-datamaps-demo-south-korea.png

South Korea:

vue-datamaps-demo-custom-color.png

Custom Color:

vue-datamaps-demo-aws-region.png

AWS Region:

{{ popupData.title }}
{{ popupData.origin }} ▶▶▶ {{ popupData.destination }}

Available Props Option

scope

Same as the original.

setProjection

Same as original but d3 version different.

projection

Same as original but PascalCase.

dataType

Same as original.

data

Same as original.

done

Not implemented.

fills

Same as original.

geographyConfig

Same as original but not include popupTemplate.

bubblesConfig

Same as original but not include popupTemplate.

bubbles

arcConfig

Same as original but not include popupTemplate.

arc

If arcConfig required.

disableDefaultStyles

Not implemented.

labelsConfig

Same as original.

labels

If labelsConfig required.

popupTemplate

If slot hoverinfo and event custom:popup||custom:popup-bubble||custom:popup-arc||custom:popup-region|| required.

Default Props Option

{ scope: 'world', setProjection: (d3, element) => { let projection = null let path = null if (this.scope === 'usa') { projection = d3.geoAlbersUsa() .scale(this.svgWidth) .translate([this.svgWidth / 2, this.svgHeight / 2]) } else if (this.scope === 'world') { projection = d3geo${this.projection} .scale((this.svgWidth + 1) / 2 / Math.PI) .translate([this.svgWidth / 2, this.svgHeight / (this.projection === 'Mercator' ? 1.45 : 1.8)]) } if (this.projection === 'Orthographic') { this.svg.append('defs').append('path') .datum({ type: 'Sphere' }) .attr('id', 'sphere') .attr('d', path)

    this.svg.append('use')
        .attr('class', 'stroke')
        .attr('xlink:href', '#sphere')

    this.svg.append('use')
        .attr('class', 'fill')
        .attr('xlink:href', '#sphere')
    projection.scale(this.svgWidth / Math.PI * 0.9).clipAngle(90).rotate(this.projectionConfigOptions.rotation)
}

path = d3.geoPath()
    .projection(projection)
return { projection, path }

}, projection: 'Equirectangular', dataType: 'json', data: {}, done: function () { return {} }, fills: { authorHasTraveledTo: '#fa0fa0', defaultFill: '#ABDDA4' }, geographyConfig: { dataUrl: null, hideAntarctica: true, hideHawaiiAndAlaska: false, borderWidth: 1, borderOpacity: 1, borderColor: '#FDFDFD', popupOnHover: true, highlightOnHover: true, highlightFillColor: '#FC8D59', highlightBorderColor: 'rgba(250, 15, 160, 0.2)', highlightBorderWidth: 2, highlightBorderOpacity: 1, highlightFillOpacity: 0.85 }, projectionConfig: { rotation: [97, 0] }, bubblesConfig: { borderWidth: 2, borderOpacity: 1, borderColor: '#FFFFFF', popupOnHover: true, radius: null, fillOpacity: 0.75, animate: true, highlightOnHover: true, highlightFillColor: '#FC8D59', highlightBorderColor: 'rgba(250, 15, 160, 0.2)', highlightBorderWidth: 2, highlightBorderOpacity: 1, highlightFillOpacity: 0.85, exitDelay: 100, key: JSON.stringify, data: [] }, bubbles: false, arcConfig: { strokeColor: '#DD1C77', strokeWidth: 1, arcSharpness: 1, animationSpeed: 600, popupOnHover: false, data: [] }, arc: false, disableDefaultStyles: false, labelsConfig: { fontSize: 10, fontFamily: 'Verdana', labelColor: '#000', lineWidth: 1 }, labels: false, popupTemplate: false, awsRegions: false, awsRegionsConfig: { strokeColor: '#0b5fd6', strokeWidth: 1.5, defaultFill: 'transparent', highlightFillOpacity: 1, showPrivateRegions: false, popupOnHover: false, data: [] } }

Slot & Event for @mouseover

Inspired

License

MIT