code: def to_chart(self):
          
          encoding, properties = {}, {}
  
          if self.orientation == "horizontal":
              # Set the axis
              encoding["x"] = alt.X(
                  "hex",
                  axis=None,
                  scale=alt.Scale(zero=False, padding=0)
              )
  
              # Set the rectangle size.
              properties["width"] = len(self.df)*self.square_size
              properties["height"] = self.square_size
  
          elif self.orientation == "vertical":
              # Set the axis
              encoding["y"] = alt.Y(
                  "hex",
                  axis=None,
                  scale=alt.Scale(zero=False, padding=0)
              )
  
              # Set the rectangle size.
              properties["height"] = len(self.df)*self.square_size
              properties["width"] = self.square_size
  
          # Build a chart.
          tooltip = list(self.df.columns)
          chart = alt.Chart(self.df).mark_rect().encode(
              color=alt.Color("hex", legend=None, scale=alt.Scale(range=self.colors)),
              tooltip=tooltip,
              **encoding
          ).properties(
              **properties
          )
          return chart
docs: Write color palette to Altair Chart.