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))
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))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.