Gauge D3, display values positions

前端 未结 1 1217
猫巷女王i
猫巷女王i 2021-01-21 14:53

I\'m trying to use some ready written javascript to make gauge. I\'m almost there, but i cannot figure how to manage value captions.

Here is how my code works now:

相关标签:
1条回答
  • 2021-01-21 15:18

    Its all about changing the translate for text

    For example (for setting the max value of gauge):

      texts.append("text")
        .text(function() {
          return gaugeMaxValue + "%";//i added the percent(%)
        })
        .attr('id', 'scale20')
        .attr('transform', "translate(" + ((width + margin.left) / 1.08) + ", " + ((height + margin.top) / 2) + ")")//then change the x and y for the translate
        .attr("font-size", 15)
        .style("fill", "#000000");
    

    Similarly for all other text values.

    working code here

    0 讨论(0)
提交回复
热议问题