(div, data, Plottable)
| 11 | } |
| 12 | |
| 13 | function run(div, data, Plottable) { |
| 14 | "use strict"; |
| 15 | var xScale = new Plottable.Scales.Category(); |
| 16 | var yScale = new Plottable.Scales.Category(); |
| 17 | var xAxis = new Plottable.Axes.Category(xScale, "bottom"); |
| 18 | var yAxis = new Plottable.Axes.Category(yScale, "left"); |
| 19 | |
| 20 | var colorScale = new Plottable.Scales.InterpolatedColor(); |
| 21 | |
| 22 | var plot = new Plottable.Plots.Rectangle().addDataset(new Plottable.Dataset(data)) |
| 23 | .renderer("canvas") |
| 24 | .x((d) => d.x, xScale) |
| 25 | .y((d) => d.y, yScale) |
| 26 | .attr("fill", (d) => d.val, colorScale); |
| 27 | |
| 28 | var table = new Plottable.Components.Table([ |
| 29 | [yAxis, plot], |
| 30 | [null, xAxis] |
| 31 | ]); |
| 32 | |
| 33 | new Plottable.Interactions.PanZoom(xScale, yScale) |
| 34 | .attachTo(plot) |
| 35 | .setMinMaxDomainValuesTo(xScale) |
| 36 | .setMinMaxDomainValuesTo(yScale); |
| 37 | |
| 38 | table.renderTo(div); |
| 39 | window.addEventListener("resize", () => { |
| 40 | table.redraw(); |
| 41 | }); |
| 42 | } |
nothing calls this directly
no test coverage detected