如何在Linqpad F中显示来自DataVisualization的图表#

时间:2017-06-24 18:57:55

标签: linqpad

使用Linqpad 5.0,我的代码如下所示:

import requests
jsonurl = 'http://api2.coindesk.com/site/headerdata.json?currency=BTC'
json = requests.get(jsonurl).json()

for key, value in json.items():                     #Loop through the first branch of the json
    if type(value) == type(dict()):                 #each branch that has a dictionary is what contains the currency and rate
        for subKey, subValue in value.items():      #Loop through those dictionaries
            if type(subValue) == type(dict()):      #if there is a dictionary in this key value pair then we loop through them.
                for subKey1, subValue1 in subValue.items():     #Our final loop
                    if subKey1 == 'rate_float':                 #The rates are held in rate_float value in this key
                        print('exchange: ' + subKey, 'rate: ' +  str(subValue1)             )

如果我说

open System
open System.Net

open System.Windows.Forms
open System.Windows.Forms.DataVisualization

open FSharp.Charting

...

module Chart = 
/// Creates a line chart from the given sequence using at 
/// most 'count' numbers and automatically adding X axis
let SimpleLine(seq, count) =
  seq |> Seq.truncate count
      |> Seq.mapi (fun i v -> i, v)
      |> Chart.Line

let chart = Chart.SimpleLine([1.0; 2.0; 4.0; 8.0], 3)

我看到典型的Linqpad盒子,但不是图表本身。

1 个答案:

答案 0 :(得分:1)

以下函数调用有效:

chart.ShowChart()