Example #1
0
 def test1(self):
     b = Bag()
     for k in range(10):
         b.child('drawString',
                 x=k * 10,
                 y=k * 10,
                 text="Hello World from bag _ %s" % str(k))
     self.canvas.drawFromBag(b)
     self.showPage()
Example #2
0
 def gridStruct(self):
     struct = Bag()
     r = struct.child('view').child('rows')
     r.child('cell', field='name', width='20em', name='Name')
     r.child('cell', field='sex', width='2em', name='Sex')
     r.child('cell', field='height', width='3em', name='Height', text_align='right', places=0)
     r.child('cell', field='birthday', width='10em', name='Birthday', format_date='short')
     return struct
Example #3
0
 def bagTest(self):
     result = Bag()
     visbag = result.child('Panel', width='=.width', height='=.height')
     visbag.child('Rule', data='pv.range(0, 2, .5)::JS',
                  bottom='function(d){return d * 80 + .5}::JS').child('Label')
     visbag.child('Bar', data='=.data',
                  width='20', height='function(d){return d * 80}::JS',
                  bottom=0,
                  left='function() {return this.index * 25 + 25}::JS',
                  anchor='bottom').child(tag='Label')
     return result
Example #4
0
 def bagTest(self):
     result = Bag()
     visbag = result.child('Panel', width='=.width', height='=.height')
     visbag.child('Rule', data='pv.range(0, 2, .5)::JS',
                  bottom='function(d){return d * 80 + .5}::JS').child('Label')
     visbag.child('Bar', data='=.data',
                  width='20', height='function(d){return d * 80}::JS',
                  bottom=0,
                  left='function() {return this.index * 25 + 25}::JS',
                  anchor='bottom').child(tag='Label')
     return result
Example #5
0
 def columnsPane(self,where,**kwargs):
     pane=where.accordionPane(**kwargs)
     struct=Bag()
     r=struct.child('view').child('rows')
     r.child('cell',field='col',width='60%',name='Column' )
     r.child('cell',field='as',width='30%',name='As' )
     r.child('cell',field='width',width='10%',name='Width' )
     
     pane.data('.colgrid.structure',struct)
     
     pane.data('.colgrid.data',Bag())
     pane.staticGrid(storepath='.colgrid.data',structpath='.colgrid.structure',identifier='col')
Example #6
0
    def columnsPane(self, where, **kwargs):
        pane = where.accordionPane(**kwargs)
        struct = Bag()
        r = struct.child('view').child('rows')
        r.child('cell', field='col', width='60%', name='Column')
        r.child('cell', field='as', width='30%', name='As')
        r.child('cell', field='width', width='10%', name='Width')

        pane.data('.colgrid.structure', struct)

        pane.data('.colgrid.data', Bag())
        pane.staticGrid(storepath='.colgrid.data',
                        structpath='.colgrid.structure',
                        identifier='col')
Example #7
0
    def source_Area(self):
        result = Bag()

        result.child('env', 'w', 400)
        result.child('env', 'h', 200)
        result.child(
            'env', 'data', """pv.range(0, 10, .1).map(function(x) {
                                            return {x: x, y: Math.sin(x) + Math.random() * .5 + 2};
                                          })""")
        result.child('env', 'sx',
                     "pv.Scale.linear(data, function(d) d.x).range(0, w)")
        result.child('env', 'sy', "pv.Scale.linear(0, 4).range(0, h)")

        visbag = result.child('Panel',
                              width_js='w',
                              height_js='h',
                              bottom=20,
                              left=20,
                              right=10,
                              top=5)
        visbag.child('Rule',
                     data_js='sy.ticks(5)',
                     bottom_js='sy',
                     strokeStyle_fn_d='d ?  "#eee" : "#000"',
                     anchor='left').child('Label', text_js='sy.tickFormat')

        visbag.child('Rule',
                     data_js='sx.ticks()',
                     visible_fn_d='d',
                     left_js='sx',
                     bottom=-5,
                     height=5,
                     anchor='bottom').child('Label', text_js='sx.tickFormat')

        visbag.child('Area',
                     data_js='data',
                     bottom=1,
                     left_fn_d='sx(d.x)',
                     height_fn_d='sy(d.y)',
                     fillStyle="rgb(121,173,210)",
                     anchor="top").child(tag='Line', lineWidth='3')
        return result
Example #8
0
 def source_MouseOver(self):
     result = Bag()
     visbag = result.child('Panel', width='=.width', height='=.height')
     visbag.child('Bar', data='=.data',def_i=-1,
                  width='20', 
                  height_fn_d='d * 80',
                  bottom=0,
                  left_fn='this.index * 25 + 25',
                  anchor='bottom',
                  fillStyle_fn='this.i() == this.index ? "red" : "green"',
                  event_mouseover_fn='this.i(this.index)',
                  event_mouseout_fn='this.i(-1)',
                  title_fn="this.index"
                  )
     return result
Example #9
0
 def source_MouseOver(self):
     result = Bag()
     visbag = result.child('Panel', width='=.width', height='=.height')
     visbag.child('Bar',
                  data='=.data',
                  def_i=-1,
                  width='20',
                  height_fn_d='d * 80',
                  bottom=0,
                  left_fn='this.index * 25 + 25',
                  anchor='bottom',
                  fillStyle_fn='this.i() == this.index ? "red" : "green"',
                  event_mouseover_fn='this.i(this.index)',
                  event_mouseout_fn='this.i(-1)',
                  title_fn="this.index")
     return result
