0

I am using FSharp.Charting 0.87 to draw very basic chart of linear function. Is there a way to turn Y axis label back to normal position? In other words, can I have 'Y' oriented normally, not turned at 90 degrees?

Namely, I wonder if Axis.TextOrientation is exposed anywhere.

Here is the code:

#load "packages/FSharp.Charting.0.87/FSharp.Charting.fsx"    
open FSharp.Charting
open System.Drawing
Chart.Line([0,0;1,0;2,1;3,1;5,0; 6,0])
            .WithYAxis(Title = "Y", TitleAlignment = StringAlignment.Far)
            .WithXAxis(Title = "x", TitleAlignment = StringAlignment.Far)
            .ShowChart()
  • What do you mean by "normal" position? The `TitleAlignment` parameter that you set specifies that it should be at the rightmost/topmost position... is that what you want? – Tomas Petricek Nov 06 '13 at 21:16
  • Edited the question to make it more clear, sorry. – Dmitry Sevastianov Nov 06 '13 at 21:55
  • As far as I can see, it is not exposed. You can still edit this once the chart is displayed if you right click on the chart and click "Show Property Grid" (where you can edit everything), but it might not be possible to do this from code... – Tomas Petricek Nov 06 '13 at 22:00
  • Yes, it looks like you're right. Does it make sense to open an issue on the project? Better yet, is there a way to expose underlying Chart control somewhere, just for this kind of weird requests? – Dmitry Sevastianov Nov 06 '13 at 22:02

1 Answers1

1

Here is the hack to get around the issue, in case anyone else needs it. In short, to get to the properties of Chart object, one has to create ChartControl first:

#load "packages/FSharp.Charting.0.87/FSharp.Charting.fsx"    
open FSharp.Charting
open FSharp.Charting.ChartTypes
open System.Drawing
open System.Windows.Forms

let chart = Chart.Line([0,0;1,0;2,1;3,1;5,0; 6,0])
                    .WithYAxis(Title = "Y", TitleAlignment = StringAlignment.Far)
                    .WithXAxis(Title = "x", TitleAlignment = StringAlignment.Far)
let ctrl = new ChartControl(chart, Dock=DockStyle.Fill)
let chartObj = ctrl.Controls |> Seq.cast<Control> |> Seq.pick (function | :? DataVisualization.Charting.Chart as x -> Some x | _-> None)
chartObj.ChartAreas.[0].AxisY.TextOrientation <- DataVisualization.Charting.TextOrientation.Horizontal
let form = new Form(Visible = true, TopMost = true, Width = 700, Height = 500)
form.Controls.Add(ctrl)
form.Show()