summaryrefslogtreecommitdiffstats
path: root/debian/missing-sources/epoch/src/basic/area.coffee
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 00:55:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 00:55:53 +0000
commit129b974b59c74140570847bb4a2774d41d1e5fae (patch)
treef2dc68e7186b8157e33aebbc2526e016912ded82 /debian/missing-sources/epoch/src/basic/area.coffee
parentAdding upstream version 3.2.1. (diff)
downloadknot-resolver-129b974b59c74140570847bb4a2774d41d1e5fae.tar.xz
knot-resolver-129b974b59c74140570847bb4a2774d41d1e5fae.zip
Adding debian version 3.2.1-3.debian/3.2.1-3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/missing-sources/epoch/src/basic/area.coffee')
-rw-r--r--debian/missing-sources/epoch/src/basic/area.coffee51
1 files changed, 51 insertions, 0 deletions
diff --git a/debian/missing-sources/epoch/src/basic/area.coffee b/debian/missing-sources/epoch/src/basic/area.coffee
new file mode 100644
index 0000000..e44b480
--- /dev/null
+++ b/debian/missing-sources/epoch/src/basic/area.coffee
@@ -0,0 +1,51 @@
+
+# Static stacked area chart implementation using d3.
+class Epoch.Chart.Area extends Epoch.Chart.Plot
+ constructor: (@options={}) ->
+ @options.type ?= 'area'
+ super(@options)
+ @draw()
+
+ # Generates a scale needed to appropriately render the stacked visualization.
+ # @return [Function] The y scale for the visualization.
+ y: ->
+ a = []
+ for layer in @getVisibleLayers()
+ for own k, v of layer.values
+ a[k] += v.y if a[k]?
+ a[k] = v.y unless a[k]?
+ d3.scale.linear()
+ .domain(@options.range ? [0, d3.max(a)])
+ .range([@height - @margins.top - @margins.bottom, 0])
+
+ # Renders the SVG elements needed to display the stacked area chart.
+ draw: ->
+ [x, y, layers] = [@x(), @y(), @getVisibleLayers()]
+
+ @g.selectAll('.layer').remove()
+ return if layers.length == 0
+
+ area = d3.svg.area()
+ .x((d) -> x(d.x))
+ .y0((d) -> y(d.y0))
+ .y1((d) -> y(d.y0 + d.y))
+
+ stack = d3.layout.stack()
+ .values((d) -> d.values)
+
+ data = stack layers
+
+ layer = @g.selectAll('.layer')
+ .data(layers, (d) -> d.category)
+
+ layer.select('.area')
+ .attr('d', (d) -> area(d.values))
+
+ layer.enter().append('g')
+ .attr('class', (d) -> d.className)
+
+ layer.append('path')
+ .attr('class', 'area')
+ .attr('d', (d) -> area(d.values))
+
+ super()