laguna92651

D3 Pie Chart Passing Parameter

Discussion created by laguna92651 on May 30, 2017
Latest reply on Jun 8, 2017 by laguna92651

I am implementing a D3 pie chart, I am having trouble getting the "onclick" event to work. If I try to pass a constant as the parameter, 50, things work fine.

But if I try to pass d.amt as the parameter, the global field that I am storing it in says undefined. The data is in a array of objects.

var dataset = [ {key: 1, amt: 5}, {key: 2, amt: 10}, {key: 3, amt: 20}, {key: 4, amt: 41}, {key: 5, amt: 6}, {key: 6, amt: 25} ];

 

At the beginning of the code I have,

var script = encodeURI('fmp://$/{{FileName}}?script=SliceClick'); that I am passing the parameter to, to execute the Filemaker script SliceClick.

 

This will pass the parameter 50.

     var arcs = svg.selectAll("g.arc")

    .data(pie(dataset))

    .enter()

    .append("g")

    .attr("class", "arc")

    .attr("transform", "translate(" + outerRadius + "," + outerRadius + ")")

        .attr("onclick", function(d, i){

            return "location.href='" + script + "&param=" + 50  + "'";

        });

 

This does not pass the parameter d.amt.

        ...

        .attr("onclick", function(d, i){

            return "location.href='" + script + "&param=" + d.amt  + "'";

        });

 

Any ideas what I'm missing?

Outcomes