Sign in to follow this  
gt_cristian

Rendering charts from VB and using chart links

Recommended Posts

Hi all,

I managed to code the following method that generates a chart in the desired panel. It is a Column2D chart that displays the data from an array.

Dim strXML As New StringBuilder()

Dim i As Integer

Dim outPut As String = ""

If (chart = "column2D") Then

strXML.Append(

"<chart caption='" & title & "' showborder='0' bgalpha='0' subcaption='' xAxisName='" & x & "' yAxisName='" & y & "' rotateLabels='1' placeValuesInside='1' rotateValues='1' param name='wmode' value='Opaque'> >")

For i = 0 To (data.Length - 1)

strXML.Append(

"<set label='" & labels(i) & "' value='" & data(i) & "'/>")

Next i

strXML.Append("</chart>")

If IsPostBack = True Then

outPut = FusionCharts.RenderChartHTML(

"FusionCharts/Column2D.swf", "", strXML.ToString(), "chart2", "430", "300", False, True, True)

Else

outPut = FusionCharts.RenderChart("FusionCharts/Column2D.swf", "", strXML.ToString(), "chart2", "430", "300", False, True, True)

End If

I would like to add links to this chart such that when I click on a column I update another chart by calling a similar method. I dont know how to dynamically generate charts from javascript, so I chose doing it from VB. How can I add links to triger a VB sub?

Thanks in advance.

Have a great weekend.

Chris.

Share this post


Link to post
Share on other sites

Hi,

 
I am afraid, FusionCharts can only call JavaScript methods and no any server side script methods. And to work with this situation you would need to use AJAX or using hardcoded javascript.
 
To move forward with the second method you can make a javascript method and link it to the chart with link attribute (<set value='323' label='label' link=' loadChart(data)' />), now need to write the code to update or create a new chart in loadChart method. 
 
Example:

function loadChart(val)

{

var xmlStr = "<chart><set value='" + val + "' /> </chart>";

var chart = new FusionCharts ("../FusionCharts/Column2d.swf","col",300,400,false,true);

chart.setDataXML (xmlStr);

chart.render (

"chartdiv");

}

 
 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this