• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

129
Views
Access to an object of an object

I'm using Datamaps plugin and I'm trying to access to an object that is in another object.

Here I want to get all the values of data in options. Please see the console.log answer the screenshot below.

Here is the js:

var map = new Datamap({
  scope: "fra",
  element: document.getElementById("map-france"),
  responsive: true,
  fills: {
    defaultFill: "#EDE8D6",
    "1-50": color_dept[4],
    "51-100": "#EDE8D6",
    "101-150": "#E2DABF",
    "151-200": "#CEC191",
    "201-300": "#BCAE7C",
    "301-400": "#9D893E",
    "401-": "#827131",
  },
  data: {
    YV: {
      fillKey: "#EDE8D6",
    },
    AM: {
      fillKey: "51-100",
    },
  },
  geographyConfig: {
    popupTemplate: function (geo, data) {
      for (const val of uniqueValues) {
        if (geo.properties.name == val) {
          return [
            '<div class="hoverinfo"><strong>',
            val,
            "<br/>",
            dataValues.filter((v) => v == val).length,
            " parrainages",
            "</strong></div>",
          ].join("");
        }
      }
    },
    hideAntarctica: true,
    hideHawaiiAndAlaska: false,
    borderWidth: 1,
    borderOpacity: 1,
    borderColor: "#D2D3B5",
    popupOnHover: true, // True to show the popup while hovering
    highlightOnHover: true,
    highlightFillColor: "#1E2382",
    highlightBorderColor: "#FFFFFF",
    highlightBorderWidth: 1,
    highlightBorderOpacity: 1,
  },
  setProjection: function (element) {
    var projection = d3.geo
      .mercator()
      .center([2.454071, 46.279229])
      .rotate([0, 0])
      .scale(1700)
      .translate([350, 225]);
    var path = d3.geo.path().projection(projection);

    return {
      path: path,
      projection: projection,
    };
  },
});


Object.entries(map).map((item) => {
  console.log("item 1 : ", item);
});

enter image description here

almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Ex.

const mapExample = new Map()

mapExample.set("test", 
{"nestedObj":{"newObject":"new Obj value"}})

now, map over this would give you an array with the top level object "test"

to get the value of the nested value of "newObject":

Object.entries(mapExample.get("test")).map(i=> console.log(i[1].newObject))

or

Object.entries(mapExample.get("test")).map(i=> {
  let [key,value] = i
  console.log(key,value)
});

can copy and post this into chrome console and mess around with it, to see different outcomes.

but key take way is Object.entries return an array of your Object in ["key":"value"] order.

almost 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error