I'm trying to use Haskell-Charts (http://hackage.haskell.org/package/Chart) to generate some graphs. It works fine and I get a nice graph
My only "problem" are the numbers on the left, that's a bit hard to read. Is there a way to maybe provide a function that would convert those numbers before displaying them ? I could convert the numbers before plotting, but I would lose precision. I've been looking at the doc but I don't see it, if it exists.
Thanks
EDIT : Here is the code.
import Graphics.Rendering.Chart.Easy
import Graphics.Rendering.Chart.Axis.LocalTime
import Graphics.Rendering.Chart.Backend.Diagrams
import Data.Time.LocalTime
main = do
-- Get datas
toFile def "test.svg" $ do
layout_title .= "Active mem"
plot (line "Active" $ [L.map (\v -> ((utcToLocalTime utc $ time v) :: LocalTime, (fromIntegral $ value v) :: Int)) $ V.toList q])
Unfortunately I get the data from a database, and I can't give public access to it. But a list of [(LocalTime, Int)] with big numbers should give you something similar. I'm using the Diagrams backend btw
Digging into the source of the Chart, maybe I found the solution.
Here's working code. you can change func
to anything you like
This will show label of y-axis 10,20,30,40
, when actual data is 100,200,300,400
import Graphics.Rendering.Chart.Easy
import Graphics.Rendering.Chart.Backend.Diagrams
func :: Int -> String
func x = show $ x `quot` 10
vals :: [(Int,Int)]
vals = [(1,100),(2,200),(3,300),(4,400)]
main = do
toFile def "test.svg" $ do
layout_title .= "test"
layout_y_axis . laxis_generate .= autoScaledIntAxis(LinearAxisParams{
_la_labelf = map func,
_la_nLabels = 5,
_la_nTicks = 10
})
plot $ points "Score" vals