Search code examples
f#google-visualizationfslab

Why isn't XPlot.GoogleCharts.Chart.Map producing tooltips?


I'm trying to plot locations on a map with XPlot and googlecharts.chart.map.

I followed the example I found, but the resulting map had no tool tips on the specified locations.

To debug my code I simply attempted to reproduce the example, with the same result, i.e. no markers at the specified locations.

My implementation of the example (https://fslab.org/XPlot/chart/google-map-chart.html) is below:

let data =
        [
            "China", "China: 1,363,800,000"
            "India", "India: 1,242,620,000"
            "US", "US: 317,842,000"
            "Indonesia", "Indonesia: 247,424,598"
            "Brazil", "Brazil: 201,032,714"
            "Pakistan", "Pakistan: 186,134,000"
            "Nigeria", "Nigeria: 173,615,000"
            "Bangladesh", "Bangladesh: 152,518,015"
            "Russia", "Russia: 146,019,512"
            "Japan", "Japan: 127,120,000"
        ]


let options = XPlot.GoogleCharts.Configuration.Options(showTip = true)

let chart =  data 
             |> XPlot.GoogleCharts.Chart.Map
             |> XPlot.GoogleCharts.Chart.WithOptions options
             |> XPlot.GoogleCharts.Chart.WithHeight 420
             |> XPlot.GoogleCharts.Chart.WithWidth 800

chart |> XPlot.GoogleCharts.Chart.Show

The map is shown without any markers.

How should the code be modified to ensure the locations are marked?


Solution

  • The missing tooltips problem source is not in your code, but in the ambient environment.

    If you use your F# console charting app code without any changes, but bind it with nuget package XPlot.GoogleCharts ver 1.4.2 instead of the latest at the moment XPlot.GoogleCharts ver 1.5.0, it will work as expected, i.e. tooltips will be present even on the html static page viewed in the browser.

    The regression, I believe, has nothing to do with XPlot.GoogleCharts per se and is likely caused by the change to the way of loading JS libraries introduced by Google: XPlot.GoogleCharts ver 1.4.2 uses the old loader , while the latest XPlot.GoogleCharts ver 1.5.0 uses the new one.