1

I have a little problem. When I add a dataset (that is a list) to a chart (pychart), i can only give to data one color on the final chart. I would have different colors depending on list element's value.

How can I do that ?

I attach my code.

c = self._setAxis(xy=(750, 430 + ystep), tuplot=(150, 50, 400, 200 + ystep), labels=labels,\
                        xtitle=PERCENTUALE_CHIUSURA_PERIODO_T_Y[self.id_user_lang],
                              ytitle=PERCENTUALE_CHIUSURA_T_Y[self.id_user_lang],\
                        title=PERCENTUALE_CHIUSURA_PERIODO_T_T[self.id_user_lang] + ' (' + str(media) + ')')

lay = self._setLay(c, left_right=False)

graphData = [hotel['Percentuale'][0] for hotel in results]

lay.addDataSet(graphData, COL_PREN)

c.swapXY()

filname= self.random_file()
c.makeChart(filname)
res.append(self.url_file(filname))
Tom Zych
  • 13,329
  • 9
  • 36
  • 53
DonCallisto
  • 29,419
  • 9
  • 72
  • 100

1 Answers1

0

I assume COL_PREN is your color? You could try separating your hotels into separate datasets. Something like:

for hotel in results:
    lay.addDataSet([hotel['Percentuale'][0]], get_color_for_hotel(hotel))
jcdyer
  • 18,616
  • 5
  • 42
  • 49
  • Yes, COL_PREN is my color. I can't split my data into small ones because addDataSet accept only a list that have to be of the same size of labels that you insert with setAxis. – DonCallisto Sep 16 '11 at 13:47