New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting Google Charts #118

Closed
tpetricek opened this Issue Dec 12, 2016 · 13 comments

Comments

Projects
None yet
6 participants
@tpetricek
Member

tpetricek commented Dec 12, 2016

@sylvanc I think I figured out what needs to be changed to make Google charts load!

I believe we've been hitting this error on Friday and I think the second answer (specify callback) makes it work (obviously....).

@sylvanc

This comment has been minimized.

Show comment
Hide comment
@sylvanc

sylvanc Dec 14, 2016

Contributor

Excellent! Are you up for adding XPlot.GoogleCharts.Paket.fsx and XPlot.GoogleCharts.fsx that sets things up to work, as the Plotly versions do?

Contributor

sylvanc commented Dec 14, 2016

Excellent! Are you up for adding XPlot.GoogleCharts.Paket.fsx and XPlot.GoogleCharts.fsx that sets things up to work, as the Plotly versions do?

@tpetricek

This comment has been minimized.

Show comment
Hide comment
@tpetricek

tpetricek Dec 14, 2016

Member

I'll see if we can do it just through the FsLab formatters - that way, all you'd need to do is to #load "FsLab.fsx" - I think it should be doable without having any direct support for this in Jupyter.

(The same for Plotly - though I'm not yet sure why it does not already work out-of-the-box.)

Member

tpetricek commented Dec 14, 2016

I'll see if we can do it just through the FsLab formatters - that way, all you'd need to do is to #load "FsLab.fsx" - I think it should be doable without having any direct support for this in Jupyter.

(The same for Plotly - though I'm not yet sure why it does not already work out-of-the-box.)

@sylvanc

This comment has been minimized.

Show comment
Hide comment
@sylvanc

sylvanc Dec 14, 2016

Contributor

Sounds good!

Contributor

sylvanc commented Dec 14, 2016

Sounds good!

@cgravill

This comment has been minimized.

Show comment
Hide comment
@cgravill

cgravill Dec 14, 2016

Contributor

Would it still be possible to chart without "FsLab.fsx" as well? It's great to share the formatters as an option, just that we don't actually use FsLab in many of our notebooks.

Contributor

cgravill commented Dec 14, 2016

Would it still be possible to chart without "FsLab.fsx" as well? It's great to share the formatters as an option, just that we don't actually use FsLab in many of our notebooks.

@tpetricek

This comment has been minimized.

Show comment
Hide comment
@tpetricek

tpetricek Dec 14, 2016

Member

I'm sure we can support both options - though I want to make sure it can be done without modifying IFSharp directly - that way, we know that when the next cool charting library appears, we can support it just via a Nuget package.

Member

tpetricek commented Dec 14, 2016

I'm sure we can support both options - though I want to make sure it can be done without modifying IFSharp directly - that way, we know that when the next cool charting library appears, we can support it just via a Nuget package.

@Rickasaurus

This comment has been minimized.

Show comment
Hide comment
@Rickasaurus

Rickasaurus Dec 15, 2016

Contributor
Contributor

Rickasaurus commented Dec 15, 2016

@cgravill

This comment has been minimized.

Show comment
Hide comment
@cgravill

cgravill Dec 16, 2016

Contributor

Sounds excellent, we were really glad to get the code out into .fsx files so that users could update and add their own charting libraries via Paket. If we can free that even further that would really help with the extensibility story.

Contributor

cgravill commented Dec 16, 2016

Sounds excellent, we were really glad to get the code out into .fsx files so that users could update and add their own charting libraries via Paket. If we can free that even further that would really help with the extensibility story.

@ibebbs

This comment has been minimized.

Show comment
Hide comment
@ibebbs

ibebbs Jan 30, 2017

Hey @tpetricek did you make any progress on this? I'm playing with a notebook right now and would very much like to use GoogleCharts rather than Plotly. I'd be happy to help out any way I can...

ibebbs commented Jan 30, 2017

Hey @tpetricek did you make any progress on this? I'm playing with a notebook right now and would very much like to use GoogleCharts rather than Plotly. I'd be happy to help out any way I can...

@ibebbs

This comment has been minimized.

Show comment
Hide comment
@ibebbs

ibebbs Jan 30, 2017

FWIW, I managed to successfully render a GoogleChart by amalgamating the approaches used in XPlot.Plotly.fsx and Tomas' suggested fix above into a custom display printer shown here:

open IfSharp.Kernel.App

@"<script src=""https://www.google.com/jsapi""></script>" |> Util.Html |> Display

type XPlot.GoogleCharts.GoogleChart with
  member __.GetContentHtml() =
    let html = __.GetInlineHtml()
    html
      .Replace ("google.setOnLoadCallback(drawChart);", "google.load('visualization', '1.0', { packages: ['corechart'], callback: drawChart })")

type XPlot.GoogleCharts.Chart with
  static member Content (chart : GoogleChart) =
    { ContentType = "text/html"; Data = chart.GetContentHtml() }

AddDisplayPrinter (fun (plot: XPlot.GoogleCharts.GoogleChart) -> { ContentType = "text/html"; Data = plot.GetContentHtml() })

Hope it helps.

ibebbs commented Jan 30, 2017

FWIW, I managed to successfully render a GoogleChart by amalgamating the approaches used in XPlot.Plotly.fsx and Tomas' suggested fix above into a custom display printer shown here:

open IfSharp.Kernel.App

@"<script src=""https://www.google.com/jsapi""></script>" |> Util.Html |> Display

type XPlot.GoogleCharts.GoogleChart with
  member __.GetContentHtml() =
    let html = __.GetInlineHtml()
    html
      .Replace ("google.setOnLoadCallback(drawChart);", "google.load('visualization', '1.0', { packages: ['corechart'], callback: drawChart })")

type XPlot.GoogleCharts.Chart with
  static member Content (chart : GoogleChart) =
    { ContentType = "text/html"; Data = chart.GetContentHtml() }

AddDisplayPrinter (fun (plot: XPlot.GoogleCharts.GoogleChart) -> { ContentType = "text/html"; Data = plot.GetContentHtml() })

Hope it helps.

cgravill added a commit that referenced this issue Mar 16, 2017

Initial XPlot.GoogleCharts support
Adapted from #118
The charts aren't present on a reload as the main script hasn't been
loaded.
@cgravill

This comment has been minimized.

Show comment
Hide comment
@cgravill

cgravill Mar 17, 2017

Contributor

Thanks! I've made preliminary support for Google Charts adapted from your script @ibebbs #139

I adjusted it to save into the notebook so that output charts will last as outputs (when trusted).
Also enabled all chart types, which made for a ~400KB rather than ~300KB download but means the main chart types will work without additional changes.

I've done this in the same style as the Plotly one, @tpetricek it sounds like you have a more minimal approach so adjustments are welcome!

Contributor

cgravill commented Mar 17, 2017

Thanks! I've made preliminary support for Google Charts adapted from your script @ibebbs #139

I adjusted it to save into the notebook so that output charts will last as outputs (when trusted).
Also enabled all chart types, which made for a ~400KB rather than ~300KB download but means the main chart types will work without additional changes.

I've done this in the same style as the Plotly one, @tpetricek it sounds like you have a more minimal approach so adjustments are welcome!

sylvanc added a commit that referenced this issue Mar 17, 2017

Basic support for plotting with GoogleCharts (#139)
* Initial XPlot.GoogleCharts support

Adapted from #118
The charts aren't present on a reload as the main script hasn't been
loaded.

* Safe load

* Switch to downloading script

This allows you to have charts when you reload the notebook

* Ignore png/svg for now

* Switch to current GC API

https://developers.google.com/chart/interactive/docs/gallery/controls#load_your_libraries

* New API and prevent attempt to multiple load

* Include all chart types

It makes for a larger download ~400KB rather than 300KB but allows the
various chart types to work without modification.
@roguetrainer

This comment has been minimized.

Show comment
Hide comment
@roguetrainer

roguetrainer Mar 19, 2017

A quick thanks to all of the people working to add Google Charts to IfSharp. This will be a very useful feature. Humble end-users like me appreciate your efforts. 🥇 🥇

roguetrainer commented Mar 19, 2017

A quick thanks to all of the people working to add Google Charts to IfSharp. This will be a very useful feature. Humble end-users like me appreciate your efforts. 🥇 🥇

@cgravill

This comment has been minimized.

Show comment
Hide comment
@cgravill

cgravill Mar 19, 2017

Contributor

Please feel free to test the current behaviour and let us if it supports everything you need. It's committed but could do with more usage before it's deployed.

btw it's only a small step from building yourself as an end-user to contributing small bits of functionality.

Contributor

cgravill commented Mar 19, 2017

Please feel free to test the current behaviour and let us if it supports everything you need. It's committed but could do with more usage before it's deployed.

btw it's only a small step from building yourself as an end-user to contributing small bits of functionality.

@cgravill

This comment has been minimized.

Show comment
Hide comment
@cgravill

cgravill Jul 10, 2017

Contributor

Hi all, this initial support is in the beta 2 zip release. I'll close this issue now. Please do add new requests if there's adjustments or improvements for this.

Contributor

cgravill commented Jul 10, 2017

Hi all, this initial support is in the beta 2 zip release. I'll close this issue now. Please do add new requests if there's adjustments or improvements for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment