# Plotly.js heatmap DATA.ZMAX CHANGE?

**URL:** <https://community.plotly.com/t/plotly-js-heatmap-data-zmax-change/1772>\
**Category:** plotly.js\
**Created:** [August 9, 2016, 11:28am UTC](https://community.plotly.com/t/plotly-js-heatmap-data-zmax-change/1772 "2016-08-09T11:28:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![min](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@min](https://community.plotly.com/u/min)\
**Post date:** [August 9, 2016, 11:28am UTC](https://community.plotly.com/t/plotly-js-heatmap-data-zmax-change/1772/1 "2016-08-09T11:28:42Z")

</div>

I have an input field that shows max Z value of the heatmap. On change of this value i call the following function:  
function adaptScale () {  
$scope.data.zmax = $scope.maxZvalue;  
Plotly.newPlot($element[0].children[0], $scope.data);  
}

I get the following error:

 ![](https://us1.discourse-cdn.com/flex024/uploads/plot/original/1X/afe75aab46bbf009090045f7d789bd32089a70d3.png)

---

<div class="post-metadata">

**Author:** ![min](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@min](https://community.plotly.com/u/min)\
**Post date:** [August 9, 2016, 1:38pm UTC](https://community.plotly.com/t/plotly-js-heatmap-data-zmax-change/1772/2 "2016-08-09T13:38:29Z")

</div>

Solution:

```
function adaptScale () {
  if($scope.maxZvalue && $scope.maxZvalue != 0){
    var layout = $element[0].children[0].layout;
    $scope.data.zmax = $scope.maxZvalue;
    $scope.data.zmin = -Math.abs($scope.maxZvalue);
    Plotly.newPlot($element[0].children[0], [$scope.data], layout);
  }
}
```

---

<div class="post-metadata">

**Author:** ![etienne](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/etienne/32/17_2.png) [@etienne](https://community.plotly.com/u/etienne)\
**Post date:** [August 9, 2016, 3:06pm UTC](https://community.plotly.com/t/plotly-js-heatmap-data-zmax-change/1772/3 "2016-08-09T15:06:42Z")

</div>

Correct. The second argument (`data`) to `Plotly.newPlot` must be an array.
