Warning: Can't synchronize with the repository (Unsupported version control system "svn". Check that the Python support libraries for "svn" are correctly installed.)

Ticket #19 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

pyCha 0.4.1, piechart.py (from an example folder) doesn't run properly

Reported by: vadim.pestovnikov@… Owned by: somebody
Priority: major Milestone:
Component: component1 Version:
Keywords: Cc:

Description

user@lab:~/pycha-0.4.1/examples$ python piechart.py Traceback (most recent call last):

File "piechart.py", line 59, in <module>

pieChart(output)

File "piechart.py", line 53, in pieChart

chart.render()

File "build/bdist.linux-i686/egg/pycha/chart.py", line 89, in render File "build/bdist.linux-i686/egg/pycha/chart.py", line 137, in

_update

File "build/bdist.linux-i686/egg/pycha/pie.py", line 66, in

_updateTicks KeyError?: 0

Change History

Changed 4 years ago by aprzywecki@…

I can verify this bug. A workaround is to change 'ticks' for 'x' in Options to 'tick'. For example:

options = {

'axis': {

'x': {

'ticks': [dict(v=i, label=d[0]) for i, d in enumerate(lines)]

The above fails.

options = {

'axis': {

'x': {

'tick': [dict(v=i, label=d[0]) for i, d in enumerate(lines)]

The above works.

The offending code is:

if self.options.axis.x.ticks:

lookup = dict([(slice.name, slice) for slice in self.slices]) for tick in self.options.axis.x.ticks:

if not isinstance(tick, Option):

tick = Option(tick)

slice = lookup[tick.v]

label = tick.label or str(tick.v)

if slice:

label += ' (%.1f%%)' % (slice.fraction * 100) self.xticks.append((tick.v, label))

slice = lookup[tick.v] produces the key error.

Changed 4 years ago by aprzywecki@…

Just a bit more information.

lookup = dict([(slice.name, slice) for slice in self.slices])

This produces a lookup with labels as keys. For example: {'5.9': <pie.Slice object at 0x8b53cac>, '50': <pie.Slice object at 0x8b53d2c>, '35': <pie.Slice object at 0x8b53d0c>}

slice = lookup[tick.v]

This tries to get the slice using the index v, which fails. {'v': 0, 'label': '5.9'}

The key for the slice object is the tick.label, not tick.v.

Changed 4 years ago by anonymous

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.