Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

116
Vistas
Set y position of svg using jquery/javascript

I want to set y value for tspan inside svg.

The svg is like this (for simplicity I deleted some part, the full code is here: https://0bin.net/paste/VKLkhpMK#HkAkhB0vVSN-ZVE9yUnWRkbgfzuN+S+bWt+U15wMJxe ):

<div class="chart" style="margin-top: -50px">
   <div id="jvwbtduzlfxnprgyeskhiqaoc" style="min-height: 288.7px;">
      <div id="apexchartsq5s3epfr" class="apexcharts-canvas apexchartsq5s3epfr apexcharts-theme-light" style="width: 270px; height: 288.7px;">
         <svg id="SvgjsSvg1001" width="270" height="288.70000000000005" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev" class="apexcharts-svg" xmlns:data="ApexChartsNS" transform="translate(0, 0)" style="background: transparent;">
            <g id="SvgjsG1016" class="apexcharts-datalabels-group" transform="translate(0, 0) scale(1)" style="opacity: 1;">
              <text id="SvgjsText1017" font-family="&quot;Nunito&quot;" x="138" y="138" text-anchor="middle" dominant-baseline="auto" font-size="16px" font-weight="600" fill="#008744" class="apexcharts-text apexcharts-datalabel-label" style="font-family: Nunito;">

                   <tspan id="SvgjsTspan1018">8 / 8 + 1</tspan> // set y="150" (the value for id is unique, so I can't using it)

               </text>
               <text id="SvgjsText1019" font-family="&quot;Nunito&quot;" x="138" y="170" text-anchor="middle" dominant-baseline="auto" font-size="14px" font-weight="400" fill="#373d3f" class="apexcharts-text apexcharts-datalabel-value" style="font-family: Nunito;">100%</text>
             </g>
         </svg>
      </div>
   </div>
</div>

I've tried like this:

<script>
   $('.apexcharts-datalabel-label tspan').attr('y', 150);
</script>

But nothing changed, I don't know why. My code above working on other page, but not working for this one.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The following selector should work:

.apexcharts-text.apexcharts-datalabel-label tspan

So the query would change to:

$('.apexcharts-text.apexcharts-datalabel-label tspan').attr('y', 150);

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda