javascript fusion charts not appearing in the new window - fusioncharts

I have a web page where fusion chart is rendered, my requirement is to bring this chart to a new window and send it for print.
function that I am using for bring the new window is
function printBtn(){
var prtContent1 = document.getElementById("chartdiv");
var WinPrint = window.open('', '', 'left=0,top=0,width=800,height=900,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent1.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
I picked one html file from the FusionChart XT folder and put a 'print' btn.
In the local m/c its works as expected. But when I put the same code and set of js/swf files in the server, the chart in the new page looks like this..
As you can see..only the labels appear and the chart is not seen.
What could I be missing here. Our application is hosted on IBM Websphere App Server. Am bringing javascript charts using FusionChart XT.
Thanks.

The code you are using to replicate the chart is not a standard method to copy SVG or VML. A number of things will not be copied to the WinPrint window by using innerHTML method. Instead try this:
Load fusioncharts.js in the new window
Then recreate the chart on that window by cloning it from source.

Related

openui5 googlemaps xmlview

I am currently building an, where i need to add a maps option. I found the openui5-googlemaps option which fitted my needs. Currently i managed to get the marker to work in an xml view without any problems. However I want to add directions with waypoints similar to what you see here:
DirectionsWithWaypoints
But i can't figure out how to build this into my XML view. I tried to add this via the controller to the view and just add the myMap element to the page. That did show the map, but it didn't show any directions, i looked at the binding and i had the correct binding.
If i added the myMap to the context of the HTML file instead, then it works.
See the code here
Can someone help?
one trick to finding out how to make something work in an XML view is via the SAPUI5 Diagnostics tool, it generates the xml for you
<ctrl><shift><alt> + S
opens the SAPUI5 Diagnostics tool, then
-> Control Tree -> Export -> XML
here is an example using generated xmlview

JFreeChart charts appearance when combined with JasperReports

I use JFreeChart in my java application to display charts like this one:
But after creating a report with JasperReports that chart now looks like this:
And that's not all, this is how a chart looks like inside the first PDF report generated with the app:
And this is how it looks when I generate a second report, without changing anything, just generating it again:
This happens again and again, everytime I restart the application. Charts are ok until I create a report. What's happening?
It looks like JasperReports is using a more prosaic BarPainter in it's ChartTheme, probably to accommodate destinations that handle gradients poorly.
This forum thread suggests applying the desired theme directly to the chart. The createLegacyTheme() method "returns a ChartTheme that doesn't apply any changes to the JFreeChart defaults. It, or something similar, might be worth a try:
StandardChartTheme.createLegacyTheme().apply(chart)
I've moved the edits here as an answer:
The theme problem
Thanks to #trashgod I've tried the following line:
ChartFactory.setChartTheme(StandardChartTheme.createJFreeTheme());
If I use this line before creating charts in my application, reports no longer affect the appearance of them. I think it is enough to put this line just once after report creation.
So now I just have one problem: the first report is different from subsequent reports: charts are different, fonts are bolder and not antialiased...
The Problem of the second report
The pdf issue is not caused by jasper reports nor jfreechart. It is a problem of Adobe Reader. This happens when you have more than one instance of Adobe Reader running (for example, when you have two different files opened).
An example of the problem:
Similar issues:
http://forums.adobe.com/message/4192938
http://forums.adobe.com/thread/902298

How to use pdf.js with gwt [duplicate]

We have an application built on GWT framework where we want to display a PDF file without any browser plugin and are currently evaluating PDF.js to do that.
The problem is, no matter what I do, I am not able to render a PDF file onto a canvas in our GWT application. Do give some background
The PDF file ticket is retrieved from server.
The PDF.js file ticket is retrieved from server and is embedded in the HTML body by using this script
var head= document.getElementsByTagName('body')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.setAttribute('charset', 'UTF-8');
script.src=url;
head.appendChild(script);
Canvas element is created in the View (using googles MVP pattern here) and a JSNI call is made to the script which embeds the PDF.js in the HTML body using the above function. The script then makes a call to function which works with PDFJS class defined in PDF.js file.
The function to render the PDF file on canvas is as below :
PDFJS.disableWorker = true;
PDFJS.getDocument(url).then(function getPdfHelloWorld(pdf)
{
pdf.getPage(1).then(function getPageHelloWorld(page)
{
var scale = 1.25;
var viewport = page.getViewport(scale);
canvas.height = viewport.height;
canvas.width = viewport.width;
page.render({canvasContext: context, viewport: viewport});
page.startRendering(context);
alert("Finished rendering");
});
});
The canvas and context are created in the View class and passed to the javascript.
The problem here is, after the call to JSNI is made, I show alerts of all variables. The browser shows alerts except when I make a call alert(PDFJS). This shows that PDFJS variable is not being recognised in the script.
This makes me think PDF.js file is not correctly embedded in the view or there is something else that I am missing.
Note: I have downloaded most of the examples over the net and most of them work locally i.e. I can modify the PDF.js file path to pick up a local copy and the HTML still renders the PDF. It has no problem reading the PDFJS variable. Its only in this GWT application that I see these problems.
Does anyone have any clue whats happening. Your help will be highly appreciated.
Thanks
Your problem is that you're injecting the script so it aloads asynchronously, but you don't wait until after it's loaded to start using it.
Try using ScriptInjector.FromUrl to inject the script and put the rest of your code in the Callback's onSuccess.
Injecting the script synchronously (by adding it to your HTML host page, or GWT Module descriptor —note: won't work with the xsiframe linker—), as proposed by Ilya is of course also a solution.
Try to add <script src="PDF.js"/> in your .gwt.xml file and put PDF.js file in your public director

Clickable barchart, where clicking on any bar would redirect to concern information page

I`m making student progress tracking system, where I need to show the progress chart on every subject.
Here every bar represent the subject, while clicking on any bar(subject) would produce another chart that is showing the progress of that particular subject.
I want every bar of bar-chart click-able that I can fire the event by clicking on that, so any help on that?(I am using ASP.NET(C#) for development)
You just need to bind a click event to the chart by inserting in page_load the following code: this.CT_RT_DB_Pt3_1.Click += new ImageMapEventHandler(Chart1_Click); And then add the protected void Chart1_Click(object sender, ImageMapEventArgs e) method inside the inherited page class, and use e.PostBackValue to specify the subject clicked..
Specify the postback value to be the xaxis label of the bar clicked in the .aspx file: <asp:Series Name="Series1" PostBackValue="#AXISLABEL"></asp:Series>
You can easily implement this with Flash or JavaScript version of amCharts
The charts are client-side so all you need to do on the server is generate your data in CSV or
XML format and feed it to the charting controls.

Microsoft Charting Controls for IE6 using asp.net mvc not working

i have a big problem here..i am using Microsoft charting controls in my asp.net mvc application..pie chart is working in my Mozilla Firefox perfectly when i open try to run the application in IE the chart is not displaying. when i refresh the page couple of times its showing the chart there?
is there anything doing wrong?
please can anybody help me out
thanks
I use also Microsoft Chart control in my ASP.NET MVC application. The problem which you describe can not appears in my case. I can explain why. I have a MVC Controller with the method GetChart which gives back pure PNG file as a stream. So I define on a HTML page (on a View to be exactly) a <img> element with src attribute like "<%= Url.Content ("~/Home/GetChart")%>". So web browser load and display a PNG graphic only. Such implementation works perfect in all browsers. It is also tested and works with IE6.
My GetChart method looks like following:
public FileStreamResult GetChart (/*some additional parameters*/) {
MyChartModel model = new MyChartModel ();
System.Web.UI.DataVisualization.Charting.Chart chart =
model.CreateChart (/*some parameters*/);
// Save the chart in a MemoryStream
MemoryStream imageStream = new MemoryStream ();
chart.SaveImage (imageStream, ChartImageFormat.Png);
// Reset the stream’s pointer back to the start of the stream.
imageStream.Seek (0, SeekOrigin.Begin);
return new FileStreamResult (imageStream, "image/png");
}
The code of the model MyChartModel is a little longer, but if you have already a implementation of Microsoft Chart you have already all needed.