PMSI-AlignAlytics / dimple

An object-oriented API for business analytics
Other
2.73k stars 556 forks source link

addEventHandler returns 0 in the case of a chart has a range of plus and minus values? #259

Closed Yoshiharu-Sato closed 7 years ago

Yoshiharu-Sato commented 7 years ago

I think there is a bug that addEventHandler("click", function (e) { console.log(e.xValue); }) returns 0 instead of the actual value in the case of a chart has a range of plus and minus values.

Any ideas? Thanks in advance.

<script src="http://dimplejs.org/dist/dimple.v2.1.4.min.js"></script>
<script type="text/javascript">
    var svg = dimple.newSvg("#chartContainer", 600, 580);
    d3.tsv("data.tsv", function (data) {

       data = dimple.filterData(data, "City", ["Tokyo"])

        var myChart = new dimple.chart(svg, data);
        myChart.setBounds(70, 50, 500, 480);

        var axisX = myChart.addMeasureAxis("x", "Value");
        var axisY = myChart.addCategoryAxis("y", "Year");

        axisX.overrideMin = -40;
        axisX.overrideMax = 40;

        var s = myChart.addSeries("Channel", dimple.plot.line);
        s.interpolation = "cardinal";
        s.lineMarkers = true;

        myChart.addLegend(60, 10, 500, 20, "right");

        s.addEventHandler("click", function (e) {
            console.log(e.xValue); // output of when clicking the bottom marker: 0 (It should be 10)
        });

        myChart.draw(0);

    });
</script>

data.tsv Year Channel City Value 2000 Japan Tokyo 10 2005 Japan Tokyo -14 2012 Japan Tokyo -30 img