Merge lp://qastaging/~mrooney/cairoplot/label-formatters into lp://qastaging/cairoplot

Proposed by Michael Rooney
Status: Needs review
Proposed branch: lp://qastaging/~mrooney/cairoplot/label-formatters
Merge into: lp://qastaging/cairoplot
Diff against target: 303 lines (+94/-34)
4 files modified
trunk/cairoplot.py (+48/-27)
trunk/seriestests.py (+21/-7)
trunk/testscripts/compare.sh (+22/-0)
trunk/testscripts/timeit.sh (+3/-0)
To merge this branch: bzr merge lp://qastaging/~mrooney/cairoplot/label-formatters
Reviewer Review Type Date Requested Status
Rodrigo Moreira Araújo Pending
Review via email: mp+30192@code.qastaging.launchpad.net

Description of the change

Add value/label formatters for displaying axis/values as any kind of string such as date, currency, et cetera.

To post a comment you must log in.
Revision history for this message
Rodrigo Moreira Araújo (alf-rodrigo) wrote :
Download full text (13.9 KiB)

Hello there,

As I wasn't too busy, i just reviewed the code. The only thing I didn't get
was the use of this compare.sh script. Why would you like to compare png
files?

Great code btw, merging it soon.

Cheers,

Rodrigo Araujo

2010/7/17 Michael Rooney <email address hidden>

> Michael Rooney has proposed merging lp:~mrooney/cairoplot/label-formatters
> into lp:cairoplot.
>
> Requested reviews:
> Rodrigo Moreira Araújo (alf-rodrigo)
>
>
> Add value/label formatters for displaying axis/values as any kind of string
> such as date, currency, et cetera.
> --
> https://code.launchpad.net/~mrooney/cairoplot/label-formatters/+merge/30192
> You are requested to review the proposed merge of
> lp:~mrooney/cairoplot/label-formatters into lp:cairoplot.
>
> === modified file 'trunk/cairoplot.py'
> --- trunk/cairoplot.py 2009-07-09 21:57:24 +0000
> +++ trunk/cairoplot.py 2010-07-17 21:38:38 +0000
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env python
> +#!/usr/bin/env python
> # -*- coding: utf-8 -*-
>
> # CairoPlot.py
> @@ -288,6 +288,8 @@
> series_legend = False,
> x_labels = None,
> y_labels = None,
> + x_formatter = None,
> + y_formatter = None,
> x_bounds = None,
> y_bounds = None,
> z_bounds = None,
> @@ -303,6 +305,9 @@
> self.titles = {}
> self.titles[HORZ] = x_title
> self.titles[VERT] = y_title
> + self.label_formatters = {}
> + self.label_formatters[HORZ] = x_formatter
> + self.label_formatters[VERT] = y_formatter
> self.max_value = {}
> self.axis = axis
> self.discrete = discrete
> @@ -396,19 +401,17 @@
> self.errors[VERT] = [errory]
>
> def calc_labels(self):
> - if not self.labels[HORZ]:
> - amplitude = self.bounds[HORZ][1] - self.bounds[HORZ][0]
> - if amplitude % 10: #if horizontal labels need floating points
> - self.labels[HORZ] = ["%.2lf" % (float(self.bounds[HORZ][0]
> + (amplitude * i / 10.0))) for i in range(11) ]
> - else:
> - self.labels[HORZ] = ["%d" % (int(self.bounds[HORZ][0] +
> (amplitude * i / 10.0))) for i in range(11) ]
> - if not self.labels[VERT]:
> - amplitude = self.bounds[VERT][1] - self.bounds[VERT][0]
> - if amplitude % 10: #if vertical labels need floating points
> - self.labels[VERT] = ["%.2lf" % (float(self.bounds[VERT][0]
> + (amplitude * i / 10.0))) for i in range(11) ]
> - else:
> - self.labels[VERT] = ["%d" % (int(self.bounds[VERT][0] +
> (amplitude * i / 10.0))) for i in range(11) ]
> -
> + for key in (HORZ, VERT):
> + if not self.labels[key]:
> + amplitude = self.bounds[key][1] - self.bounds[key][0]
> + labels = (self.bounds[key][0] + (amplitude * i / 10.0) for
> i in range(11))
> + if self.label_formatters[key]:
> + self.labels[key] = [self.label_formatters[key](label)
> for label in labels]
> + elif amplitude % 10: #if horizontal labels need floating
> points
> + ...

Revision history for this message
Michael Rooney (mrooney) wrote :

> Hello there,
>
> As I wasn't too busy, i just reviewed the code. The only thing I didn't get
> was the use of this compare.sh script. Why would you like to compare png
> files?
>
> Great code btw, merging it soon.
>

Thanks! That is showing up because it is including the changes from the speedup branch made by Karel, since this branch is a branch of that branch. I believe it was to make sure the generated images after the speedup changes are identical in testing, to what they should be or were before. It may not need to be in version control once you approve the merge, like the timeit.sh script which is just meant to demonstrate the improvements I believe.

If you like and are going to merge that branch anyway, you can merge that one first and I can re-propose a merge based off of that which should be simpler as it would only be r47-49.

Let me know whatever you prefer.

50. By Michael Rooney

make sure value is defined for stacked vertical bar plots

Revision history for this message
Michael Rooney (mrooney) wrote :

Just a note, I committed r50 to fix stacked vertical plots which I likely broke.

Unmerged revisions

50. By Michael Rooney

make sure value is defined for stacked vertical bar plots

49. By Michael Rooney

fix centering of formatted values in a vertical bar plot

48. By Michael Rooney

add support for value formatters to a vertical bar plot

47. By Michael Rooney

add support for x/y label formatters for a scatter plot

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches