[Chart] Specifying sizes
Tim Docker
tim at dockerz.net
Thu Jan 23 10:05:58 GMT 2014
Correction. I intended to say
"there's no reason _not_ to use it outside the library"
Tim
On 23 Jan 2014 07:27, "Tim Docker" <tim at dockerz.net> wrote:
> Hi Jorden.
>
> The Grid type was created to facilitate the internal layout of plots (ie
> allocating space to the axes, title, plot area etc). However, there's no
> reason to use it outside the library.
>
> When the rendering area is bigger than the minimum size of the
> renderables, the extra space is allocated to the renderables according to
> their weights. In your example below, your grid cells have weights of 0
> (the default), which means that no extra space is allocated. If you set all
> the weights to 1, by replacing with this:
>
> let g0 = ((tval chart) .|. (tval chart)) ./. (tval chart .|. tval chart)
> let g = weights (1,1) g0
>
> you will see the output you expect.
>
> Tim
>
> On 23/01/14 04:35, Jorden M wrote:
>
>> 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
>>>>
>>>>
>> _______________________________________________
>> Chart mailing list
>> Chart at projects.haskell.org
>> http://projects.haskell.org/cgi-bin/mailman/listinfo/chart
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://projects.haskell.org/pipermail/chart/attachments/20140123/ab0d6a36/attachment-0001.htm>
More information about the Chart
mailing list