OpenpyxlのLineChart()機能を使用して、好きなようにグラフを描画する際に問題があります。openpyxlで線グラフを描画する - 軸/描画の問題
the official pageのドキュメントを使用していますが、があります。
これは望ましい結果(ただ、私はそれをスタイルすることができ、データ・ポイントが正しい取得する必要があり、カラー/書式設定を無視する):私はにデータを再配置しようとした
縦彼らは文書で証明するのと同じ方法でmasterListリスト内のスライスが、私はグラフが実際
for i in masterList:
#print ("Appending ", i, "to the sheet")
sheet.append(i)
セクション、そして下の行の間でデータをどのように使用するかを理解していない:
data = Reference(sheet, min_col = 4, min_row = 7, max_col = currentCell, max_row = 28)
以下の全体機能。 version = "v1.9"、currentCell =データがある日付の数、sheetはワークブック内の現在アクティブなワークシートです。
def drawChart(self, sheet, currentCell, version):
print ("CurrentCell = ", currentCell)
### Get the chart data
dateData, versionData, versionXABData = ([] for i in range(3)) #Make 3 lists
for i in range(currentCell):
temp = sheet.cell(row = 7, column = 4+i).value
if not temp:
temp = 0
dateData.append(temp)
else: dateData.append(temp) #Put the dates in a list
for i in range(currentCell):
temp = sheet.cell(row = 28, column = 4+i).value
if not temp:
temp = 0
versionData.append(temp)
else: versionData.append(temp) #Put the version Totals in another
for i in range(currentCell):
temp = sheet.cell(row = 27, column = 4+i).value
if not temp:
temp = 0
versionXABData.append(temp)
else: versionXABData.append(temp) #Put the version XAB bugs in another
print ("Dates are: ", dateData, '\n', "VersionData is: ",versionData, '\n', "Version XAB is: ", versionXABData, '\n')
masterList = [list() for i in range(currentCell)] #Make a list containing the total number of empty lists for each day we have data for
masterList[0].append("Date")
masterList[0].append("Total "+ version +" Bugs")
masterList[0].append("Total "+ version +" XAB Bugs")
print (masterList[0])
for i in range(1, currentCell):
#print (" Length of dataData = ", len(dateData), '\n', "Length of versionData = ", len(versionData), '\n', "Length of versionXABData = ", len(versionXABData), '\n',"i = ", i)
masterList[i].append(dateData[i])
masterList[i].append(versionData[i])
masterList[i].append(versionXABData[i])
for i in masterList:
#print ("Appending ", i, "to the sheet")
sheet.append(i)
chart1 = LineChart()
chart1.title = "DoT Bug Burndown"
chart1.style = 13
chart1.y_axis.title = "No of Bugs"
chart1.x_axis.title = "Date"
chart1.width = 30
chart1.height = 20
data = Reference(sheet, min_col = 4, min_row = 7, max_col = currentCell, max_row = 28)
chart1.add_data(data, titles_from_data=True)
sheet.add_chart(chart1, "K31")
*希望の方法でグラフを描くことができます* ** < - **実際に出力が期待されるものは誰でも推測する必要がありますそのように見えるように... –
あなたは日付でプロットしたいように見えるので、 'PlotBy'引数を変更する必要があります(openpyxlで何が呼び出されているかはわかりません)。*スクリーンショットは*日付です。 –
ありがとうございました! 希望の結果を表示するスクリーンショットを追加しました。 PlotBy引数を今調査します。 –