Commits

Ralph Bean  committed 5dac9f6

moved text trimming out of the core

  • Participants
  • Parent commits acbdacc

Comments (0)

Files changed (3)

 
 setup(
     name='tw2.protovis.custom',
-    version='0.1.a1',
+    version='0.1.a2',
     description='toscawidgets2 wrapper for the stanford protovis toolkit',
     long_description=long_description,
     author='Ralph Bean',

File tw2/protovis/custom/samples.py

                     or file.endswith('.swp')):
                     continue
                 nodename = "%s/%s" % (dir, file)
+                value = int(os.path.getsize(nodename)) + 1
+                clip = int(math.sqrt(value)/50.0) # trim text based on value
                 self.p_data.append({
                     'name' : nodename,
-                    'value' : int(os.path.getsize(nodename)) + 1,
-                    'text' : nodename.split('/')[-1],
+                    'value' : value,
+                    'text' : nodename.split('/')[-1][:clip],
                     'group' : "/".join(nodename.split('/')[:-1]),
                 })
         super(DemoBubbleChart, self).prepare()

File tw2/protovis/custom/widgets.py

             .visible(js('function(d) d.parentNode')) \
             .title(js('function(d) d.nodeValue.name + ": " + format(d.nodeValue.value)')) \
           .anchor("center").add(pv.Label) \
-            .text(
-        js('function(d) d.nodeValue.text.substring(0, Math.sqrt(d.nodeValue.value/25.0) >> 4)'))
+            .text(js('function(d) d.nodeValue.text'))