Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

93
Visualizações
Template literal statement results in creating "[obejct Object]" div elemnt in d3.js example

I'm trying to create a swatch type legend on my graph and following this reference. (https://observablehq.com/@d3/color-legend)

But when I apply the above code, the results on html look like this:

<div style="display: flex; align-items: center; margin-left: ${+marginLeft}px; min-height: 33px; font: 10px sans-serif;">
  <style>

.${id}-item {
  break-inside: avoid;
  display: flex;
  align-items: center;
  padding-bottom: 1px;
}

.${id}-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - ${+swatchWidth}px - 0.5em);
}

.${id}-swatch {
  width: ${+swatchWidth}px;
  height: ${+swatchHeight}px;
  margin: 0 0.5em 0 0;
}

  </style>
  <div style="width: 100%"; columns: 300px">
    "[object Object], [object Object], [object Object], [object Object] "
  </div>
</div>

It should look like this on html:

<div ...>
  <style>
    ...
  </style>
  <div style="width: 100%; columns: 300px">
    <div class="-swatches-99bef5aa19961-swatch" style="background: rgb(31, 119, 180);"></div>
    <div class="-swatches-99bef5aa19961-label" title="title1">title1</div>
  </div>

I guess the clause about return inside of template literal statement though, don't even know what's the real problem and how to solve it.

Can anyone help solving this?

about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda