Git Product home page Git Product logo

Comments (4)

martynasma avatar martynasma commented on June 8, 2024

Click event should not be fired twice. It should not be fired on map drag, either.

Here's your map in a standalone setting:
https://codepen.io/team/amcharts/pen/3119e0e372f3c0bf7eddf179a60f9aee

I works as expected.

Could you double check if you are running the latest version? (3.21.4) I remember having us fixed click event in some version.

from amcharts3-angular2.

Pauan avatar Pauan commented on June 8, 2024

@rbasniak Also make sure that you're using this.AmCharts.updateChart when making any changes to the chart, including when adding event listeners:

this.chart = this.AmCharts.makeChart("chartdiv", {
    "type": "map",
    "theme": "light",
    "dataProvider": {
        "map": "worldLow",
        "getAreasFromMap": true
    },
    "areasSettings": {
        "autoZoom": false,
        "selectedColor": "#CC0000"
    }
});

this.AmCharts.updateChart(this.chart, () => {
    this.chart.addListener("click", event => {
        // find out the coordinates of under mouse cursor
        var info = event.chart.getDevInfo();

        // print in console as well
        console.log({
            "latitude": info.latitude,
            "longitude": info.longitude
        });
    });
});

from amcharts3-angular2.

rbasniak avatar rbasniak commented on June 8, 2024

@Pauan @martynasma I found the problem. The readme.md says that I need to add the follwing scipts to my index.html

  <script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
  <script src="https://www.amcharts.com/lib/3/serial.js"></script>
  <script src="https://www.amcharts.com/lib/3/themes/light.js"></script>

If I do, the click event is fired twice and on map pan. If I remove these scripts, it all works as expected.

I'm closing the issue because the problem is fixed, but I would like to understand why if someone can explain to me...

Is it ok to remove the script tags, or there's a problem on the readme.md?

from amcharts3-angular2.

Pauan avatar Pauan commented on June 8, 2024

@rbasniak You're right, that seems to be a bug in AmCharts v3.

The README assumes that you are using the serial chart, because that is our most popular chart type.

You have to change the serial.js file when you are using other chart types. I'll add a note in the README about that.

It should be completely fine for you to remove the amcharts.js and serial.js <script> tags:

<script src="https://www.amcharts.com/lib/3/ammap.js"></script>
<script src="https://www.amcharts.com/lib/3/maps/js/worldLow.js"></script>
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>

from amcharts3-angular2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.