palantir / plottable

:bar_chart: A library of modular chart components built on D3
http://plottablejs.org/
MIT License
2.97k stars 224 forks source link

Rectangle Plot Error: postScale is not a function (replicated in codesandbox) #3473

Open riley-steele-parsons opened 6 years ago

riley-steele-parsons commented 6 years ago

Hello. I'm attempting to render a plottable.js rectangle plot within a React app. I repeatedly am seeing the same error:

TypeError
postScale is not a function
postScaledAccesor
./node_modules/plottable/build/src/plots/plot.js:777:42

I've replicated this same error within the Mondrian example inside of a codesandbox, see below.

Bug report

Live example URL: https://codesandbox.io/s/xlqn2mnwyw

Expected behavior

It should render properly.

Actual behavior

It does not.

pasndrp commented 6 years ago

I encountered the same issue while migrating from an old version of plottable to 3.8.x. This can be traced back to changes made to the arguments of the functions Rectangle.prototype.x2 = function (x2, postScale) {...} and Rectangle.prototype.y2 = function (y2, postScale) {...}.

You can fix your example by excluding xScale and yScale respectively from said functions:

...
var plot = new Plottable.Plots.Rectangle();
plot.addDataset(new Plottable.Dataset(data));
plot
   .x(function(d) {
      return d.x;
   }, xScale)
   .y(function(d) {
      return d.y;
   }, yScale)
   .x2(function(d) {
      return d.x2;
   })
   .y2(function(d) {
      return d.y2;
   })
   .attr("fill", function(d) {
      return d.fill;
   })
   .attr("stroke", function() {
      return "#000000";
   })
   .attr("stroke-width", function() {
      return 4;
   });
plot.renderTo(this._rootNode);
...
riley-steele-parsons commented 6 years ago

@themadcreator, can you comment as to whether this is expected behavior?