Skip to content

Commit

Permalink
[Examples] Merge HeatMap and TooltipMap
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorCazanave committed Apr 13, 2019
1 parent 3ff1c35 commit 645951a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
6 changes: 2 additions & 4 deletions examples/src/components/examples-app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import React from 'react';
import CheckboxMap from './checkbox-map';
import RadioMap from './radio-map';
import LinkMap from './link-map';
import TooltipMap from './tooltip-map';
import HeatMap from './heat-map';
import TooltipHeatMap from './tooltip-heat-map';
import './examples-app.scss';

class ExamplesApp extends React.Component {
Expand All @@ -20,8 +19,7 @@ class ExamplesApp extends React.Component {
<RadioMap />
<CheckboxMap />
<LinkMap />
<TooltipMap />
<HeatMap />
<TooltipHeatMap />
</section>
);
}
Expand Down
32 changes: 21 additions & 11 deletions examples/src/components/examples-app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,27 @@

&--usa {
width: 800px; // USA needs more space for tooltip
.svg-map{
&__location {
&.heat1{
opacity:0.8;
}
&.heat2{
opacity:0.6;
}
&.heat3{
opacity:0.4;
}

.svg-map__location {
&--heat0 {
fill: blue;
}

&--heat1 {
fill: lightblue;
}

&--heat2 {
fill: orange;
}

&--heat3 {
fill: red;
}

&:focus,
&:hover {
opacity: 0.75;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { SVGMap, USA } from '../../../src/';
import { SVGMap, USA } from '../../../src';
import { getLocationName } from '../utils';
import '../../../src/svg-map.scss';

class TooltipMap extends React.Component {
class TooltipHeatMap extends React.Component {
constructor(props) {
super(props);

Expand Down Expand Up @@ -37,15 +37,21 @@ class TooltipMap extends React.Component {
this.setState({ tooltipStyle });
}

getLocationClassName(location, index) {
// Generate random heat map
return `svg-map__location svg-map__location--heat${index % 4}`;
}

render() {
return (
<article className="examples__block">
<h2 className="examples__block__title">
USA SVG map with tooltips
USA SVG heat map with tooltips
</h2>
<div className="examples__block__map examples__block__map--usa">
<SVGMap
map={USA}
locationClassName={this.getLocationClassName}
onLocationMouseOver={this.handleLocationMouseOver}
onLocationMouseOut={this.handleLocationMouseOut}
onLocationMouseMove={this.handleLocationMouseMove} />
Expand All @@ -58,4 +64,4 @@ class TooltipMap extends React.Component {
}
}

export default TooltipMap;
export default TooltipHeatMap;

0 comments on commit 645951a

Please sign in to comment.