title: Is it is possible to reference existing data to create a chart using openpyxl?
body: <p>I have some data that is already in an xlsx sheet. Is it possible to build a chart using openpyxl with this data that already exists in these cells? The data gets updated monthly.</p>
  <p>data</p>
  <pre><code>category    3/1/2021    3/8/2021
  computer    2646        3000
  network     117         200
  other       316         20
  total       3079        3220
  </code></pre>
  <p><a href="https://i.stack.imgur.com/SW0Yr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SW0Yr.png" alt="enter image description here" /></a></p>
  <p>Desired:</p>
  <p>A chart month by month chart next to the data</p>
  <p><a href="https://i.stack.imgur.com/RoUa3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RoUa3.png" alt="enter image description here" /></a></p>
  <p>Doing:</p>
  <pre><code>from datetime import date
  
  from openpyxl import Workbook
  from openpyxl.chart import (
      LineChart,
      Reference,
  )
  from openpyxl.chart.axis import DateAxis
  
  wb = Workbook()
  ws = wb.active
  
  
  
  c2 = LineChart()
  c2.title = &quot;Date Axis&quot;
  c2.style = 12
  c2.y_axis.title = &quot;Size&quot;
  c2.y_axis.crossAx = 500
  c2.x_axis = DateAxis(crossAx=100)
  c2.x_axis.number_format = 'd-mmm'
  c2.x_axis.majorTimeUnit = &quot;days&quot;
  c2.x_axis.title = &quot;Date&quot;
  
  c2.add_data(data, titles_from_data=True)
  dates = Reference(ws, min_col=1, min_row=2, max_row=5)
  c2.set_categories(dates)
  
  ws.add_chart(c2, &quot;E1&quot;)
  </code></pre>
  <p>Any suggestion is appreciated</p>