I'm trying to build a lwc component that will print a map chart with values from salesforce. In each region I have several accounts and I want to sum all my data for the connected commercial. So I plan to use a SOQL query, retrieve my data and put them in my chart.
But when I look for some example they use CSV file to import values.
var promises = [];
promises.push(d3.json('d3js/map-population/regions.json'));
promises.push(d3.csv("d3js/map-population/population.csv"));
Promise.all(promises).then(function(values) {
const geojson = values[0];
const csv = values[1];
var features = deps
.selectAll("path")
.data(geojson.features)
.enter()
.append("path")
.attr('id', d => "d" + d.properties.CODE_REG)
.attr("d", path);
//Some code
csv.forEach(function(e,i) {
d3.select("#d" + e.CODE_REG)
.attr("class", d => "region q" + quantile(+e.POP) + "-9")
.on("mouseover", function(d) {
div.transition()
.duration(200)
.style("opacity", .9);
div.html("<b>Region : </b>" + e.NAME_REGION + "<br>"
+ "<b>Population : </b>" + e.POP + "<br>")
.style("left", (d3.event.pageX + 30) + "px")
.style("top", (d3.event.pageY - 30) + "px");
})
.on("mouseout", function(d) {
div.style("opacity", 0);
div.html("")
.style("left", "-500px")
.style("top", "-500px");
});
});
Here I want to replace my csv
value with a List<Account>
from this kind of query SELECT Region__c, PostCode__c, Value1 FROM Account WHERE User = thisUser
so in my forEach
I want to print the SUM of all my Value1 instead of POP from there example. But I wasn't able to populate my map with my values from Salesforce.
EDIT
My JSON is a map with coordinate with at the end "properties":{"code":"75","name":"Paris"}
with code
the code of my department name
the name of my department. So the JSON map a list of coordinate with my department infos. Here a sample of the CSV they provided :
CODE_REG,NAME_REGION,CODE_DEPT,NAME_DEPT,NB_ARRONDS,NB_CANTONS,NB_COMMUNES,POP
82,Rhône-Alpes,01,Ain,4,43,419,614331
22,Picardie,02,Aisne,5,42,816,555094
83,Auvergne,03,Allier,3,35,320,353124
This is a csv from a tutorial site I used to build my programme. Now I have some difficulties to adapt it. I guessed that in the foreach
statement they use the information in the csv to print POP
value for each department. But now I want to use a List to print my own values from salesforce.