1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
{-# LANGUAGE DeriveDataTypeable #-}
-- | Module for accessing minified flot code (<http://www.flotcharts.org/>).
-- As an example:
--
-- > import qualified Language.Javascript.Flot as Flot
-- >
-- > main = do
-- > putStrLn $ "Flot version " ++ show Flot.version ++ " source:"
-- > putStrLn =<< readFile =<< Flot.file Flot.Flot
module Language.Javascript.Flot(
Flot(..), version, file
) where
import qualified Paths_js_flot as Paths
import Data.Version
import Data.Data
import Data.Char
-- | The Flot code to obtain. Use 'Flot' for the base system and the other values
-- for the various addins shipped with Flot.
data Flot
= Flot
| FlotCanvas
| FlotCategories
| FlotCrosshair
| FlotErrorbars
| FlotFillbetween
| FlotImage
| FlotNavigate
| FlotPie
| FlotResize
| FlotSelection
| FlotStack
| FlotSymbol
| FlotThreshold
| FlotTime
deriving (Eq,Ord,Show,Read,Bounded,Enum,Data,Typeable)
-- | A local file containing the minified Flot code for 'version'.
file :: Flot -> IO FilePath
file = Paths.getDataFileName . name
name Flot = "jquery.flot.min.js"
name x = "jquery.flot." ++ map toLower (drop 4 $ show x) ++ ".min.js"
-- | The version of Flot provided by this package. Not necessarily the version of this package,
-- but the versions will match in the first three digits.
version :: Version
version = Version (take 3 $ versionBranch Paths.version) []
|