Jump to content
Software FX Community

Updating Charts Client-side using AJAX


User (Legacy)

Recommended Posts

Hi,

I'm evaluating your product for use in a new business intelligence product

for the financial services sector. I have a question regarding the .NET Webforms

ChartFx component. Is it possible from client-side Javascript to issue an

AJAX command to have the chart refresh itself?

Here's my situation. We have developed our own OLAP browser which updates

itself after drag/drop operations using AJAX. We want to display your chart

component below it. However, since the OLAP browser is being refreshed using

AJAX only its particular section of the page gets updated. Keeping the two

in synch is a problem. I havn't found a refresh button in the chart's toolbar,

but ideally, whenever we replace the HTML for the OLAP browser I would like

to send the server the same command that a button like that might send to

update the chart.

Any suggestions?

Thank you,

Terry Smith

Senior Architect

Insight Ecosystems

Link to comment
Share on other sites

  • 1 month later...

Interesting situation, but I see a lot of problems:

You said that you update your OLAP control using AJAX but does your olap

control modifies the chart in the server ?

A refresh command won't do. If all you do is modify the chart, those changes

will be lost after you return as a new chart control is created on each

request, you would need to update the viewstate. We offer a Export method

that you can use to export the chart settings, you could then return this to

your client so that it is put into the viewstate. We do something similar

when we use or .NET client control.

I think this can be done though, but it will require from you to do some

work in your control to transmit chart's state back and forth.

--

Francisco Padron

www.chartfx.com

Link to comment
Share on other sites

Thank you for your response. I don't mind doing some work to get this going.

I was thinking about updating the chart myself by placing the control in

an "AJAX panel" of my creation and updating it myself. If I understand you

correctly, any end-user customizations via the toolbar or menus in the chart

control would be lost by doing this, correct? So I need to export and then

import the user settings somehow? Can you give me some more guidance if this

is correct? Do I need to catch one one or more control events on the server

whenever the user clicks a toolbar button or something and save off the chart

settings in session state?

Thanks again,

Terry

Insight Ecosystems

Link to comment
Share on other sites

In the server, when you are ready to return your info to the client, you can 

call:

((ICallbackEventHandler) Chart1).RaiseCallbackEvent("0");

string output = ((ICallbackEventHandler) Chart1).GetCallbackResult();

You then insert this output into your output.

In your client's code, you extract this output back and call:

SFX_OnCallbackReady(output,"Chart1");

Some XML encoding/Decoding may be needed depending on your response's

format.

--

Francisco Padron

www.chartfx.com

Link to comment
Share on other sites

Hi Francisco,

Thanks again for your help. I've got side-tracked on another problem the

last few days, but I'm back to looking at this fun problem now. And I'm still

confused...

The RaiseCallbackEvent\GetCallbackResult call that you gave me only returns

what looks like the hot spot area mapping for the chart. Also, I tried the

Export method you mentioned in a previous post and that seems to only export

the actual rendering of the chart like to an image file.

Here's what I think I need. Please let me know if I'm totaly off track, and

if not some guidance on how to implement it would be appreciated! Maybe what

you have already told me is what I need to know, but I'm just not making

the mental connection.

First, whenever an appearance changing toolbar or menu item is selected I

need to intercept that on the server and then export the chart's settings

and save them off. Later when the user has changed the data in my OLAP viewer

and it gets refreshed using AJAX, then from Javascript I can do a "refresh"

on the AJAX panel containing the ChartFX control. This will be my AJAX panel

and not the one the chart control uses internally. Once I'm on ther server

I create a new instance of the control, import the saved off settings, bind

it to the data, and then send the output of RenderControl back to the browser.

So is this even possible?

Thanks once again,

Terry

Link to comment
Share on other sites

I've been testing Export and Import for use in handling my problem like you 

suggested. I tried exporting the chart settings to a memory buffer, putting

it in Session (for testing at least), and then reloading it using Import

on the next web request. The Import throws an IndexOutOfRangeException. I've

verified that the memory stream is the right length and has the same bytes

in it (after matches before). The same things happens if I do an Import immediately

after doing an export. Here's a simplified example just to illustrate my

point:

chartFx.FileContents = Global.ChartFX.WebForms.FileContents.Template

chartFx.TemplateContents = Global.ChartFX.WebForms.FileContents.Template

Dim memStream As New System.IO.MemoryStream

chartFx.Export(Global.ChartFX.WebForms.FileFormat.BinaryTemplate, memStream)

'Next line throws this: "System.IndexOutOfRangeException: Index was outside

the bounds of the array."

chartFx.Import(Global.ChartFX.WebForms.FileFormat.BinaryTemplate, memStream)

Am I missing something?

Thanks once again,

Terry

post-2107-13922364382276_thumb.jpg

Link to comment
Share on other sites

Before importing the stream you have to "rewind" it by setting its position 

to 0.

--

JC

Software FX Support

"Terry Smith" <terry.smith@insightecosystems.com> wrote in message

news:66a06d7a203e8c7fb95df3684b8@news.softwarefx.com...

