Skip to main content
Version: 1.0.0

Histogram

Shows the frequency distribution of a variable by dividing it into bins. This provides a visual representation of the shape and spread of the data distribution. It is useful for understanding the underlying probability distribution of a variable, identifying potential outliers, and comparing the distributions of different variables.

Chart:


Code:

  const { muze, getDataFromSearchQuery } = viz;
  
  const data = getDataFromSearchQuery();

  const ColumnField = "Horsepower(BIN)";
  const RowField = "Horsepower";

  muze
    .canvas()
    .columns([ColumnField])
    .rows([RowField])
    .layers([
      {
        mark: "bar",
        encoding: {
          color: RowField,
        },
      },
    ])
    .config({
      axes: {
        x: {
          compact: true,
          labels: {
            rotation: 0,
          },
          bins: {
            display: "startValue",
            position: "start",
          },
        },
      },
    })
    .data(data)
    .mount("#chart"); // mount your chart