Wed Sep 29 17:08:37 BST 2010 malcolm.wallace@me.com * Add Candle plots. New patches: [Add Candle plots. malcolm.wallace@me.com**20100929160837 Ignore-this: b75ca804ec3865578ea2d507a5486a65 ] { hunk ./Graphics/Rendering/Chart/Plot.hs 20 -- -- * 'PlotFillBetween' -- +-- * 'PlotCandle' +-- -- * 'PlotErrBars' -- -- * 'PlotBars' hunk ./Graphics/Rendering/Chart/Plot.hs 63 ErrPoint(..), ErrValue(..), symErrPoint, + -- * Candle plots + PlotCandle(..), + Candle(..), + defaultPlotCandle, -- * Plot with filled area PlotFillBetween(..), defaultPlotFillBetween, hunk ./Graphics/Rendering/Chart/Plot.hs 108 plot_errbars_overhang, plot_errbars_values, + plot_candle_title, + plot_candle_line_style, + plot_candle_tick_length, + plot_candle_width, + plot_candle_centre, + plot_candle_fill, + plot_candle_values, + plotBars, plot_bars_style, plot_bars_item_styles, hunk ./Graphics/Rendering/Chart/Plot.hs 437 plot_errbars_values_ = [] } + +---------------------------------------------------------------------- + +-- | Value defining a series of statistical intervals, and a style in +-- which to render them. +data PlotCandle x y = PlotCandle { + plot_candle_title_ :: String, + plot_candle_line_style_ :: CairoLineStyle, + plot_candle_tick_length_ :: Double, + plot_candle_width_ :: Double, + plot_candle_centre_ :: Double, + plot_candle_fill_ :: Bool, + plot_candle_values_ :: [Candle x y] +} + +-- | A Value holding statistical intervals around a point (x,y): the +-- 0th, 25th, 75th, and 100th percentiles. +data Candle x y = Candle { candle_x :: x + , candle_lo :: y + , candle_q1 :: y + , candle_y :: y + , candle_q3 :: y + , candle_hi :: y + } deriving (Show) + +instance ToPlot PlotCandle where + toPlot p = Plot { + plot_render_ = renderPlotCandle p, + plot_legend_ = [(plot_candle_title_ p, renderPlotLegendCandle p)], + plot_all_points_ = ( map candle_x pts + , concat [ [candle_lo c, candle_hi c] + | c <- pts ] ) + } + where + pts = plot_candle_values_ p + +renderPlotCandle :: PlotCandle x y -> PointMapFn x y -> CRender () +renderPlotCandle p pmap = preserveCState $ do + mapM_ (drawCandle p . candlemap) (plot_candle_values_ p) + where + candlemap (Candle x lo q1 y q3 hi) = + Candle x' lo' q1' y' q3' hi' + where (Point x' y') = pmap' (x,y) + (Point _ lo') = pmap' (x,lo) + (Point _ q1') = pmap' (x,q1) + (Point _ q3') = pmap' (x,q3) + (Point _ hi') = pmap' (x,hi) + pmap' = mapXY pmap + +drawCandle ps (Candle x lo q1 y q3 hi) = do + let tl = plot_candle_tick_length_ ps + let wd = plot_candle_width_ ps + let ct = plot_candle_centre_ ps + let f = plot_candle_fill_ ps + setLineStyle (plot_candle_line_style_ ps) + c $ C.newPath + c $ C.moveTo x lo + c $ C.lineTo x q1 + c $ C.lineTo (x-wd) q1 + c $ C.lineTo (x-wd) q3 + c $ C.lineTo (x+wd) q3 + c $ C.lineTo (x+wd) q1 + c $ C.lineTo x q1 + c $ C.moveTo x q3 + c $ C.lineTo x hi + c $ if f then C.fill else C.stroke + + c $ C.newPath -- ? + c $ C.moveTo (x-tl) lo + c $ C.lineTo (x+tl) lo + c $ C.moveTo (x-tl) hi + c $ C.lineTo (x+tl) hi + + c $ C.moveTo (x-ct) y + c $ C.lineTo (x+ct) y + + c $ C.stroke + +renderPlotLegendCandle :: PlotCandle x y -> Rect -> CRender () +renderPlotLegendCandle p r@(Rect p1 p2) = preserveCState $ do + drawCandle p (Candle ((p_x p1 + p_x p2)/2) lo q1 mid q3 hi) + where + lo = min (p_y p1) (p_y p2) + mid = (p_y p1 + p_y p2)/2 + hi = max (p_y p1) (p_y p2) + q1 = (lo + mid) / 2 + q3 = (mid + hi) / 2 + +defaultPlotCandle :: PlotCandle x y +defaultPlotCandle = PlotCandle { + plot_candle_title_ = "", + plot_candle_line_style_ = solidLine 1 $ opaque blue, + plot_candle_tick_length_ = 2, + plot_candle_width_ = 5, + plot_candle_centre_ = 7, + plot_candle_fill_ = False, + plot_candle_values_ = [] +} + ---------------------------------------------------------------------- class PlotValue a => BarsPlotValue a where hunk ./Graphics/Rendering/Chart/Plot.hs 790 $( deriveAccessors ''PlotPoints ) $( deriveAccessors ''PlotFillBetween ) $( deriveAccessors ''PlotErrBars ) +$( deriveAccessors ''PlotCandle ) $( deriveAccessors ''PlotBars ) $( deriveAccessors ''PlotHidden ) $( deriveAccessors ''PlotAnnotation ) } Context: [Contextual axis labels for time series. malcolm.wallace@me.com**20100726205206 Ignore-this: 179700aba6e0e60ec87559af465a782f An axis can now have two set of labels, not just one. The outer set is for contextual information. If no context labels are defined, no extra whitespace is left for them. The autoTimeAxis now uses the context labels to show the next sensible granularity of time enclosing the more detailed labels and ticks. For example, labels showing minutes have an hour context, hours have a day context, days a month context, etc. ] [Lots of visual tests for new two-layered time axis. (test2[a-w]) malcolm.wallace@me.com**20100726132817 Ignore-this: b4b7871b040ebcd0252d15d6b78e1e86 Tries to exercise all of the different time granularities, including close to the boundaries where the axis display changes from one format to another. ] [Fix up all tests to cope with new return type of renderableToPNGFile. malcolm.wallace@me.com**20100723111217 Ignore-this: caefe80de905abf7e2d1f5151e9c0672 ] [Extended Layout1Pick type to have cases for titles and axis titles, also a fix for legend picking tim@dockerz.net**20100721234717 Ignore-this: 198747147640111c0495a27f8a26a51b ] [Add a gtk flag to .cabal file. Building with Gtk is now optional. Malcolm.Wallace@cs.york.ac.uk**20100716200334 Ignore-this: 802d7da21e73c49c997cbec44252506e The cairo package is still necessary, but cairo and gtk are no longer packaged together upstream. ] [Return a PickFn after rendering to a PNG file. malcolm.wallace@me.com**20100716200023 Ignore-this: 4e17b9cd600b102b311f283a3fff59d7 ] [Allow titles to be pickable, like legends. malcolm.wallace@me.com**20100716195903 Ignore-this: d11830ae4b4236ac555b616c19cb6578 ] [Initial support for picking tim@dockerz.net**20100714034226 Ignore-this: f61ac66905ac07de9d714046f44d49b7 This builds upon the patches from Malcolm Wallace, and supports picking inside the plot region and along the axes. A sample script is provided that prints the pick results which the chart is clicked upon. ] [fixed uninitiased warnings in all_tests.hs script tim@dockerz.net**20100712233958 Ignore-this: 28222438cbbea9d5985c1faf68e6e76f ] [Fix calibration of pickFn when inside a grid. Malcolm.Wallace@cs.york.ac.uk**20100707124657 Ignore-this: 754640fdbb5b6ca6f717451598376948 ] [Fix Prelude.undefined bug. Malcolm.Wallace@cs.york.ac.uk**20100630144642 Ignore-this: 5d27b01acec25891302eb21994632748 ] [Added AreaSpots4D test to all_tests.hs harness tim@dockerz.net**20100708133257 Ignore-this: 7631e5c2594de214606a1e6ecaee6599 ] [upgraded version to 0.13.1 tim@dockerz.net**20100526142148 Ignore-this: 9800a2d19171d4d2190e9d321e36dc5a ] [Improved parametric test appearance tim@dockerz.net**20100526142110 Ignore-this: 94fcd2e223de9354f2d567a6b2becf55 ] [Fixes to suit gtk2hs 0.11.0 tim@dockerz.net**20100526141957 Ignore-this: 53673595ce055aa3dbd65f57491583de ] [A Percent type for use on axes. Malcolm.Wallace@cs.york.ac.uk**20100630144135 Ignore-this: 5f0ec76f90be9c04a4ed08381e89eb6b ] [Inverse mapping from output image coordinates to values. Malcolm.Wallace@cs.york.ac.uk**20100629130113 Ignore-this: 6852a485374a372bac0ed1896ab60072 This is useful for interactive manipulation of the output, e.g. for zooming or selecting. ] [Test for AreaSpots4D. Malcolm.Wallace@cs.york.ac.uk**20100521131637 Ignore-this: 57b50241834dc6a827d6ad857979ee69 ] [New: AreaSpots4D; shows (x,y,z,t) using coords, spot area, and colour. Malcolm.Wallace@cs.york.ac.uk**20100521131139 Ignore-this: fb2563fc3fcd3bd900a725cc11bc83a0 In addition to 2D position, and spot area for the z value, the colour to represent the fourth dimension is chosen from a supplied palette. A palette is just a list of available colours - values are mapped to the palette linearly, with truncation. (There is no blending of intermediate colours.) ] [If title is empty, don't create space for it in the top margin. Malcolm.Wallace@cs.york.ac.uk**20100507131529 Ignore-this: cdc6a737b11171cf76e0660e8ae0d3e5 ] [TAG CHART_0_13 tim@dockerz.net**20100330122247 Ignore-this: 92a0f773bf03c589fbfbfc28baf01308 ] [Added new tests to cabal file tim@dockerz.net**20100330122207 Ignore-this: 8787f97742854594f8fc79e7128eaaab ] [Legends now get layed out in rows or columns tim@dockerz.net**20100328213117 Ignore-this: 8fb1069968ff5e4fe7b488b0767c0e63 ] [Fixed barcharts so that the bar edges align cleanly with pixels. tim@dockerz.net**20100323214503 Ignore-this: b7af76c66d394a8d444cff7d603f77b In implmenting this fix, the drawing API was simplified somewhat with two new functions: strokePath and fillPath. The functions do correct pixel alignment. ] [Updated version to 0.13 tim@dockerz.net**20100321214321 Ignore-this: c0306bcc4ef406d6bc8b874c55822b7 ] [BarsFixGap now takes an extra size to put a floor on the minimum width tim@dockerz.net**20100321214133 Ignore-this: c769d3176720f25ea21030894d07be98 ] [Refactored tests into separate files tim@dockerz.net**20100319064219 Ignore-this: 27852fefb85a257aafd5ecd147b13fac This was done in order to make the examples clearer, and suitable for pasting directly into the web documentation ] [Fix bar charts so reference point always shown tim@dockerz.net**20100317210347 Ignore-this: 7f802109853251751489d0c3dd9a33d9 This originally worked, but was subsequently broken by a patch from May 2009 ] [Tidied up date handling in tests tim@dockerz.net**20100310215140 Ignore-this: dcbe59cfe921be8943f11eca47551103 ] [Updated test4 and test5 to show log axes with normal double values. tim@dockerz.net**20100204204536 Ignore-this: 809d2e937d45789326b6b89b98ea29e ] [Fix new bug in autoIndexAxis tim@dockerz.net**20100203214625 Ignore-this: d79493a18e801c58631e46a175dfdd33 ] [Fix bug with rounding errors Khudyakov Alexey **20100113224136 Ignore-this: 2da4a790572171b604405e2ac735f3a4 After generalisation of type signature of functions 'step' and 'chooseStep' some rounding errors arose. For example axis label could be like 24.200000002. Now all calculation for ticks are performed exactly using Rational type. ] [Generalize type signatures for auto*Axis functions Khudyakov Alexey **20100113161249 Ignore-this: 791fec9625687675dd3f81bc2bbbf44a Namely: > autoScaledAxis :: RealFloat a => LinearAxisParams a -> AxisFn a > autoScaledLogAxis :: RealFloat a => LogAxisParams a -> AxisFn a Also make data type LogAxisParames this is API breaking change ] [Add function Axis.makeAxis' Khudyakov Alexey **20100111232504 Ignore-this: fe59ba7f24672b2a6c03a34a3d77ef34 It's similar to Axis.makeAxis but accept function to convert axis value to double instead of using one from PlotValue type class ] [Add more instances for LogValue Khudyakov Alexey **20100111210026 Ignore-this: 9061cb15e63f62f231668e2662c5e32a ] [Generalize functions steps and chooseStep in Axis Khudyakov Alexey **20100109205916 Ignore-this: 85667cb48e7dd6dce9fdbd52113c8e11 ] [Generalize type of Axis.autoIndexAxis Khudyakov Alexey **20100109180153 Ignore-this: 6ddf080431af1f6b537f8f9065ff4fcf Change its type signature to > autoIndexAxis :: Integral i => [String] -> [i] -> AxisData i Integral is only required constrain also add function linMap which is analog of vmap but function to convert value to double is passed explicitly. ] [Split export list of G.R.C.Plot in sections to improve readability Khudyakov Alexey **20100108201641 Ignore-this: e003db54907f209a6befd7878521b53e ] [Added a test for AreaSpots tim@dockerz.net**20091221122001] [Derive Data.Accessor.Accessor for AreaSpots. Malcolm.Wallace@cs.york.ac.uk**20091218140249 Ignore-this: 9949516e03a1de9510b0d00741d492e4 ] [A new type of plot: AreaSpots. Malcolm.Wallace@cs.york.ac.uk**20091210184616 Ignore-this: 1dc591b33199d93252edd5939b93b35 For a collection of (x,y,z) points, the (x,y) coordinate is the position of the centre of the spot, and the z coordinate translates into the area of the spot. By default, spots are 20% opaque, so overlaps can be seen clearly. All spots are scaled relative to the largest z value in the dataset, and the maximum radius of the spot is an attribute that can be changed. ] [Generalise from Int axis to Integral, and make Integer an instance. Malcolm.Wallace@cs.york.ac.uk**20091218135735 Ignore-this: 5cbdaad083b0bda819461ef9b036796a ] [Variation of test4 to demonstrate `joinPlot`. Malcolm.Wallace@cs.york.ac.uk**20091215112952 Ignore-this: 54ae72b5ade100799428d524d4a21da4 ] [Add an obvious instance - if Grid contents are renderable, so is the Grid. Malcolm.Wallace@cs.york.ac.uk**20091215112332 Ignore-this: eb6e9b1a649fa00e2adc3a4644a17e00 ] [Added a TODO File tim@dockerz.net**20091215115626] [Minor refactor to plot annotations to reuse text drawing code tim@dockerz.net**20091215114326] [Added test example for explicitly defined axes tim@dockerz.net**20091215114238] [Resolve conflict tim@dockerz.net**20091215074115] [First implementation of plot annotations dkarang@gmail.com**20091210200958 Ignore-this: ec735e607260b051bc0fcb526cfc96f1 ] [Fix pattern match failure when mepty data set is passed to plot_lines_value Khudyakov Alexey **20091214133046 Ignore-this: 1187ef037972ba0b910bf5fa8a6ebcca ] [export plot_bars_singleton_width jwlato@gmail.com**20091209103546 Ignore-this: d26ce1bb0a8cc55f5ade8f01389ee1b2 ] [Added missing signatures for some exported functions. Bradford Larsen **20091118220142 Ignore-this: 9f4ad2add8fd821cf089fb9e2f575022 Several exported functions were missing signatures. Signatures are required to allow Haddock to document functions. ] [Graphics.Rendering.Chart haddock tweaks. Bradford Larsen **20091118214013 Ignore-this: 52f09909457c499e270ef7ad4d832802 ] [Graphics.Rendering.Chart.Simple haddock fix brad.larsen@gmail.com**20091118211325 Ignore-this: 79cb095c5b8fba6ca3879d60640de2cd The module documentation was missing a '>' on the continuation line for some example code. This was causing haddock (version 2.4.* and 2.5.*) to abort with an error. ] [Small refactoring to use named-field update instead of constructors. Malcolm.Wallace@cs.york.ac.uk**20091120081005 Ignore-this: ca7debe670d42a4155f517dc20819b16 When the purpose is to change only a single field, using field update draws attention to the point of interest, in a way that re-building all the fields from scratch does not. ] [Export the ErrValue type, for constructing error bars. Malcolm.Wallace@cs.york.ac.uk**20091120080035 Ignore-this: 373d3c586b510156c5feac58ca6cd774 ] [Fix exports of Graphics.Rendering.Chart.Simple, so test_simple can compile. Malcolm.Wallace@cs.york.ac.uk**20091105120323 Ignore-this: fe37b3d5e236e96edace036cf3308fbd ] [A new form of composition for Plots: joinPoint. Malcolm.Wallace@cs.york.ac.uk**20091105120138 Ignore-this: 48d326d57089539d1775ab2cab062932 The two argument plots are overlaid, but their legends are combined rather than separated. ] [Tidy up comments, fit into 80 columns, and improve vertical alignments. Malcolm.Wallace@cs.york.ac.uk**20091105115912 Ignore-this: 2d990a3db8762093f92dbec595857a17 Also restore a missing linefeed character that prevented MacOS from recognising that this is a DOS-style text file. ] [Tidy up comments, fit into 80 columns, and improve vertical alignments. Malcolm.Wallace@cs.york.ac.uk**20091105115206 Ignore-this: 1341b8feaf2e048c2394ebd575b3b848 ] [Tidy up comments, fit into 80 columns, and improve vertical alignments. Malcolm.Wallace@cs.york.ac.uk**20091105115052 Ignore-this: a2845609574ff0b730d915e501af47bf ] [Tidy up comments, fit into 80 columns, and improve vertical alignments. Malcolm.Wallace@cs.york.ac.uk**20091105115000 Ignore-this: db2aefac3658d061023e9a6e63893ec4 ] [Tidy up comments, fit into 80 columns, and improve vertical alignments. Malcolm.Wallace@cs.york.ac.uk**20091105114715 Ignore-this: e6aa4b0d530845c87880a1c06660ba7e Also remove invisible leading tabs. ] [Tidy up comments, fit into 80 columns, and improve vertical alignments. Malcolm.Wallace@cs.york.ac.uk**20091105114535 Ignore-this: 9d3a7066eae816dd0ddcbdf994f88ad7 ] [Tidy up comments, fit into 80 columns, and improve vertical alignments. Malcolm.Wallace@cs.york.ac.uk**20091105114312 Ignore-this: 41690b917825a12841589f2ee866a2f7 ] [Tidy up comments, fit into 80 columns, and improve vertical alignments. Malcolm.Wallace@cs.york.ac.uk**20091105114148 Ignore-this: 531f53f5efb857d92f40fb0b27579899 ] [Tidy up comments, fit into 80 columns, and improve vertical alignments. Malcolm.Wallace@cs.york.ac.uk**20091105113208 Ignore-this: bf69845411fd51398f12a1a83393f63 ] [TAG CHART_0_12 tim@dockerz.net**20091103110450] Patch bundle hash: 72288b89b1d170f03ec30f2ab8bdd861e356082b