Sign in to follow this  
Arindam

embed multiple charts in single page

Recommended Posts

Hi All,

I am wondering if its possible to embed multiple charts in the same page? New to the world of asp.net. I can manage to create a multigraph pulling info from our db, but would like to create other graphs on the same page that do this as well.

Has anyone been sucessful with this? and if so how the on earth did you do it?

Cheers

Shock

Share this post


Link to post
Share on other sites

Hi there,

I cant seem to find any documentation that lends itself to embeding multiple charts in a single page (probably obvious to most but not to poor old me). Do you have some sample code based one one of your basic examples that I can follow?

One more question. Will I need to create another adodb connection again on the same page? What the best way around this?

Thanks again

Shock

this is what I have in my code behind page:

Imports

InfoSoftGlobal

Imports

System.Text

Partial

Class MultMultChartMDXTestBasicDataXML

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Literal1.Text = GetMonthlySalesChartHtml()

End Sub

Public Function GetMonthlySalesChartHtml() As String

Dim cn

Dim cel 'Declare cellset variable

Dim strMDX 'A string that holds the MDX query

Dim sConnect

Dim sXML As String

Dim intDCO

Dim intDC1

Dim intPCO

Dim intPC1

Dim yy

Dim r

cn = Server.CreateObject(

"ADODB.Connection")

cn.Mode = 3

cn.CursorLocation = 2

cn.IsolationLevel = 4096

sConnect =

"DATA SOURCE=myservername;PROVIDER=MYOLAP;Location=myipaddress"

cn.Open(sConnect,

"username", "password")

'---------------------------------------------------------------------------------

' INSERT MDX STRING HERE

strMDX = "SELECT {[accounts].[AAPT_REV],[accounts].[COS_AAPT]} ON COLUMNS,"

strMDX = strMDX &

"{[Month].[Jul],[Month].[Aug],[Month].[sep],[Month].[Oct],[Month].[Nov],[Month].[Dec],[Month].[Jan],[Month].[Feb],[Month].[Mar],[Month].[Apr],[Month].[May],[Month].[Jun]} ON ROWS"

strMDX = strMDX &

" FROM [Reportingaapt]"

strMDX = strMDX &

" WHERE ([Company].[TPWT],[transindicator].[All Indicators],[tradingindicator].[All tradingpartners],"

strMDX = strMDX &

"[accessmethod].[ALLAccessMethods],[coo_ausext].[Au_ext],[measures].[Financial],[Year].[2008],[Version].[Reported],[product].[TOT_PRODUCT])"

'-----------------------------------------------------------------------------------

' OPEN Cellset Object

cel = Server.CreateObject(

"ADOMD.Cellset")

cel.Open(strMDX, cn)

'----------------------------------------------------------------------------------------------

intDCO = cel.Axes(0).DimensionCount - 1

intDC1 = cel.Axes(1).DimensionCount - 1

intPCO = cel.Axes(0).Positions.Count - 1

intPC1 = cel.Axes(1).Positions.Count - 1

sXML =

""

'------ Define headings and labels -------

sXML = sXML &

"<chart caption='REVENUE v COS V OPEX V EBITDA (FY08)' numberPrefix='$' formatNumberScale='1' rotateValues='0' placeValuesInside='1' decimals='0' imageSave='1' imageSaveURL='FusionChartsSave.aspx' " & ">"

sXML = sXML &

"<categories" & ">"

'------ Define categories ---------------

For yy = 0 To intPC1

For r = 0 To intDC1

sXML = sXML &

"<category label=" & "'" & cel.Axes(1).positions(yy).Members®.Caption & "'" & " />"

Next

Next

sXML = sXML &

"</categories" & ">"

'------- define first dataset -------

sXML = sXML &

"<dataset seriesName='Revenue'" & ">"

For yy = 0 To intPC1

sXML = sXML &

"<set value=" & "'" & FormatNumber(cel(0, yy).Value, 0, , , 0) & "'" & " />"

Next

sXML = sXML &

"</dataset" & ">"

'------- define second dataset -------

sXML = sXML &

"<dataset seriesName='COS'" & ">"

For yy = 0 To intPC1

sXML = sXML &

"<set value=" & "'" & FormatNumber(cel(1, yy).Value, 0, , , 0) & "'" & " />"

Next

sXML = sXML &

"</dataset" & ">"

sXML = sXML &

"<" & "/chart" & ">"

Return InfoSoftGlobal.FusionCharts.RenderChart("charts/MSline.swf", "", sXML.ToString, "productSales", "600", "300", False, False)

'crucial to use "sXML.ToString". You need to change it back to html so you read it in webbrowser.

'remember that xml acts as a way to pass information from one place to anohther. once its at it destination

'you need to change it back to html.

'Use below code for single chart only

'Return FusionCharts.RenderChartHTML("charts/Column3D.swf", "", sXML.ToString, "myNext", "600", "300", False)

'------------------------------------------------------------------------------------------

cn.close()

cel =

Nothing

cn =

Nothing

 

End Function

 End

Class

Share this post


Link to post
Share on other sites

Hi,

 For multiple charts you have to take different Literal control with in design page say literal1, literal2, literal3

After that call different fusionchart render function with in Page_load event

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 Literal1.Text = GetMonthlySalesChartHtml()

 Literal2.Text = Chart1Html()

 Literal3.Text = Chart2Html()

End Sub

Now create 2 other function Chart1Html() and Chart2Html()

Public Function Chart1Html () As String

 '

 'Your code here goes here

 '

 Return FusionCharts.RenderChartHTML("charts/Column3D.swf", "", sXML.ToString, "myNext", "600", "300", False)

End Function

Public Function Chart2Html () As String

 '

 'Your code here goes here

 ' 

 Return FusionCharts.RenderChartHTML("charts/Column3D.swf", "", sXML.ToString, "myNext1", "600", "300", False)

End Function

 

Note when you are rendering fusioncharts that time chartID must be deferent.

Edited by Guest

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