Histogram from object fields

Hello,

I’m trying to build histogram from a list of object. Each object got a date in string format and a value which correspond to the height of the associated bar in the histogram.

When i’m giving my two values to x and y in the histogram, while the x value is correct, i have a value of 1 for y (instead of 14 in my test). Why is that ?

Here is my try

> <script type="text/javascript">
>     function loadGraph() {   
>         var source = JSON.parse($('.id_hiddenField').val());
>         var x = source.map(function(a) {return a.Date});
>         var y = source.map(function (a) { return a.Value });

>         //if (source != null) {
>         var data = [
>                 {
>                     x: x,
>                     y: y,
>                     type: 'histogram',
>                     marker: {
>                         color: 'rgba(100,250,100,0.7)',
>                     }
>                 }
>         ];
>         Plotly.newPlot('TestChart', data, {displayModeBar: false});
>         //}
>     }
> </script>

What am i doing wrong ?

Solved, i didn’t realize i wanted a Bar chart and not an histogram…

1 Like