How to use histfunc in the vertical histogram of a histogram2dcontour

I’m trying to use the “sum” as for my histfunc in a histogram2dcontour with two histograms (one vertical and one horizontal). I’ve learned that if I want to use a histfunc of sum, I need to provide a “z” array for the histogram2dcontour and a “y” array for the horizontal histogram. But what should I provide to the vertical histogram? I mean when I provide the weight array as “x”, it will rotate the histogram which messes it up and if I provide it as “z”, it makes no change to the rendered chart.

You can get a better understanding by looking at the following example:

https://codepen.io/mehranziadloo/pen/KKWRodN

In this example, both charts are showing the same data. It’s just that the one on the left should be showing the count and the right one the sum. While mostly they are correct, the vertical histograms for both are showing the count. So how can I make the vertical histogram show the sum of the data?

I think I found the solution to this problem.

Even for the vertical histogram, you should only use the x and y attributes to provide the data. But to fix the orientation of the chart, you should also mention the orientation attribute as well. Like this:

var trace = {
  x: x,
  y: y,
  orientation: 'h',
  marker: {color: 'rgb(102,0,0)'},
  xaxis: 'x2',
  type: 'histogram',
  histfunc: 'sum',
};