Skip to content

Commit f6c1793

Browse files
committed
Update README for v0.1.0
1 parent 61efe69 commit f6c1793

File tree

2 files changed

+46
-40
lines changed

2 files changed

+46
-40
lines changed

README.md

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,28 @@
44
<a href="https://www.npmjs.com/package/vue-choropleth"><img src="https://img.shields.io/npm/l/vue-choropleth.svg" alt="License"></a>
55
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/voluntadpear/ChoroplethMap/issues)
66

7-
> Vue component to display a choropleth map given a certain GeoJSON and another datasource to show information from. Using [Vue2Leaflet](https://korigan.github.com/Vue2Leaflet/)
7+
> Vue components to display a choropleth map given a certain GeoJSON and another datasource to show information from. Using [Vue2Leaflet](https://korigan.github.com/Vue2Leaflet/)
88
99
![Image of Paraguay Choropleth](https://media.giphy.com/media/3ohzh15YwfUVpAWsJq/giphy.gif)
1010

1111
## How to use
12+
*For a complete example, check the code in the single-file component [example](https://github.com/voluntadpear/vue-choropleth/blob/master/examples/node-example/src/App.vue).*
1213

13-
Register ChoroplethMap as a component
14+
Make sure you have `Vue2Leaflet` installed and add the `v-map` component along with the next `vue-choropleth` components:
1415
``` javascript
15-
import ChoroplethMap from 'vue-choropleth'
16-
17-
Vue.component(ChoroplethMap)
16+
import { InfoControl, ReferenceChart, ChoroplethLayer } from 'vue-choropleth'
17+
18+
// Register these components in the components
19+
20+
export default {
21+
name: "app",
22+
components: {
23+
'v-map': Vue2Leaflet.Map,
24+
'v-info-control': InfoControl,
25+
'v-reference-chart': ReferenceChart,
26+
'v-choropleth-layer': ChoroplethLayer
27+
},
28+
// .......your component code.........
1829
```
1930
2031
Make sure the leaflet.css is included, either via a HTML link tag or in your vue component style
@@ -25,71 +36,66 @@ Make sure the leaflet.css is included, either via a HTML link tag or in your vue
2536
2637
On the template:
2738
```html
28-
<ChoroplethMap
29-
:geojson="geojson"
30-
:data="pyDepartmentsData"
31-
titleKey="department_name"
32-
geojsonIdKey="dpto"
33-
idKey="department_id"
34-
:value="value"
35-
:extraValues="extraValues"
36-
:center="center"
37-
:colorScale="colorScale"
38-
mapStyle="height: 500px;"
39-
:zoom="6"
40-
:mapOptions="mapOptions">
41-
<template scope="props">
42-
<InfoControl
39+
<v-map
40+
:center="[-23.752961, -57.854357]"
41+
:zoom="6"
42+
style="height: 500px;"
43+
:options="mapOptions">
44+
<v-choropleth-layer
45+
:data="pyDepartmentsData"
46+
titleKey="department_name"
47+
idKey="department_id"
48+
:value="value"
49+
:extraValues="extraValues"
50+
geojsonIdKey="dpto"
51+
:geojson="paraguayGeojson"
52+
:colorScale="colorScale">
53+
<template slot-scope="props">
54+
<v-info-control
4355
:item="props.currentItem"
4456
:unit="props.unit"
4557
title="Department"
46-
placeholder="Hover over a department"
47-
position="topright">
48-
</InfoControl>
49-
<ReferenceChart
58+
placeholder="Hover over a department"/>
59+
<v-reference-chart
5060
title="Girls school enrolment"
5161
:colorScale="colorScale"
5262
:min="props.min"
5363
:max="props.max"
54-
position="bottomright">
55-
</ReferenceChart>
56-
</template>
57-
</ChoroplethMap>
64+
position="topright"/>
65+
</template>
66+
</v-choropleth-layer>
67+
</v-map>
5868
```
5969
60-
### ChoroplethMap Props
70+
### `v-choropleth-layer` Props
6171
* **geojson**: The GeoJSON object to use
6272
* **data**: Data object with the information to show on the map
6373
* **titleKey**: Property of the **data** object to show when you hover over a certain region of your map (e.g. state_name)
6474
* **geojsonIdKey**: Property under the *properties* array of the GeoJSON that serves as identifier of each region of the map.
6575
* **idKey**: Property of the **data** object that matches the **geojsonIdKey** value.
6676
* **value**: JS object with two properties, **key**: that maps to the **data** property that contains the value domain set (e.g. amount) and **metric**: that maps to the **data** property that describes the unit that you're working on (e.g. ```"% of students"```)
6777
* **extraValues**: Array of **value** objects that show additional information of a certain region of the map.
68-
* **center**: Geographic coordinates of the map initial center (e.g. ```[-23.752961, -57.854357]```)
6978
* **colorScale**: Array of hex color codes to fill each region of the map with. At the minimum you need to specify two colors, the one to use with the lowest values and another one to use with the highest values. (e.g. ```["e7d090", "de7062"]```)
70-
* **mapStyle**: CSS style of the map.
71-
* **zoom**: With how much zoom to init the map.
72-
* **mapOptions**: Additional leaflet Map options. (e.g. ```{attributionControl: false}```)
7379
74-
The `ChoroplethMap` component pass the this information through its [default slot](https://vuejs.org/v2/guide/components.html#Scoped-Slots):
80+
The `v-choropleth-layer` component pass the this information through its [default slot](https://vuejs.org/v2/guide/components.html#Scoped-Slots):
7581
* **currentItem**: Current item on focus
7682
* **unit**: metric associated with the value
7783
* **min**: The lowest value on the domain set
7884
* **max**: The highest value on the domain set
7985
80-
As seen on the example, usually you'll pass these values to the `InfoControl` and `ReferenceChart` components.
86+
As seen on the example, usually you'll pass these values to the `v-info-control` and `v-reference-chart` components.
8187
82-
### InfoControl props
88+
### `v-info-control` props
8389
This is the current item information view.
8490
* **item**: Item to show information about
8591
* **unit**: Metric to use while displaying information
8692
* **title**: Description about what each item of the map is (e.g. ```"State"```)
8793
* **placeholder**: Placeholder text to show when no element is currently selected
8894
* **position**: Where to render the component. With values allowed [here](http://leafletjs.com/reference-1.2.0.html#control-position) (default: ```"bottomleft"```)
8995
90-
### ReferenceChart props
96+
### `v-reference-chart` props
9197
* **title**: Short description to show as reference of the information described by the map (e.g. ```"Population density"```)
92-
* **colorScale**: Same prop as used on `ChoroplethMap` component
98+
* **colorScale**: Same prop as used on `v-choropleth-layer` component
9399
* **min**: The lowest value represented on the visualization
94100
* **max**: The highest value represented on the visualization
95101
* **position**: Where to render the component. With values allowed [here](http://leafletjs.com/reference-1.2.0.html#control-position) (default: ```"topright"```)
@@ -136,7 +142,7 @@ The dev server should detect modification and reload the demo
136142
137143
### Web example
138144
139-
You'll also find an example using direct `<script>` include under `examples/browser-example`
145+
You'll also find an example using `<script>` tags included under `examples/browser-example`
140146
## Authors
141147
142148
Guillermo Peralta Scura

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-choropleth",
3-
"version": "0.0.5",
3+
"version": "0.1.0",
44
"description": "Choropleth Map for Vue.js",
55
"homepage": "https://github.com/voluntadpear/ChoroplethMap",
66
"bugs": "https://github.com/voluntadpear/ChoroplethMap/issues",

0 commit comments

Comments
 (0)