override def draw()

in atlas-chart/src/main/scala/com/netflix/atlas/chart/graphics/TimeSeriesGraph.scala [109:186]


  override def draw(g: Graphics2D, x1: Int, y1: Int, x2: Int, y2: Int): Unit = {

    val leftAxisW = yaxes.head.width
    val rightAxisW = yaxes.tail.foldLeft(0) { (acc, axis) =>
      acc + axis.width
    }
    val rightSideW = if (rightAxisW > 0) rightAxisW else TimeSeriesGraph.minRightSidePadding
    val axisW = leftAxisW + rightSideW
    val width = x2 - x1 - axisW

    val showAxes = !graphDef.onlyGraph && width >= GraphConstants.MinCanvasWidth
    val leftOffset = if (showAxes) leftAxisW else TimeSeriesGraph.minRightSidePadding
    val rightOffset = if (showAxes) rightSideW else TimeSeriesGraph.minRightSidePadding

    val timeAxisH = if (graphDef.onlyGraph) 10 else timeAxis.height
    val timeGrid = TimeGrid(timeAxis, graphDef.theme.majorGrid.line, graphDef.theme.minorGrid.line)

    val chartEnd = y2 - timeAxisH * timeAxes.size

    val prevClip = g.getClip
    clip(g, x1 + leftOffset, y1, x2 - rightOffset, chartEnd + 1)
    graphDef.plots.zip(yaxes).zipWithIndex.foreach {
      case ((plot, axis), i) =>
        heatmaps.get(i).foreach { heatmap =>
          val element = TimeSeriesHeatmap(heatmap)
          element.draw(g, x1 + leftOffset, y1, x2 - rightOffset, chartEnd)
        }

        val offsets = TimeSeriesStack.Offsets(timeAxis)
        plot.renderedLines.foreach { line =>
          val style = Style(color = line.color, stroke = new BasicStroke(line.lineWidth))
          val lineElement = line.lineStyle match {
            case LineStyle.LINE  => TimeSeriesLine(style, line.data.data, timeAxis, axis)
            case LineStyle.AREA  => TimeSeriesArea(style, line.data.data, timeAxis, axis)
            case LineStyle.VSPAN => TimeSeriesSpan(style, line.data.data, timeAxis)
            case LineStyle.STACK => TimeSeriesStack(style, line.data.data, timeAxis, axis, offsets)
            case LineStyle.HEATMAP => throw new IllegalStateException()
          }

          lineElement.draw(g, x1 + leftOffset, y1, x2 - rightOffset, chartEnd)
        }

        plot.horizontalSpans.foreach { hspan =>
          val style = Style(color = hspan.color)
          val spanElement = ValueSpan(style, hspan.v1, hspan.v2, axis)
          spanElement.draw(g, x1 + leftOffset, y1, x2 - rightOffset, chartEnd)
        }

        plot.verticalSpans.foreach { vspan =>
          val style = Style(color = vspan.color)
          val spanElement = TimeSpan(style, vspan.t1.toEpochMilli, vspan.t2.toEpochMilli, timeAxis)
          spanElement.draw(g, x1 + leftOffset, y1, x2 - rightOffset, chartEnd)
        }
    }
    g.setClip(prevClip)

    timeGrid.draw(g, x1 + leftOffset, y1, x2 - rightOffset, chartEnd)

    if (!graphDef.onlyGraph) {
      timeAxes.zipWithIndex.foreach {
        case (axis, i) =>
          val offset = chartEnd + 1 + timeAxisH * i
          axis.draw(g, x1 + leftOffset, offset, x2 - rightOffset, y2)
      }
    }

    val valueGrid =
      ValueGrid(yaxes.head, graphDef.theme.majorGrid.line, graphDef.theme.minorGrid.line)
    valueGrid.draw(g, x1 + leftOffset, y1, x2 - rightOffset, chartEnd)
    if (showAxes) {
      yaxes.head.draw(g, x1, y1, x1 + leftAxisW - 1, chartEnd)
      yaxes.tail.zipWithIndex.foreach {
        case (axis, i) =>
          val offset = leftAxisW + width + leftAxisW * i
          axis.draw(g, x1 + offset, y1, x1 + offset + leftAxisW, chartEnd)
      }
    }
  }