I am trying to set a field value using a basic calculation that uses values set in my constructor, though for some reason when i reference some of the values initialised in my constructor, i get TypeError: Cannot read property of undefined.
Though when i reference this
without trying to access any of the values set in my constructor (margin or dimension) , i do not get this error and can see the initialised object.
class viz {
constructor(dimension, margin) {
this.dimension = dimension;
this.margin = margin;
}
width = this.dimension.width - this.margin.left - this.margin.right;
height = this.dimension.height - this.margin.top - this.margin.bottom;
}
const margin = { left: 40, right: 40, top: 40, bottom: 20 };
const dimension = { width: 1000, height: 600 };
let visual = new viz(dimension,margin)