Simplifying SVG path strings by reducing number of nodes

前端 未结 1 1819
终归单人心
终归单人心 2021-02-09 22:10

I am generating a large SVG path string that represents a line chart.

Beneath the chart I have a slider for selecting a time range slice. Behind the slider is a mini pr

1条回答
  •  清酒与你
    2021-02-09 22:42

    Simplify.js is probably what you're looking after.

    Given your line chart consists of straight line segments only (which by definition it should), you can use it like this:

      var tolerance = 3
      var pathSegArray = []
      for (var i=0; i

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