It is currently 21 April 2025, 12:46 Advanced search

Google charts in Book/Report

Questions and answers on how to best use Instant Developer

Google charts in Book/Report

Postby john w » 3 August 2021, 14:13

Design question. I want to put a chart in a report. I use Google charts and I need to set the properties of the chart. I have set the library in the

I have the chart on a form and it works well. What I curious to learn is the best place to put the chart properties in the report. Events are limited. The graph is in the detail section and I can add a procedure to that section. I just not sure it if fires when the report is run, or needs an event.

Specifically, this text.

AnalysisGraph.options = "{"trendlines": {"0": {"type": "linear", "color": "green", "lineWidth": "3","opacity": "0.
3","showR2": "true", "visibleInLegend": "true" }}}"

Any suggestions?
Regards

John W
User avatar
john w
 
Posts: 834
Joined: 24 October 2012, 16:29
Location: Apple Valley, Minnesota USA

Re: Google charts in Book/Report

Postby ATroyer » 3 August 2021, 15:27

Did you try using the Before Formatting event of the detail section containing the chart? You can set the code you want directly in the event, or call a procedure from the event.
ATroyer
 
Posts: 55
Joined: 30 October 2019, 13:30

Re: Google charts in Book/Report

Postby john w » 3 August 2021, 15:53

I think I tried that, but no luck so far. I will go back though and make sure I tried having it run a procedure.

The user manual suggests the same event but it is not doing what I need, though the event runs.
Regards

John W
User avatar
john w
 
Posts: 834
Joined: 24 October 2012, 16:29
Location: Apple Valley, Minnesota USA

Re: Google charts in Book/Report

Postby ljwilson » 3 August 2021, 17:40

InDe Users Guide, Section 7.3.7 "Graphs and Reports", p. 335, has a little info on it.

You are getting the chart displayed in the book already, without the options, correct? On that same page in the guide is written: "You can only use graphic engines based on the generation of images, such as JFreeChart", which makes me wonder if you can display a GoogleChart inside a book since it renders it in real-time.

Update:

At least as of 2017, GoogleCharts is not supported in books:
https://forum.instantdeveloper.com/viewtopic.php?f=5&t=74569&p=132139
Google Chart cannot be used in books .
In this case you need to use JFreeChart.


Though I would try JQPlot (Javascript-based version) since JFreeChart doesn't work well with 64-bit versions of windows (discussed in this forum in various places, such as: "Getting JFreeChart (c#) working in Windows 10" https://forum.instantdeveloper.com/viewtopic.php?f=7&t=70855&p=122836)

But if the book requires a graphic already created, then JQPlot might suffer from the same issue as GoogleCharts.

...jack
ljwilson
 
Posts: 783
Joined: 26 November 2013, 14:15

Re: Google charts in Book/Report

Postby john w » 3 August 2021, 18:21

I suppose that is possible. However, I need a trend line type of chart. I am not sure its available in InDe outside of Google Charts.
Regards

John W
User avatar
john w
 
Posts: 834
Joined: 24 October 2012, 16:29
Location: Apple Valley, Minnesota USA

Re: Google charts in Book/Report

Postby john w » 4 August 2021, 15:41

I have the graph in the report. I asked InDe about it and Google Charts can now exist in the report. The sent me a sample .idp file.

The sole remaining issue is setting the .options{"..."} information. Everything works in forms but not books/reports. The debugger shows them being read and applied(?) but the report displayed is without the needed options. Its just a vanilla form of the graph...pie, doughnut, line, bar etc. It makes me almost wonder if reports are really using Google Charts.

I have tried virtually every combination of events and procedures I can think of, all without success. For my project the options issue one I need to get to work if at all possible. The graph output that needed requires them.

If anyone has any suggestions, I am up for giving them a try.
Regards

John W
User avatar
john w
 
Posts: 834
Joined: 24 October 2012, 16:29
Location: Apple Valley, Minnesota USA

Re: Google charts in Book/Report

Postby ljwilson » 4 August 2021, 15:58

Well if that is all you lack then you could set the options in a custom3.js file. I've attached one here which gives you access to all of the options right before the the graph is rendered. At the very least you can use it to see if GoogleCharts is indeed being used for the report.

Use the Chrome developer tools js console to debug.

custom3.zip
Customized DrawGoogleChart function
(2 KiB) Downloaded 227 times
ljwilson
 
Posts: 783
Joined: 26 November 2013, 14:15

Re: Google charts in Book/Report

Postby john w » 4 August 2021, 16:54

Thanks - I have it downloaded and will look it over.

So far it seems the chartname.options properties are not functioning in the report. I can set the properties like chartname.title, chartname.settype, etc., but not using .options string. I need the more complex trendlines and R2 factors. Those are done using the options string.

I feel like I am so close but yet so far.
Regards

John W
User avatar
john w
 
Posts: 834
Joined: 24 October 2012, 16:29
Location: Apple Valley, Minnesota USA

Re: Google charts in Book/Report

Postby ljwilson » 4 August 2021, 17:32

I don't believe embedding a chart in a book is actually using GoogleCharts.

I've attached a modified version of my ChartJS example which uses GoogleCharts instead.

In the form load I set Options for a title, which shows correctly everywhere but the 3rd button (Create Graph PDF Using Embedded Chart)

The first two buttons will create a graphic (SaveGraphFile) or create a pdf (Create Graph PDF Using Embedded Image) which has a GoogleChart image (based on the graph which is on the panel). The 3rd button tries to use an Embedded Chart. Since setting it to pie does in fact change it, then if it was a true GoogleChart options should apply here as well. But they do not.

And the rendered image does not look like a Google Chart default pie chart at all.

Plus the javascript console debug never fires for button 3.

Maybe depending on how your app works you could use the embedded image trick instead.

GoogleCharts Printing Express.zip
GoogleCharts Printing Express InDe 21.0 r15
(478.6 KiB) Downloaded 222 times


...jack
ljwilson
 
Posts: 783
Joined: 26 November 2013, 14:15

Re: Google charts in Book/Report

Postby john w » 5 August 2021, 14:34

Thanks - I will look at the sample. I cannot get the options to work either. I can change the setLibrary and SetType but the image always looks the same. At least in my experimentation.

I see values being passed to the set .options in the debugger but they are not applied to the report graph. I have tried screen an print options thinking the rendering process might be slightly different. None of that plus other things have worked.

Its pretty frustrating given I have customers who want the graph on the form panel to be printed on the report. That means a trend line report with the R2 statistic. If I use a 3rd party reporting tool such as Stimulsoft there is no clean way for me to move the data which only exists in memory and is the result of calculations.

I am not even setting the report graph to be an inline frame would work. I have the data issues as well as the Slope function to work.

I find it hard to accept that charting in InDe books/reports has a limitation like this. I keep thinking I have missed the solution given the power of the toolset.
Regards

John W
User avatar
john w
 
Posts: 834
Joined: 24 October 2012, 16:29
Location: Apple Valley, Minnesota USA

Next

Return to Tips & Tricks

Who is online

Users browsing this forum: No registered users and 21 guests

cron