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

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.

Related

javascript fusion charts not appearing in the new window

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.

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

Reloading an iframe in GWT

I am currently working on a GWT project where I am displaying an HTML file within an iframe in my application. This HTML file is actually being written to as it is getting displayed, and I am hoping to be able to reload the frame so that the changes made to the HTML file are reflected on screen. I am able to do this two different ways that both work when running in development mode, however neither seem to work when the project is deployed.
The first method I tried was setting the frame's URL to itself:
frame.setUrl(frame.getUrl());
The second method I tried using JSNI:
public native void refresh() /*-{
if($doc.getElementById('__reportFrame') != null) {
$doc.getElementById('__reportFrame').src =
$doc.getElementById('__reportFrame').src;
}
}-*/;
When deployed, the frame gets displayed in a Window, and when the file is finished being written to, a call to either of these refresh methods is made, and the frame refreshes to contain the finished HTML file. When I am deployed, the call to refresh does not reload the contents of the frame, however if I bring up the frame's context menu (in Firefox), then go into 'This Frame', and click Reload, it successfully reloads the frame to contain the finished HTML file. I have tested this on multiple versions of Firefox without any luck.
Does anyone have any suggestions? Why would the behavior be different from one mode to the other?
Thanks.
wow, google is really fast with his search^^
You can use some JSNI to do this. Create a method such as
protected native void reloadIFrame(Element iframeEl) /-{
iframeEl.contentWindow.location.reload(true); }-/;
Then call it with your iFrame element
so your question you posted twice was already answerd here
http://groups.google.com/group/google-web-toolkit/browse_thread/thread/64aa7712890652d3
We had a requirement where one GWT application(parent) had another GWT application(child) loaded in an iframe. The child application had to refresh the iframe after it performs certain DB operations. We used JSNI to accomplish the same.
private native void refreshChild(String url)/*-{
$wnd.location.href=url;
}-*/
In case, if the child frame needs to be redirected to another webpage, the url can be modified accordingly.
We did try to use the reload() method, but it did not help.
The above piece of code, of course needs to be written in the child application.

How to use GWT designer with Eclipse GWT plugin?

Sorry but I see no way to use it at all!
If I create GWT project with sample code, then SDK is generating a page with a HTML table where positions for sample TextBox-es and Button are already marked. So, if I open sample file with GWT designer and move button slightly down-right, I will get errors during run.
If I create GWT project without sample code, then GWT designer appears to be unable to open file with empty GUI.
Is there any way to design GUI from scratch or to see GWT designer usage sample?
Thanks
The problem is when you want GWT to create sample code for you, it puts the container parts of layout hard-coded in your projects html file. The generated sample uses RootPanel.get("someId").add(someWidget); to access these containers. When you open designer and move these widgets around, designer generates RootPanel.get("someId").add(someWidget,left,top); which doesn't work with this method.
On another note, when you want to create a class from scratch and open it with designer, you can simply add a reference to RootPanel to get around "this is not a gui class issue" such as :
public class SimpleClass {
RootPanel r = RootPanel.get();
public SimpleClass() {}
}

Nvigation within a GWT application

I intend to build a web application where users can enter their time every week and have been struggling to get my head around the concept of a single page in GWT that gets repainted with data depending on the user actions. After researching a lot on this site and google, I found one link that I would like to emulate but dont know how to go about doing it in GWT. Although their source code is available, I dont think it is full and complete. I got some idea from this link - Multiple pages tutorial in Google Web Toolkit (GWT) but again dont know how to implement it into a working version. One small working sample would be great to help me understand and get started.
Could anyone please guide me as to how to achieve the look and feel of the screen with the link below and how the content can be repainted with data from the server ? Would I need to put all the logic in one EntryPoint class ? I would like to have the hyperlinks in the left navigation panel and show the content in the right panel. I seem to be completely lost after a few hours of research.
http://gwt.google.com/samples/Showcase/Showcase.html#!CwHyperlink
Thanks a lot for your help.
Regards,
Sonu.
A single page application layout is actually quite easy to achieve.
The first thing you do is define the general layout, using GWTs layout panels. For your layout, I'd suggest using a DockLayoutPanel.
Content content = new Content();
Button switchContent = new Button(content);
Navigation navigation = new Navigation();
navigation.add(switchContent);
DockLayoutPanel pageLayout = new DockLayoutPanel(Unit.EM);
p.addWest(new HTML(navigation), 7.5);
p.add(new HTML(content));
Here, the width of the navigation panel will be fixed, whereas the content will take the remaining space. You have to pass a reference of the button (or some other widget) which does the switch of the content area, add the button to the navigation area, and so on.
Put this into a class, e.g. called MasterPageFactory:
public class MasterPageFactory {
private MasterPageFactory() {}
public static MasterPage newInstance() {
Content content = new Content();
Button switchContent = new Button(content);
Navigation navigation = new Navigation();
navigation.add(switchContent);
DockLayoutPanel masterPage = new DockLayoutPanel(Unit.EM);
masterPage.addWest(new HTML(navigation), 7.5);
masterPage.add(new HTML(content));
return masterPage;
}
}
Now, in your EntryPoint class, call the factory:
RootLayoutPanel.get().add(MasterPageFactory.newInstance());
This example should get you an idea. Other options would be using a DI framework like Guice or the Command pattern.
Your question is mixing up a couple of concepts. If you want the user to click something that looks like a link, and in reponse the application sends a request to the server and shows a page that looks different than the page they're on, and that page has fresh data that just came from the server, then you want a perfectly normal anchor or form submit button. You don't need anything special or weird from GWT.
The showcase example you referenced lets the user click something that looks like a link, and looks like it loads a new page, even to the point of letting the back button work as expected, but does not actually hit the server to get a new page or new data.