/+junk/pygooglechart-py3k

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/pygooglechart-py3k

« back to all changes in this revision

Viewing changes to pygooglechart.py

  • Committer: gak
  • Date: 2008-05-01 02:26:12 UTC
  • Revision ID: git-v1:876d3c39497bd316bd4f1bb15782f391a8c8faa5
pep8 fixes, version bump

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
# Helper variables and functions
31
31
# -----------------------------------------------------------------------------
32
32
 
33
 
__version__ = '0.2.0'
 
33
__version__ = '0.2.1'
34
34
 
35
35
reo_colour = re.compile('^([A-Fa-f0-9]{2,2}){3,4}$')
36
36
 
102
102
        clipped = cls.clip_value(scaled)
103
103
        return clipped
104
104
 
 
105
 
105
106
class SimpleData(Data):
 
107
 
106
108
    enc_map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
107
109
 
108
110
    def __repr__(self):
125
127
    def max_value():
126
128
        return 61
127
129
 
 
130
 
128
131
class TextData(Data):
129
132
 
130
133
    def __repr__(self):
161
164
    def scale_value(cls, value, range):
162
165
        # use float values instead of integers because we don't need an encode
163
166
        # map index
164
 
        scaled = cls.float_scale_value(value,range)
 
167
        scaled = cls.float_scale_value(value, range)
165
168
        clipped = cls.clip_value(scaled)
166
169
        return clipped
167
170
 
 
171
 
168
172
class ExtendedData(Data):
169
173
    enc_map = \
170
174
        'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.'
559
563
 
560
564
    def set_axis_labels(self, axis_type, values):
561
565
        assert(axis_type in Axis.TYPES)
562
 
        values = [ urllib.quote(a) for a in values ]
 
566
        values = [urllib.quote(a) for a in values]
563
567
        axis_index = len(self.axis)
564
568
        axis = LabelAxis(axis_index, axis_type, values)
565
569
        self.axis.append(axis)
675
679
            # markers.
676
680
            yield ('marker-size', self.data[2])
677
681
 
 
682
 
678
683
class LineChart(Chart):
679
684
 
680
685
    def __init__(self, *args, **kwargs):
681
686
        assert(type(self) != LineChart)  # This is an abstract class
682
687
        Chart.__init__(self, *args, **kwargs)
683
688
 
684
 
#    def get_url_bits(self, data_class=None):
685
 
#        url_bits = Chart.get_url_bits(self, data_class=data_class)
686
 
#        return url_bits
687
 
 
688
689
 
689
690
class SimpleLineChart(LineChart):
690
691
 
696
697
        for dataset in self.data:
697
698
            yield ('y', dataset)
698
699
 
 
700
 
699
701
class SparkLineChart(SimpleLineChart):
700
702
 
701
703
    def type_to_url(self):
702
704
        return 'cht=ls'
703
705
 
 
706
 
704
707
class XYLineChart(LineChart):
705
708
 
706
709
    def type_to_url(self):
714
717
            else:
715
718
                yield ('y', dataset)
716
719
 
 
720
 
717
721
class BarChart(Chart):
718
722
 
719
723
    def __init__(self, *args, **kwargs):
782
786
            skip_chbh=True)
783
787
        if self.group_spacing is not None:
784
788
            if self.bar_spacing is None:
785
 
                raise InvalidParametersException('Bar spacing is required to ' \
786
 
                    'be set when setting group spacing')
 
789
                raise InvalidParametersException('Bar spacing is required ' \
 
790
                    'to be set when setting group spacing')
787
791
            if self.bar_width is None:
788
792
                raise InvalidParametersException('Bar width is required to ' \
789
793
                    'be set when setting bar spacing')
865
869
    def type_to_url(self):
866
870
        return 'cht=r'
867
871
 
 
872
 
868
873
class SplineRadarChart(RadarChart):
869
874
 
870
875
    def type_to_url(self):
963
968
 
964
969
if __name__ == '__main__':
965
970
    test()
966