timbod7 / haskell-chart

A 2D charting library for haskell
429 stars 85 forks source link

Is it possible to fix Chart-diagrams to work with SVGFonts 1.8 #232

Closed expipiplus1 closed 2 years ago

expipiplus1 commented 2 years ago

There are a few breaking changes which need to be accommodated. I had a glance at fixing these but some were non-obvious.

Graphics/Rendering/Chart/Backend/Diagrams.hs:398:59: error:
    Not in scope: ‘F.textSVG'’
    Perhaps you meant ‘F.textSVG’ (imported from Graphics.SVGFonts)
    Neither ‘Graphics.SVGFonts’,
            ‘Graphics.SVGFonts.CharReference’ nor ‘Graphics.SVGFonts.ReadFont’ exports ‘textSVG'’.
    |
398 |                 { textSizeWidth = realToFrac $ D2.width $ F.textSVG' (fontStyleToTextOpts env) text
    |                                                           ^^^^^^^^^^

Graphics/Rendering/Chart/Backend/Diagrams.hs:418:12: error:
    Not in scope: ‘F.textSVG_’
    Perhaps you meant ‘F.textSVG’ (imported from Graphics.SVGFonts)
    Neither ‘Graphics.SVGFonts’,
            ‘Graphics.SVGFonts.CharReference’ nor ‘Graphics.SVGFonts.ReadFont’ exports ‘textSVG_’.
    |
418 |          $ F.textSVG_ (fontStyleToTextOpts env) text
    |            ^^^^^^^^^^

Graphics/Rendering/Chart/Backend/Diagrams.hs:578:9: error:
    Not in scope: ‘F.mode’
    Neither ‘Graphics.SVGFonts’,
            ‘Graphics.SVGFonts.CharReference’ nor ‘Graphics.SVGFonts.ReadFont’ exports ‘mode’.
    |
578 |       , F.mode = F.INSIDE_H
    |         ^^^^^^

Graphics/Rendering/Chart/Backend/Diagrams.hs:578:18: error:
    Not in scope: data constructor ‘F.INSIDE_H’
    Neither ‘Graphics.SVGFonts’,
            ‘Graphics.SVGFonts.CharReference’ nor ‘Graphics.SVGFonts.ReadFont’ exports ‘INSIDE_H’.
    |
578 |       , F.mode = F.INSIDE_H
    |                  ^^^^^^^^^^

Graphics/Rendering/Chart/Backend/Diagrams.hs:581:9: error:
    Not in scope: ‘F.textWidth’
    Neither ‘Graphics.SVGFonts’,
            ‘Graphics.SVGFonts.CharReference’ nor ‘Graphics.SVGFonts.ReadFont’ exports ‘textWidth’.
    |
581 |       , F.textWidth = 1
    |         ^^^^^^^^^^^

Graphics/Rendering/Chart/Backend/Diagrams.hs:582:9: error:
    Not in scope: ‘F.textHeight’
    Neither ‘Graphics.SVGFonts’,
            ‘Graphics.SVGFonts.CharReference’ nor ‘Graphics.SVGFonts.ReadFont’ exports ‘textHeight’.
    |
582 |       , F.textHeight = scaledH -- _font_size fs
    |         ^^^^^^^^^^^^
timbod7 commented 2 years ago

I've always used stack to build the chart library, and note that https://www.stackage.org/lts-16.31 was the last lts release to include SVGfonts. I note that even the most recent nightly release doesn't include SVGFonts ?

expipiplus1 commented 2 years ago

Yeah, it's regrettable that SVGFonts has dropped off Stackage, although I guess if it's ever put back in it'll be the latest version.

byorgey commented 2 years ago

Just wanted to mention here that I put together a migration guide for SVGFonts-1.8: https://github.com/diagrams/SVGFonts#porting-to-version-18 . If you like, I'd be happy to help put together a PR to update Chart.

timbod7 commented 2 years ago

Thanks @byorgey. I'll take a look at the migration advice.

simonmichael commented 2 years ago

+1, a release supporting current SVGFonts (and ideally, SVGFonts and Chart back in stackage) would help with hls packaging.

414owen commented 2 years ago

It looks like @bravit made a revision to 1.9.3 that enabled SVGFonts 1.8: https://hackage.haskell.org/package/Chart-diagrams-1.9.3/revisions/

I'm still seeing errors (mainly Not in scope: ‘F.textSVG') though.

Am I missing something? I've set a bound in my project to < 1.8 to work around it.
I don't see any changes on master that would fix charts-diagrams for SVGFonts 1.8

byorgey commented 2 years ago

Note that SVGFonts is back in Stackage now. My offer from above to help put together a PR to update Chart still stands. At this point maybe I will just put a PR together and see where it goes from there.

bravit commented 2 years ago

Thanks, @byorgey, I'll look into this today.

bravit commented 2 years ago

Fixed with https://github.com/timbod7/haskell-chart/commit/91d82bf719d93e3092fc6e2087a62f24b14b0b76