class_docstr: **Bases:** :class:`AxisItem <pyqtgraph.AxisItem>`
  
  An AxisItem that displays dates from unix timestamps.
  
  The display format is adjusted automatically depending on the current time
  density (seconds/point) on the axis. For more details on changing this
  behaviour, see :func:`setZoomLevelForDensity() <pyqtgraph.DateAxisItem.setZoomLevelForDensity>`.
  
  Can be added to an existing plot e.g. via 
  :func:`setAxisItems({'bottom':axis}) <pyqtgraph.PlotItem.setAxisItems>`.
class_docstr_tok: ["*","*","Bases",":","*","*",":","class",":","`","AxisItem","<","pyqtgraph.AxisItem",">","`","An","AxisItem","that","displays","dates","from","unix","timestamps",".","The","display","format","is","adjusted","automatically","depending","on","the","current","time","density","(","seconds\/point",")","on","the","axis",".","For","more","details","on","changing","this","behaviour",",","see",":","func",":","`","setZoomLevelForDensity","(",")","<","pyqtgraph.DateAxisItem.setZoomLevelForDensity",">","`",".","Can","be","added","to","an","existing","plot","e.g",".","via",":","func",":","`","setAxisItems","(","{","'bottom","'",":","axis","}",")","<","pyqtgraph.PlotItem.setAxisItems",">","`","."]
docstr: Setting `zoomLevel` and `minSpacing` based on given density of seconds per pixel
  
  The display format is adjusted automatically depending on the current time
  density (seconds/point) on the axis. You can customize the behaviour by 
  overriding this function or setting a different set of zoom levels
  than the default one. The `zoomLevels` variable is a dictionary with the
  maximal distance of ticks in seconds which are allowed for each zoom level
  before the axis switches to the next coarser level. To customize the zoom level
  selection, override this function.
docstr_tok: ["Setting","`","zoomLevel","`","and","`","minSpacing","`","based","on","given","density","of","seconds","per","pixel","The","display","format","is","adjusted","automatically","depending","on","the","current","time","density","(","seconds\/point",")","on","the","axis",".","You","can","customize","the","behaviour","by","overriding","this","function","or","setting","a","different","set","of","zoom","levels","than","the","default","one",".","The","`","zoomLevels","`","variable","is","a","dictionary","with","the","maximal","distance","of","ticks","in","seconds","which","are","allowed","for","each","zoom","level","before","the","axis","switches","to","the","next","coarser","level",".","To","customize","the","zoom","level","selection",",","override","this","function","."]
code: def setZoomLevelForDensity(self, density):
      """
      Setting `zoomLevel` and `minSpacing` based on given density of seconds per pixel
  
      The display format is adjusted automatically depending on the current time
      density (seconds/point) on the axis. You can customize the behaviour by
      overriding this function or setting a different set of zoom levels
      than the default one. The `zoomLevels` variable is a dictionary with the
      maximal distance of ticks in seconds which are allowed for each zoom level
      before the axis switches to the next coarser level. To customize the zoom level
      selection, override this function.
      """
      padding = 10
  
      # Size in pixels a specific tick label will take
      if self.orientation in ["bottom", "top"]:
  
          def sizeOf(text):
              return (
                  self.fontMetrics.boundingRect(text).width() + padding
              )
  
      else:
  
          def sizeOf(text):
              return (
                  self.fontMetrics.boundingRect(text).height() + padding
              )
  
      # Fallback zoom level: Years/Months
      self.zoomLevel = YEAR_MONTH_ZOOM_LEVEL
      for maximalSpacing, zoomLevel in self.zoomLevels.items():
          size = sizeOf(zoomLevel.exampleText)
  
          # Test if zoom level is too fine grained
          if maximalSpacing / size < density:
              break
  
          self.zoomLevel = zoomLevel
  
      # Set up zoomLevel
      self.zoomLevel.utcOffset = self.utcOffset
  
      # Calculate minimal spacing of items on the axis
      size = sizeOf(self.zoomLevel.exampleText)
      self.minSpacing = density * size
  
imports: import sys
  import time
  from collections import OrderedDict
  from datetime import datetime, timedelta, timezone
  import numpy
  from .AxisItem import AxisItem
label_desc: Use image node_id 4 for calling the DateAxisItem obj's underlying member method code with example usage: obj.setZoomLevelForDensity(density) and returns: unknown, unknown