> I´ve been testing Export and Import for use in handling my problem like

> you suggested. I tried exporting the chart settings to a memory buffer,

> putting it in Session (for testing at least), and then reloading it using

> Import on the next web request. The Import throws an

> IndexOutOfRangeException. I´ve verified that the memory stream is the

> right length and has the same bytes in it (after matches before). The same

> things happens if I do an Import immediately after doing an export. Here´s

> a simplified example just to illustrate my point:

>

> chartFx.FileContents = Global.ChartFX.WebForms.FileContents.Template

> chartFx.TemplateContents = Global.ChartFX.WebForms.FileContents.Template

> Dim memStream As New System.IO.MemoryStream

> chartFx.Export(Global.ChartFX.WebForms.FileFormat.BinaryTemplate,

> memStream)

> ´Next line throws this: "System.IndexOutOfRangeException: Index was

> outside the bounds of the array."

> chartFx.Import(Global.ChartFX.WebForms.FileFormat.BinaryTemplate,

> memStream)

>

> Am I missing something?

>

> Thanks once again,

>

> Terry

>

>

Link to comment
Share on other sites

I'm close to getting my problem working, but I'm getting one exception that 

I can't figure out. When my OLAP browser has been refreshed and I re-hit

the server using AJAX, I'm attempting to put the new HTML for the OLAP browser

panel and the HTML for charts panel in an XML document that gets returned

to the client, pull the HTML pieces out, and place them into the SPAN panels.

That strategy should be fine I think.

However, when I attempt to render the chart into HTML it's throwing an exception.

The control is loaded and data has been bound to it, but when I do this:

Dim htmlStringBuilder As New StringBuilder()

Dim htmlStringWriter As New System.IO.StringWriter(htmlStringBuilder)

Dim htmlTextWriter As New HtmlTextWriter(htmlStringWriter)

charts.RenderControl(htmlTextWriter)

Dim html As String = htmlStringBuilder.ToString

RenderControl throws an exception:

"System.NullReferenceException: Object reference not set to an instance of

an object.

at ChartFX.WebForms.ag.a(String A_0)

at ChartFX.WebForms.ag.b(String A_0)

at ChartFX.WebForms.d.a(OutputText A_0, String A_1, String A_2, Boolean

A_3, String A_4)

at ChartFX.WebForms.d.a(OutputText A_0, Int32 A_1)

at ChartFX.WebForms.ag.a(OutputText A_0, ICommand A_1)

at ChartFX.WebForms.m.a()

at ChartFX.WebForms.Internal.h.a(OutputInfo A_0)

at ChartFX.WebForms.Internal.h.a(Stream A_0, OutputText A_1, OutputInfo

A_2)

at ChartFX.WebForms.Chart.a(Stream A_0, IOutputWriter A_1, OutputText

A_2, OutputText A_3, OutputInfo A_4)

at ChartFX.WebForms.Chart.a(OutputText A_0, OutputText A_1, Boolean A_2,

String A_3, String A_4)

at ChartFX.WebForms.Chart.Render(HtmlTextWriter output)

at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,

ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter

adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)

at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,

ICollection children)

at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)

at System.Web.UI.Control.Render(HtmlTextWriter writer)

at System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter

writer)

at System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)

at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,

ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter

adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)

at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,

ICollection children)

at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)

at System.Web.UI.Control.Render(HtmlTextWriter writer)

at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,

ControlAdapter adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter

adapter)

at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)

at InsightExplorer.RaiseCallbackEvent(String eventArgument) in C:\Insight\Insight_1.0\Website\InsightExplorer\InsightExplorer.ascx.vb:line

151"

Something must not be initialized, but I can't figure out what it is. The

component seems to be loaded and initialized like it would be on a normal

page refresh.

Any ideas?

Thanks once again,

Terry

Link to comment
Share on other sites

Hi All,

Here is the solution working!

You will have to create a website project to test and then make sure the

ChartFX Dlls are actually referenced in your project.

Enjoy!

Thank you Terry for the question.

-c

"Terry Smith" <terry.smith@insightecosystems.com> wrote in message

news:66a06d7a1f378c7f6176bcaf88e@news.softwarefx.com...

> Hi,

>

> I´m evaluating your product for use in a new business intelligence product

> for the financial services sector. I have a question regarding the .NET

> Webforms

> ChartFx component. Is it possible from client-side Javascript to issue an

> AJAX command to have the chart refresh itself?

>

> Here´s my situation. We have developed our own OLAP browser which updates

> itself after drag/drop operations using AJAX. We want to display your

> chart

> component below it. However, since the OLAP browser is being refreshed

> using

> AJAX only its particular section of the page gets updated. Keeping the two

> in synch is a problem. I havn´t found a refresh button in the chart´s

> toolbar,

> but ideally, whenever we replace the HTML for the OLAP browser I would

> like

> to send the server the same command that a button like that might send to

> update the chart.

>

> Any suggestions?

>

> Thank you,

>

> Terry Smith

> Senior Architect

> Insight Ecosystems

>

>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...