amcharts / ammap3

JavaScript Maps V3
Other
92 stars 53 forks source link

Uncaught TypeError: Cannot read property 'areas' of undefined, Uncaught TypeError: Cannot read property 'scale' of undefined #1

Open gfoiani opened 8 years ago

gfoiani commented 8 years ago

Hi,

I'm using trying to build a map chart following the your first map tutorial. I'm using the library inside a React application with ES6 and Babel. I created an SVG map using the Pixel Map tool you suggested and I'm using it through mapUrl option. I get the following errors:

Uncaught TypeError: Cannot read property 'areas' of undefined
Uncaught TypeError: Cannot read property 'scale' of undefined

I imported the library as suggested here This is my code:

import React, { Component } from 'react';
import AmCharts from 'exports?window.AmCharts!ammap3/ammap/ammap';

export default class Map extends Component {

  componentDidMount() {
    AmCharts.makeChart( 'mapdiv', {
      type: 'map',
      mapUrl: require('../images/amCharts.pixelMap.svg')
    });
  }

  render() {
    const style = {
      width: '600px',
      height: '400px'
    };
    return (
      <div id="mapdiv" style={style}></div>
    );
  }
}
martynasma commented 8 years ago

Sorry for the late reply. Would you be able to try this with our official React wrapper?

https://github.com/amcharts/amcharts3-react