[reportlab-users] From intra-paragraph images to drawings?

Robin Becker robin at reportlab.com
Wed May 8 11:59:46 EDT 2013


On 08/05/2013 10:53, Dinu Gherman wrote:

> Hi,

>

> I wonder if anybody has tried to generalize the concept of intra-para-

> graph images to drawings? This would enable nice features like something

> called "sparklines", which have been introduced by Edward R. Tufte, if

> I'm not mistaken. See also this nice jQuery package:

>


I don't think it would be too hard to make a drawing produce an image that could
be injected into a paragraph. The main problem would be how to identify the
chart code and data in a sensible way. The img tags have a lot of control over
height / width etc etc, but they don't need much more than a uri to identify
them. Presumably one could inject a namespace into the parser somehow as is done
for various other cases eg callbacks are identified by name and are assumed to
live directly on the canvas


> func = getattr(tx._canvas,name,None)

> if not func:

> raise AttributeError("Missing %s callback attribute '%s'" % (kind,name))

> tx._canvas._curr_tx_info=dict(tx=tx,cur_x=cur_x,cur_y=cur_y,leading=leading,xs=tx.XtraState)

> try:

> func(tx._canvas,kind,cbDefn.label)

> finally:

> del tx._canvas._curr_tx_info


that might work for a drawable object



> http://omnipotent.net/jquery.sparkline


I looked at the front page and it looks OK, but I wasn't able to see how
data/chart type were selected for the charts; one of the paras is described thus


> <p>

> Inline

> <span class="sparkline">

> <canvas style="display: inline-block; width: 21px; height: 16px; vertical-align: top;" width="21" height="16"></canvas>

> </span>

> line graphs

> <span class="sparkline">

> <canvas style="display: inline-block; width: 63px; height: 16px; vertical-align: top;" width="63" height="16"></canvas>

> </span>

> </p>


but the two charts are different so I guess the data / chart is being pushed
into them via the class.



> Regards,

>

> Dinu

........

--
Robin Becker


More information about the reportlab-users mailing list