I want to make a pie chart and have looked at the documentation (it's in C, which I do not understand) and am having trouble. I have 8 slices of the pie and I want each a different color. Here is what I have so far, which produces at least one error (comes on the line: series.append("Auto", auto):

Code:

series = QPieSeries() chart = QChart() # Each slice's value auto = self.expensesWindow.piechart[0] employ = self.expensesWindow.piechart[1] ins = self.expensesWindow.piechart[2] hh = self.expensesWindow.piechart[3] house = self.expensesWindow.piechart[4] enter = self.expensesWindow.piechart[5] util = self.expensesWindow.piechart[6] other = self.expensesWindow.piechart[7] # # Set up the pie series.append("Auto", auto) series.append("Employ", employ) series.append("Insurance", ins) series.append("Household", hh) series.append("House", house) series.append("Entertainment", enter) series.append("Utilities", util) series.append("Other)", other) # chart.addSeries(series)

Regarding the color of each slice, I came up with this example for one of the slices (but likely not correct) and don't know where to put it:

To show the chart:

Code:

self.chartView = QChartView(chart) self.ui.gridLayout.addWidget(self.chartView)

I need help getting the construction of the pie chart to work. thanks

I want to make a pie chart and have looked at the documentation (it's in C, which I do not understand) and am having trouble. I have 8 slices of the pie and I want each a different color. Here is what I have so far, which produces at least one error (comes on the line: series.append("Auto", auto):

Code:

series = QPieSeries() chart = QChart() # Each slice's value auto = self.expensesWindow.piechart[0] employ = self.expensesWindow.piechart[1] ins = self.expensesWindow.piechart[2] hh = self.expensesWindow.piechart[3] house = self.expensesWindow.piechart[4] enter = self.expensesWindow.piechart[5] util = self.expensesWindow.piechart[6] other = self.expensesWindow.piechart[7] # # Set up the pie series.append("Auto", auto) series.append("Employ", employ) series.append("Insurance", ins) series.append("Household", hh) series.append("House", house) series.append("Entertainment", enter) series.append("Utilities", util) series.append("Other)", other) # chart.addSeries(series)

Regarding the color of each slice, I came up with this example for one of the slices (but likely not correct) and don't know where to put it:

To show the chart:

Code:

self.chartView = QChartView(chart) self.ui.gridLayout.addWidget(self.chartView)

I need help getting the construction of the pie chart to work. thanks

Added after 1 21 minutes:

UPDATE: I got the pie chart to work (the code was correct - there was an error in the data file), but I still need to know how to make each piece of the pie a color of my choosing.

SOLVED: Thanks for looking

Code:

_slice = series.append("Auto", self.expensesWindow.piechart[0]) _slice = series.append("Employment", self.expensesWindow.piechart[1]) _slice = series.append("Insurance", self.expensesWindow.piechart[2]) _slice = series.append("Household", self.expensesWindow.piechart[3]) _slice = series.append("Housing", self.expensesWindow.piechart[4]) _slice = series.append("Entertainment", self.expensesWindow.piechart[5]) _slice = series.append("Utilities", self.expensesWindow.piechart[6]) _slice = series.append("Other", self.expensesWindow.piechart[7])