[Chart] Specifying sizes

Jorden M jrm3000 at gmx.com
Wed Jan 22 17:35:53 GMT 2014


Here's an example:

The chart equation is lifted directly from the wiki. I think Grid and/or Renderable need to be changed so that they can stretch. I can probably work on it if someone's willing to point me in the right direction.

import Graphics.Rendering.Chart
import Graphics.Rendering.Chart.Backend.Cairo
import Graphics.Rendering.Chart.Grid
import Control.Lens
import Data.Default.Class

chart = toRenderable layout 
  where
    values = [ ("Mexico City",19.2,e), ("Mumbai",12.9,e), ("Sydney",4.3,e), ("London",8.3,e), ("New York",8.2,e1) ]
    e = 0
    e1 = 25
    pitem (s,v,o) = pitem_value .~ v
                  $ pitem_label .~ s
                  $ pitem_offset .~ o
                  $ def
    
    layout = pie_title .~ "Relative Population"
           $ pie_plot . pie_data .~ map pitem values
           $ def

main = do
   
   let g = ((tval chart) .|. (tval chart)) ./.
           (tval chart .|. tval chart)

   renderableToFile def {_fo_size = (1200,1200)} (gridToRenderable g) "file.png"




> ----- Original Message -----
> From: Carter Schonwald
> Sent: 01/22/14 11:22 AM
> To: Jorden M
> Subject: Re: [Chart] Specifying sizes
> 
> have you tried making the overall plot larger?
> 
> 
> On Wed, Jan 22, 2014 at 10:44 AM, Jorden M <jrm3000 at gmx.com> wrote:
> 
> > I took the pie chart example from the wiki and tried to stick several
> > copies of it into a grid, which had the effect of shrinking the charts so
> > much you can't see the pies, just the labelling. I assume this happens with
> > more than just pie charts. I figured there must be something I could fmap
> > into the grid that would set the size of every chart to whatever I wanted,
> > but I don't see anything in Pie, Grid, or Renderable with which I could
> > override the default sizing. Am I missing something simple, or can someone
> > tell me where I should look to make a patch?
> >
> > Thanks,
> > -j
> >
> > _______________________________________________
> > Chart mailing list
> > Chart at projects.haskell.org
> > http://projects.haskell.org/cgi-bin/mailman/listinfo/chart
> >




More information about the Chart mailing list