1

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?

  • The [example script](https://fslab.org/XPlot/chart/google-map-chart.html) shows tool tips just fine given FsLab is `correctly initialized` by running `FsLab.fsx`. Last line in your script with `Show(chart)` is not needed. – Gene Belitski Aug 14 '18 at 19:46
  • In my initial attempt, I did not use FsLab but added a reference to XPlot.GoogleCharts directly. I've tried a new console app using FsLab and still encounter this issue. If I don't include the last line, the map isn't displayed, and if I do include the last line, a map is displayed in the browser, but without tool tips. Is there a way to display the chart that I have missed? – H Wheelwright Aug 15 '18 at 06:30
  • Well, the chart produced by F# console app generating html that is then shown in a web browser is a setup quite different, than one in `FSLab` where the chart html is put into `suave` server as a page, then being shown by a browser. – Gene Belitski Aug 15 '18 at 14:02
  • I think I understand now, I think the issue is that the html has to be part of a live website for the map to be updated with tool tips. – H Wheelwright Aug 16 '18 at 12:46
  • Nope, your guess is wrong. You've forced me to compose an answer (kinda). I'll publish it shortly – Gene Belitski Aug 16 '18 at 21:16

1 Answers1

0

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.

Gene Belitski
  • 10,270
  • 1
  • 34
  • 54