Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oswald2/chart-fltkhs
FLTKHS backend for the Chart Haskell library.
https://github.com/oswald2/chart-fltkhs
chart fltk fltkhs haskell
Last synced: 29 days ago
JSON representation
FLTKHS backend for the Chart Haskell library.
- Host: GitHub
- URL: https://github.com/oswald2/chart-fltkhs
- Owner: oswald2
- License: bsd-3-clause
- Created: 2019-06-12T20:42:29.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-13T16:14:09.000Z (over 4 years ago)
- Last Synced: 2025-01-08T20:22:10.246Z (29 days ago)
- Topics: chart, fltk, fltkhs, haskell
- Language: Haskell
- Size: 73.2 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Chart-fltkhs
FLTKHS backend for the Chart Haskell library.
Builds the library and (if specified) the examples, which resemble the examples from https://github.com/timbod7/haskell-chart/wiki.
**Note:** *Transparency is not supported by FLTK, so e.g. Examples 8, 9 and 10 from the Chart library will not look correctly. This is a limitation of FLTK itself.*
To render a Chart to a widget, it is best to create a custom widget and override it's draw method.
## Building ##
### Stack ###
Just use stack build. If you specify the flag 'examples', also the examples will be built:
> stack build
To build with examples:
> stack build --flag Chart-fltkhs:examples
### Cabal ###
It is recommended to use cabal new-build:
> cabal new-build
To build with examples:
> cabal new-build -f examples
### A usage example: ###
```haskell
widget' <- widgetCustom
(FL.Rectangle (Position (X 0) (Y 0)) (Size (Width width) (Height height)))
Nothing
drawChart
defaultCustomWidgetFuncs
```Here, `drawChart` is the provided draw method for the widget. A possible implementation
could be this:```haskell
-- The char itself, to be used here with 'Graphics.Rendering.Chart.Easy'
signal :: [Double] -> [(Double,Double)]
signal xs = [ (x,(sin (x*3.14159/45) + 1) / 2 * sin (x*3.14159/5)) | x <- xs ]-- the overloaded drawing function
drawChart :: Ref Widget -> IO ()
drawChart widget = do
-- determine a clipping area for the whole widget first
rectangle' <- getRectangle widget-- with this clipping area, we draw the graph. This graph is taken from Example1
-- from the Chart library
withFlClip rectangle' $
renderToWidgetEC widget $ do
layout_title .= "Amplitude Modulation"
setColors [opaque blue, opaque red]
plot (line "am" [signal [0,(0.5)..400]])
plot (points "am points" (signal [0,7..400]))
```For more detailed examples, look into the [examples](https://github.com/oswald2/Chart-fltkhs/tree/master/examples) directory.