From b2411247a4f91c744176d6ab5f9c1cb66dcc6bce Mon Sep 17 00:00:00 2001 From: Bohdan Szymanik Date: Thu, 10 Sep 2015 13:19:14 +1200 Subject: [PATCH 1/8] Bug fixes --- src/FSharp.Charting.Gtk.fs | 68 ++++++++++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/src/FSharp.Charting.Gtk.fs b/src/FSharp.Charting.Gtk.fs index 6a7fe11..2a03218 100644 --- a/src/FSharp.Charting.Gtk.fs +++ b/src/FSharp.Charting.Gtk.fs @@ -208,6 +208,9 @@ namespace FSharp.Charting module ChartTypes = + /// An implementation of a histogram bin. + type Bin = { LowerBound: float; UpperBound: float; Count: int} + /// An implementation type for items on a chart. This type should not be used directly. type public LineChartItem(X: key, Y: value) = member __.X = X @@ -616,6 +619,14 @@ namespace FSharp.Charting // ---------------------------------------------------------------------------------- // Data operations + let internal binData data lowerBound upperBound intervals = + seq{lowerBound .. (upperBound - lowerBound)/intervals .. upperBound } + |> Seq.pairwise + |> Seq.map (fun (l,u) -> + let cnt = data |> Seq.filter (fun e -> e >= l && e < u) |> Seq.length + {LowerBound = l; UpperBound = u; Count = cnt} + ) + let internal allowNull x = match x with None -> null | Some v -> v let internal listen data = NotifySeq.notifyOrOnce data @@ -694,7 +705,7 @@ namespace FSharp.Charting type internal Helpers() = /// Use a DateTime axis if the input key data is DateTime - static member ApplyStaticAxis(xty, pos) = (fun (ch:('T :> GenericChart)) -> + static member ApplyStaticAxis(xty, pos, ?gap) = (fun (ch:('T :> GenericChart)) -> let model = ch.Model match model.DefaultXAxis with | null -> @@ -703,7 +714,12 @@ namespace FSharp.Charting if xty = typeof then model.Axes.Add (Axes.TimeSpanAxis(Position=pos)) if xty = typeof then - model.Axes.Add (Axes.CategoryAxis(Position=pos)) + match gap with + | Some g -> + let a = Axes.CategoryAxis(Position=pos) + a.GapWidth <- g + model.Axes.Add (a) + | _ -> model.Axes.Add (Axes.CategoryAxis(Position=pos)) | _ -> () ch) @@ -731,6 +747,7 @@ namespace FSharp.Charting AxisYTitle |> Option.iter (fun t -> ensureDefaultYAxis().Title <- t) ch) + /// Provides a set of static methods for creating charts. type Chart = /// Register a function that is used to automatically transform X values (keys) @@ -912,9 +929,13 @@ namespace FSharp.Charting /// The color for the data. /// The title of the X-axis. /// The title of the Y-axis. - static member Column(data:seq<('key :> key)*#value>,?Name,?Title,?Labels, ?Color,?XTitle,?YTitle) = + /// The width of columns versus whitespace as a percentage. + static member Column(data:seq<('key :> key)*#value>,?Name,?Title,?Labels, ?Color,?XTitle,?YTitle,?ColumnWidth:float) = + let gap = match ColumnWidth with + | Some columnWidth -> Some (1.0 - columnWidth) + | _ -> None GenericChart.Create(data |> listen |> mergeLabels Labels |> makeItems (fun ((k,v),labelOpt) -> ColumnItem(valueToDouble v)), ColumnSeries(ValueField="Value")) - |> Helpers.ApplyStaticAxis(typeof<'key>, Axes.AxisPosition.Bottom) + |> Helpers.ApplyStaticAxis(typeof<'key>, Axes.AxisPosition.Bottom, ?gap = gap) |> Helpers.ApplyStyles(?Name=Name,?Title=Title,?Color=Color,?AxisXTitle=XTitle,?AxisYTitle=YTitle) /// Uses a sequence of columns to compare values across categories. @@ -925,8 +946,33 @@ namespace FSharp.Charting /// The color for the data. /// The title of the X-axis. /// The title of the Y-axis. - static member Column(data:seq<#value>,?Name,?Title,?Labels, ?Color,?XTitle,?YTitle) = - Chart.Column(indexData data,?Name=Name,?Title=Title,?Labels=Labels, ?Color=Color,?XTitle=XTitle,?YTitle=YTitle) + /// The width of columns versus whitespace as a percentage. + static member Column(data:seq<#value>,?Name,?Title,?Labels, ?Color,?XTitle,?YTitle, ?ColumnWidth) = + Chart.Column(indexData data,?Name=Name,?Title=Title,?Labels=Labels, ?Color=Color,?XTitle=XTitle,?YTitle=YTitle, ?ColumnWidth=ColumnWidth) + + + /// Generates a Histogram with reasonable defaults. + /// The data for the chart. + /// The name of the data set. + /// The title of the chart. + /// The labels that match the data. + /// The color for the data. + /// The title of the X-axis. + /// The title of the Y-axis. + static member Histogram(data:seq<#value>,?Name,?Title,?Color,?XTitle,?YTitle, ?LowerBound, ?UpperBound, ?Intervals) = + let data' = data |> Seq.map valueToDouble + let lowerBound = match LowerBound with + | Some LowerBound -> LowerBound + | _ -> Seq.min data + let upperBound = match UpperBound with + | Some UpperBound -> UpperBound + | _ -> Seq.max data + let intervals = match Intervals with + | Some Intervals -> Intervals + | _ -> 30. // corresponds to what ggplot does + let data'' = (binData data' lowerBound upperBound intervals) |> Seq.map (fun b -> b.Count) + let labels = (binData data' lowerBound upperBound intervals) |> Seq.map (fun b -> b.LowerBound.ToString()) + Chart.Column(indexData data'',?Name=Name,?Title=Title,?Labels=Some labels, ?Color=Color,?XTitle=XTitle,?YTitle=YTitle, ?ColumnWidth=Some 0.95) #if INCOMPLETE_API /// Similar to the Pie chart type, except that it has a hole in the center. @@ -1785,8 +1831,9 @@ namespace FSharp.Charting /// The color for the data. /// The title of the X-axis. /// The title of the Y-axis. - static member Column(data:IObservable<#seq<#key * #value>>,?Name,?Title,(* ?Labels, *) ?Color,?XTitle,?YTitle) = - Chart.Column(NotifySeq.ofObservableReplacing data,?Name=Name,?Title=Title(* ,?Labels=Labels *),?Color=Color,?XTitle=XTitle,?YTitle=YTitle) + /// The width of columns versus whitespace as a percentage. + static member Column(data:IObservable<#seq<#key * #value>>,?Name,?Title,(* ?Labels, *) ?Color,?XTitle,?YTitle,?ColumnWidth) = + Chart.Column(NotifySeq.ofObservableReplacing data,?Name=Name,?Title=Title(* ,?Labels=Labels *),?Color=Color,?XTitle=XTitle,?YTitle=YTitle,?ColumnWidth=ColumnWidth) /// Uses a sequence of columns to compare values across categories. /// The data for the chart. Each observation adds a data element to the chart. @@ -1796,8 +1843,9 @@ namespace FSharp.Charting /// The color for the data. /// The title of the X-axis. /// The title of the Y-axis. - static member ColumnIncremental(data:IObservable<#key * #value>,?Name,?Title,(* ?Labels, *) ?Color,?XTitle,?YTitle) = - Chart.Column(NotifySeq.ofObservableIncremental data,?Name=Name,?Title=Title(* ,?Labels=Labels *),?Color=Color,?XTitle=XTitle,?YTitle=YTitle) + /// The width of columns versus whitespace as a percentage. + static member ColumnIncremental(data:IObservable<#key * #value>,?Name,?Title,(* ?Labels, *) ?Color,?XTitle,?YTitle,?ColumnWidth) = + Chart.Column(NotifySeq.ofObservableIncremental data,?Name=Name,?Title=Title(* ,?Labels=Labels *),?Color=Color,?XTitle=XTitle,?YTitle=YTitle, ?ColumnWidth=ColumnWidth) #if INCOMPLETE_API /// Similar to the Pie chart type, except that it has a hole in the center. From bbaf623fc97ba1aec0c0722d3b393f34cd0f43bf Mon Sep 17 00:00:00 2001 From: Bohdan Szymanik Date: Thu, 10 Sep 2015 13:21:09 +1200 Subject: [PATCH 2/8] Bug fixes --- src/FSharp.Charting.fs | 73 +++++++++++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 12 deletions(-) diff --git a/src/FSharp.Charting.fs b/src/FSharp.Charting.fs index 6ae14a4..bea5cb2 100644 --- a/src/FSharp.Charting.fs +++ b/src/FSharp.Charting.fs @@ -261,6 +261,10 @@ namespace FSharp.Charting do registerConvertor (fun (dto:DateTimeOffset) -> dto.DateTime :> key) module ChartTypes = + + /// An implementation of a histogram bin. + type Bin = { LowerBound: float; UpperBound: float; Count: int} + /// An implementation type for labelled points on chart. This type should not be used directly. type public DataPoint(X: key, Y: value, Label: string) = member __.Label = Label @@ -830,6 +834,13 @@ namespace FSharp.Charting // stacked values | StackedXYValues of seq + let internal binData data lowerBound upperBound intervals = + seq{lowerBound .. (upperBound - lowerBound)/intervals .. upperBound } + |> Seq.pairwise + |> Seq.map (fun (l,u) -> + let cnt = data |> Seq.filter (fun e -> e >= l && e < u) |> Seq.length + {LowerBound = l; UpperBound = u; Count = cnt} + ) // ---------------------------------------------------------------------------------- // Utilities for working with enumerable and tuples @@ -847,6 +858,8 @@ namespace FSharp.Charting // Converts Y value of a chart (defines the type too) let culture = System.Globalization.CultureInfo.InvariantCulture + let valueToDouble (x:value) = x.ToDouble(culture) + open System.Collections.Specialized let private convertKeys (selector:_ -> key) (transform:(key -> key) -> _) data = @@ -2395,6 +2408,9 @@ namespace FSharp.Charting GenericChart.Create(mergeDataAndLabelsForY4 data Labels, fun() -> CandlestickChart() ) |> Helpers.ApplyStyles(?Name=Name,?Title=Title,?Color=Color,?AxisXTitle=XTitle,?AxisYTitle=YTitle) + static member internal ConfigureColumn(c:GenericChart, property, vPointWidth) = + vPointWidth |> Option.iter (fun v -> c.SetCustomProperty(property, v)) + /// Uses a sequence of columns to compare values across categories. /// The data for the chart. /// The name of the data set. @@ -2403,10 +2419,14 @@ namespace FSharp.Charting /// The color for the data. /// The title of the X-axis. /// The title of the Y-axis. - static member Column(data,?Name,?Title,?Labels, ?Color,?XTitle,?YTitle) = - GenericChart.Create(mergeDataAndLabelsForXY data Labels, fun () -> GenericChart(SeriesChartType.Column)) - |> Helpers.ApplyStyles(?Name=Name,?Title=Title,?Color=Color,?AxisXTitle=XTitle,?AxisYTitle=YTitle) - + /// The width of columns versus whitespace as a percentage. + static member Column(data,?Name,?Title,?Labels, ?Color,?XTitle,?YTitle,?ColumnWidth) = + let c = + GenericChart.Create(mergeDataAndLabelsForXY data Labels, fun () -> GenericChart(SeriesChartType.Column)) + |> Helpers.ApplyStyles(?Name=Name,?Title=Title,?Color=Color,?AxisXTitle=XTitle,?AxisYTitle=YTitle) + Chart.ConfigureColumn(c, "PointWidth", ColumnWidth) + c + /// Uses a sequence of columns to compare values across categories. /// The data for the chart. /// The name of the data set. @@ -2415,10 +2435,13 @@ namespace FSharp.Charting /// The color for the data. /// The title of the X-axis. /// The title of the Y-axis. - static member Column(data,?Name,?Title,?Labels, ?Color,?XTitle,?YTitle) = - GenericChart.Create(mergeDataAndLabelsForY data Labels, fun () -> GenericChart(SeriesChartType.Column)) - |> Helpers.ApplyStyles(?Name=Name,?Title=Title,?Color=Color,?AxisXTitle=XTitle,?AxisYTitle=YTitle) - + /// The width of columns versus whitespace as a percentage. + static member Column(data,?Name,?Title,?Labels, ?Color,?XTitle,?YTitle,?ColumnWidth) = + let c = + GenericChart.Create(mergeDataAndLabelsForY data Labels, fun () -> GenericChart(SeriesChartType.Column)) + |> Helpers.ApplyStyles(?Name=Name,?Title=Title,?Color=Color,?AxisXTitle=XTitle,?AxisYTitle=YTitle) + Chart.ConfigureColumn(c, "PointWidth", ColumnWidth) + c /// Similar to the Pie chart type, except that it has a hole in the center. /// The data for the chart. @@ -2529,6 +2552,30 @@ namespace FSharp.Charting GenericChart.Create(mergeDataAndLabelsForY data Labels, fun () -> FunnelChart () ) |> Helpers.ApplyStyles(?Name=Name,?Title=Title,?Color=Color,?AxisXTitle=XTitle,?AxisYTitle=YTitle) + /// Generates a Histogram with reasonable defaults. + /// The data for the chart. + /// The name of the data set. + /// The title of the chart. + /// The labels that match the data. + /// The color for the data. + /// The title of the X-axis. + /// The title of the Y-axis. + static member Histogram(data:seq<#value>,?Name,?Title,?Color,?XTitle,?YTitle, ?LowerBound, ?UpperBound, ?Intervals) = + let data' = data |> Seq.map valueToDouble + let lowerBound = match LowerBound with + | Some LowerBound -> LowerBound + | _ -> Seq.min data + let upperBound = match UpperBound with + | Some UpperBound -> UpperBound + | _ -> Seq.max data + let intervals = match Intervals with + | Some Intervals -> Intervals + | _ -> 30. // corresponds to what ggplot does + let data'' = (binData data' lowerBound upperBound intervals) |> Seq.map (fun b -> b.Count) + let labels = (binData data' lowerBound upperBound intervals) |> Seq.map (fun b -> b.LowerBound.ToString()) + Chart.Column(data'',?Name=Name,?Title=Title,?Labels=Some labels, ?Color=Color,?XTitle=XTitle,?YTitle=YTitle, ?ColumnWidth=Some 0.05) + + /// Displays a series of connecting vertical lines where the thickness and direction of the lines are dependent on the action of the price value. /// The data for the chart. /// The name of the data set. @@ -3292,8 +3339,9 @@ namespace FSharp.Charting /// The color for the data. /// The title of the X-axis. /// The title of the Y-axis. - static member Column(data:IObservable<#seq<#key * #value>>,?Name,?Title,(* ?Labels, *) ?Color,?XTitle,?YTitle) = - Chart.Column(NotifySeq.ofObservableReplacing data,?Name=Name,?Title=Title(* ,?Labels=Labels *),?Color=Color,?XTitle=XTitle,?YTitle=YTitle) + /// The width of columns versus whitespace as a percentage. + static member Column(data:IObservable<#seq<#key * #value>>,?Name,?Title,(* ?Labels, *) ?Color,?XTitle,?YTitle,?ColumnWidth) = + Chart.Column(NotifySeq.ofObservableReplacing data,?Name=Name,?Title=Title(* ,?Labels=Labels *),?Color=Color,?XTitle=XTitle,?YTitle=YTitle,?ColumnWidth=ColumnWidth) /// Uses a sequence of columns to compare values across categories. /// The data for the chart. Each observation adds a data element to the chart. @@ -3303,8 +3351,9 @@ namespace FSharp.Charting /// The color for the data. /// The title of the X-axis. /// The title of the Y-axis. - static member ColumnIncremental(data:IObservable<#key * #value>,?Name,?Title,(* ?Labels, *) ?Color,?XTitle,?YTitle) = - Chart.Column(NotifySeq.ofObservableIncremental data,?Name=Name,?Title=Title(* ,?Labels=Labels *),?Color=Color,?XTitle=XTitle,?YTitle=YTitle) + /// The width of columns versus whitespace as a percentage. + static member ColumnIncremental(data:IObservable<#key * #value>,?Name,?Title,(* ?Labels, *) ?Color,?XTitle,?YTitle,?ColumnWidth) = + Chart.Column(NotifySeq.ofObservableIncremental data,?Name=Name,?Title=Title(* ,?Labels=Labels *),?Color=Color,?XTitle=XTitle,?YTitle=YTitle,?ColumnWidth=ColumnWidth) /// Similar to the Pie chart type, except that it has a hole in the center. /// The data for the chart. Each observation replaces the entire data on the chart. From 7cc6f94cb8155593afccdd805e1e30c9d7071ebc Mon Sep 17 00:00:00 2001 From: Bohdan Szymanik Date: Thu, 10 Sep 2015 13:32:47 +1200 Subject: [PATCH 3/8] Update pointwidth --- src/FSharp.Charting.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FSharp.Charting.fs b/src/FSharp.Charting.fs index bea5cb2..00df90a 100644 --- a/src/FSharp.Charting.fs +++ b/src/FSharp.Charting.fs @@ -2573,7 +2573,7 @@ namespace FSharp.Charting | _ -> 30. // corresponds to what ggplot does let data'' = (binData data' lowerBound upperBound intervals) |> Seq.map (fun b -> b.Count) let labels = (binData data' lowerBound upperBound intervals) |> Seq.map (fun b -> b.LowerBound.ToString()) - Chart.Column(data'',?Name=Name,?Title=Title,?Labels=Some labels, ?Color=Color,?XTitle=XTitle,?YTitle=YTitle, ?ColumnWidth=Some 0.05) + Chart.Column(data'',?Name=Name,?Title=Title,?Labels=Some labels, ?Color=Color,?XTitle=XTitle,?YTitle=YTitle, ?ColumnWidth=Some 0.95) /// Displays a series of connecting vertical lines where the thickness and direction of the lines are dependent on the action of the price value. From 18349dce80d06beea653d21dd602cccea56fe0cd Mon Sep 17 00:00:00 2001 From: Bohdan Szymanik Date: Thu, 10 Sep 2015 14:54:59 +1200 Subject: [PATCH 4/8] Histogram parameters documentation was incorrect --- src/FSharp.Charting.fs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/FSharp.Charting.fs b/src/FSharp.Charting.fs index 00df90a..91ce9ad 100644 --- a/src/FSharp.Charting.fs +++ b/src/FSharp.Charting.fs @@ -2556,20 +2556,22 @@ namespace FSharp.Charting /// The data for the chart. /// The name of the data set. /// The title of the chart. - /// The labels that match the data. /// The color for the data. /// The title of the X-axis. /// The title of the Y-axis. + /// The lower bound of the histogram. + /// The upper bound of the histogram. + /// The number of intervals in the histogram. static member Histogram(data:seq<#value>,?Name,?Title,?Color,?XTitle,?YTitle, ?LowerBound, ?UpperBound, ?Intervals) = let data' = data |> Seq.map valueToDouble let lowerBound = match LowerBound with - | Some LowerBound -> LowerBound + | Some lowerBound -> lowerBound | _ -> Seq.min data let upperBound = match UpperBound with - | Some UpperBound -> UpperBound + | Some upperBound -> upperBound | _ -> Seq.max data let intervals = match Intervals with - | Some Intervals -> Intervals + | Some intervals -> intervals | _ -> 30. // corresponds to what ggplot does let data'' = (binData data' lowerBound upperBound intervals) |> Seq.map (fun b -> b.Count) let labels = (binData data' lowerBound upperBound intervals) |> Seq.map (fun b -> b.LowerBound.ToString()) From 603a42faac29bc1efb621540cdecc6d67c8c7a0a Mon Sep 17 00:00:00 2001 From: Bohdan Szymanik Date: Thu, 10 Sep 2015 15:45:55 +1200 Subject: [PATCH 5/8] Histogram x-axis now displays properly --- src/FSharp.Charting.fs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/FSharp.Charting.fs b/src/FSharp.Charting.fs index 91ce9ad..d72b1c0 100644 --- a/src/FSharp.Charting.fs +++ b/src/FSharp.Charting.fs @@ -2436,7 +2436,7 @@ namespace FSharp.Charting /// The title of the X-axis. /// The title of the Y-axis. /// The width of columns versus whitespace as a percentage. - static member Column(data,?Name,?Title,?Labels, ?Color,?XTitle,?YTitle,?ColumnWidth) = + static member Column(data,?Name,?Title,?Labels,?Color,?XTitle,?YTitle,?ColumnWidth) = let c = GenericChart.Create(mergeDataAndLabelsForY data Labels, fun () -> GenericChart(SeriesChartType.Column)) |> Helpers.ApplyStyles(?Name=Name,?Title=Title,?Color=Color,?AxisXTitle=XTitle,?AxisYTitle=YTitle) @@ -2573,10 +2573,9 @@ namespace FSharp.Charting let intervals = match Intervals with | Some intervals -> intervals | _ -> 30. // corresponds to what ggplot does - let data'' = (binData data' lowerBound upperBound intervals) |> Seq.map (fun b -> b.Count) - let labels = (binData data' lowerBound upperBound intervals) |> Seq.map (fun b -> b.LowerBound.ToString()) - Chart.Column(data'',?Name=Name,?Title=Title,?Labels=Some labels, ?Color=Color,?XTitle=XTitle,?YTitle=YTitle, ?ColumnWidth=Some 0.95) - + let bins = binData data' lowerBound upperBound intervals + let data'' = bins |> Seq.map (fun b -> (b.LowerBound.ToString(), b.Count)) + Chart.Column(data'',?Name=Name,?Title=Title,?Color=Color,?XTitle=XTitle,?YTitle=YTitle,?ColumnWidth=Some 0.95) /// Displays a series of connecting vertical lines where the thickness and direction of the lines are dependent on the action of the price value. /// The data for the chart. From 01de8236fc0d5facfa83072782ffc0bf4f4f9a56 Mon Sep 17 00:00:00 2001 From: Bohdan Szymanik Date: Thu, 10 Sep 2015 15:55:43 +1200 Subject: [PATCH 6/8] Corrected the data for the histogram to contain the x-values... But x-axis still not displaying correctly. One more thing to fix --- src/FSharp.Charting.Gtk.fs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/FSharp.Charting.Gtk.fs b/src/FSharp.Charting.Gtk.fs index 2a03218..da0f7ba 100644 --- a/src/FSharp.Charting.Gtk.fs +++ b/src/FSharp.Charting.Gtk.fs @@ -955,24 +955,26 @@ namespace FSharp.Charting /// The data for the chart. /// The name of the data set. /// The title of the chart. - /// The labels that match the data. /// The color for the data. /// The title of the X-axis. /// The title of the Y-axis. + /// The lower bound of the histogram. + /// The upper bound of the histogram. + /// The number of intervals in the histogram. static member Histogram(data:seq<#value>,?Name,?Title,?Color,?XTitle,?YTitle, ?LowerBound, ?UpperBound, ?Intervals) = let data' = data |> Seq.map valueToDouble let lowerBound = match LowerBound with - | Some LowerBound -> LowerBound + | Some lowerBound -> lowerBound | _ -> Seq.min data let upperBound = match UpperBound with - | Some UpperBound -> UpperBound + | Some upperBound -> upperBound | _ -> Seq.max data let intervals = match Intervals with - | Some Intervals -> Intervals + | Some intervals -> intervals | _ -> 30. // corresponds to what ggplot does - let data'' = (binData data' lowerBound upperBound intervals) |> Seq.map (fun b -> b.Count) - let labels = (binData data' lowerBound upperBound intervals) |> Seq.map (fun b -> b.LowerBound.ToString()) - Chart.Column(indexData data'',?Name=Name,?Title=Title,?Labels=Some labels, ?Color=Color,?XTitle=XTitle,?YTitle=YTitle, ?ColumnWidth=Some 0.95) + let bins = binData data' lowerBound upperBound intervals + let data'' = bins |> Seq.map (fun b -> (b.LowerBound.ToString(), b.Count)) + Chart.Column(data'',?Name=Name,?Title=Title,?Color=Color,?XTitle=XTitle,?YTitle=YTitle, ?ColumnWidth=Some 0.95) #if INCOMPLETE_API /// Similar to the Pie chart type, except that it has a hole in the center. @@ -2626,4 +2628,3 @@ namespace FSharp.Charting #endif - From 1d8bccdad747638f42083084d1b2a8319549f09d Mon Sep 17 00:00:00 2001 From: Bohdan Szymanik Date: Fri, 11 Sep 2015 16:32:02 +1200 Subject: [PATCH 7/8] Tweak xaxis display Add a format specifier --- src/FSharp.Charting.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FSharp.Charting.fs b/src/FSharp.Charting.fs index d72b1c0..58b3fe8 100644 --- a/src/FSharp.Charting.fs +++ b/src/FSharp.Charting.fs @@ -2574,7 +2574,7 @@ namespace FSharp.Charting | Some intervals -> intervals | _ -> 30. // corresponds to what ggplot does let bins = binData data' lowerBound upperBound intervals - let data'' = bins |> Seq.map (fun b -> (b.LowerBound.ToString(), b.Count)) + let data'' = bins |> Seq.map (fun b -> ( sprintf "%.2f" b.LowerBound), b.Count) Chart.Column(data'',?Name=Name,?Title=Title,?Color=Color,?XTitle=XTitle,?YTitle=YTitle,?ColumnWidth=Some 0.95) /// Displays a series of connecting vertical lines where the thickness and direction of the lines are dependent on the action of the price value. From bbfd8846e1bc75c7eba91fb223e273a34296d0a1 Mon Sep 17 00:00:00 2001 From: Bohdan Szymanik Date: Fri, 11 Sep 2015 16:33:52 +1200 Subject: [PATCH 8/8] Format bin labels Just need to get them to display! --- src/FSharp.Charting.Gtk.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FSharp.Charting.Gtk.fs b/src/FSharp.Charting.Gtk.fs index da0f7ba..2d57676 100644 --- a/src/FSharp.Charting.Gtk.fs +++ b/src/FSharp.Charting.Gtk.fs @@ -973,7 +973,7 @@ namespace FSharp.Charting | Some intervals -> intervals | _ -> 30. // corresponds to what ggplot does let bins = binData data' lowerBound upperBound intervals - let data'' = bins |> Seq.map (fun b -> (b.LowerBound.ToString(), b.Count)) + let data'' = bins |> Seq.map (fun b -> ( sprintf "%.2f" b.LowerBound), b.Count) Chart.Column(data'',?Name=Name,?Title=Title,?Color=Color,?XTitle=XTitle,?YTitle=YTitle, ?ColumnWidth=Some 0.95) #if INCOMPLETE_API