Example #10
0
 def gridStruct(self):
     struct = Bag()
     r = struct.child("view").child("rows")
     r.child("cell", field="name", width="20em", name="Name")
     r.child("cell", field="sex", width="2em", name="Sex")
     r.child(
         "cell",
         field="height",
         width="13em",
         name="Height",
         text_align="right",
         format_pattern="#.#",
         format_currency=False,
     )
     r.child("cell", field="birthday", width="10em", name="Birthday", format_date="short")
     return struct
Example #11
0
 def gridStruct(self):
     struct = Bag()
     r = struct.child('view').child('rows')
     r.child('cell', field='name', width='20em', name='Name')
     r.child('cell', field='sex', width='2em', name='Sex')
     r.child('cell',
             field='height',
             width='3em',
             name='Height',
             text_align='right',
             places=0)
     r.child('cell',
             field='birthday',
             width='10em',
             name='Birthday',
             format_date='short')
     return struct
Example #12
0
    def source_SimpleBar(self):
        result = Bag()
        visbag = result.child('Panel', width='=.width', height='=.height')
        visbag.child('Rule',
                     data_js='pv.range(0, 2, .5)',
                     def_ys='=.ys',
                     bottom_fn_d='d * this.ys() + .5').child('Label')

        visbag.child('Bar',
                     data='=.data',
                     def_ys='=.ys',
                     def_xs='=.xs',
                     width='=.xs',
                     height_fn_d='d * this.ys()',
                     bottom=0,
                     left_fn='this.index * (this.xs() +5) +10',
                     anchor='bottom').child(tag='Label')
        return result
Example #13
0
 def source_SimpleBar(self):
     result = Bag()
     visbag = result.child('Panel', 
                         width='=.width', 
                         height='=.height')
     visbag.child('Rule', 
                  data_js='pv.range(0, 2, .5)',
                  def_ys='=.ys',
                  bottom_fn_d='d * this.ys() + .5').child('Label')
                  
     visbag.child('Bar', data='=.data',
                  
                  def_ys='=.ys',
                  def_xs='=.xs',
                  width='=.xs',
                  height_fn_d='d * this.ys()',
                  bottom=0,
                  left_fn='this.index * (this.xs() +5) +10',
                  anchor='bottom').child(tag='Label')
     return result
Example #14
0
    def source_Area(self):
        result = Bag()
        
        result.child('env','w',400)
        result.child('env','h',200)
        result.child('env','data',"""pv.range(0, 10, .1).map(function(x) {
                                            return {x: x, y: Math.sin(x) + Math.random() * .5 + 2};
                                          })""")
        result.child('env','sx',"pv.Scale.linear(data, function(d) d.x).range(0, w)")
        result.child('env','sy',"pv.Scale.linear(0, 4).range(0, h)")

        visbag = result.child('Panel', 
                            width_js='w', 
                            height_js='h',
                            bottom=20,
                            left=20,
                            right=10,
                            top=5)
        visbag.child('Rule', 
                     data_js='sy.ticks(5)',
                     bottom_js='sy',
                     strokeStyle_fn_d='d ?  "#eee" : "#000"',
                     anchor='left'
                     ).child('Label',text_js='sy.tickFormat')
                     
        visbag.child('Rule', 
                     data_js='sx.ticks()',
                     visible_fn_d='d',
                     left_js='sx',
                     bottom=-5,
                     height=5,
                     anchor='bottom'
                     ).child('Label',text_js='sx.tickFormat')

        visbag.child('Area', data_js='data',
                     bottom=1,
                     left_fn_d='sx(d.x)',
                     height_fn_d='sy(d.y)',
                     fillStyle="rgb(121,173,210)",
                     anchor="top").child(tag='Line',lineWidth='3')
        return result
#/* Sizing and scales. */
#var w = 400,
#    h = 200,
#    x = pv.Scale.linear(data, function(d) d.x).range(0, w),
#    y = pv.Scale.linear(0, 4).range(0, h);
#
#/* The root panel. */
#var vis = new pv.Panel()
#    .width(w)
#    .height(h)
#    .bottom(20)
#    .left(20)
#    .right(10)
#    .top(5);
#
#/* Y-axis and ticks. */
#vis.add(pv.Rule)
#    .data(y.ticks(5))
#    .bottom(y)
#    .strokeStyle(function(d) d ? "#eee" : "#000")
#  .anchor("left").add(pv.Label)
#    .text(y.tickFormat);
#
#/* X-axis and ticks. */
#vis.add(pv.Rule)
#    .data(x.ticks())
#    .visible(function(d) d)
#    .left(x)
#    .bottom(-5)
#    .height(5)
#  .anchor("bottom").add(pv.Label)
#    .text(x.tickFormat);
#
#/* The area with top line. */
#vis.add(pv.Area)
#    .data(data)
#    .bottom(1)
#    .left(function(d) x(d.x))
#    .height(function(d) y(d.y))
#    .fillStyle("rgb(121,173,210)")
#  .anchor("top").add(pv.Line)
#    .lineWidth(3);
#
#vis.render();
#            
#            """
#
#             
Example #15
0
 def test1(self):
     b = Bag()
     for k in range(10):
         b.child('drawString', x=k * 10, y=k * 10, text="Hello World from bag _ %s" % str(k))
     self.canvas.drawFromBag(b)
     self.showPage()