OWC 10 chChartTypeLineMarkers HELP

M

MNFV

Hi,

I've wrote the code GRAPHIC_ENGINE.ASPX.VB
but it doesn't work properly, because the chart appears only with one
dataline (the last line resulting from the query). Can anyone tell me
what i'm doing wrong?

Thanks in advance.
Marco Viana
Portugal



GRAPHIC_ENGINE.ASPX.VB:

Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.OWC


Public Class graphic_engine
Inherits System.Web.UI.Page
Protected WithEvents chartspace1 As OWC.ChartSpace



Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here


Response.Buffer = True

'''************************************************************
'''*** Query building
'''************************************************************

Dim v_campanha As String
v_campanha = Request.QueryString("idcampanha")
Dim a_campanha() As String
a_campanha = Split(v_campanha, ",")


Dim v_estacao As String
v_estacao = Request.QueryString("idestacao")
Dim a_estacao() As String
a_estacao = Split(v_estacao, ",")


Dim v_parametro As String
v_parametro = Request.QueryString("idparametro")

Dim v_profundidade As String
v_profundidade = Request.QueryString("idprofundidade")



Dim a_sql_series(UBound(a_estacao) + 1, 1) As String

'Criar primeira linha do array com uma query que vai criar
todas as campanhas
a_sql_series(0, 0) = "SELECT nome, 0 AS valor FROM l_periodo
ORDER BY codigo"
a_sql_series(0, 1) = "SELECT count(*) FROM l_periodo"

Dim j As Integer
j = 0

Dim k As Integer
k = 1

While j <= UBound(a_estacao)
a_sql_series(j + 1, 0) = "SELECT periodo,cast(valor AS
float),parametro,profund,unid FROM l_medicoes WHERE parametro_codigo="
& v_parametro & " AND profund='" & v_profundidade & "' AND
local_codigo=" & a_estacao(j) & " AND (periodo_codigo = " &
a_campanha(0) & " "
'a_sql_series(j, 0) = "SELECT periodo_codigo,cast(valor AS
float),parametro,profund,unid FROM l_medicoes WHERE parametro_codigo="
& v_parametro & " AND profund='" & v_profundidade & "' AND
local_codigo=" & a_estacao(j) & " AND (periodo_codigo = " &
a_campanha(0) & " "

a_sql_series(j + 1, 1) = "SELECT count(*) FROM l_medicoes
WHERE parametro_codigo=" & v_parametro & " AND profund='" &
v_profundidade & "' AND local_codigo=" & a_estacao(j) & " AND
(periodo_codigo = " & a_campanha(0) & " "

While k <= UBound(a_campanha)
a_sql_series(j + 1, 0) = a_sql_series(j + 1, 0) & " OR
periodo_codigo = " & a_campanha(k) & " "
a_sql_series(j + 1, 1) = a_sql_series(j + 1, 1) & " OR
periodo_codigo = " & a_campanha(k) & " "

If k = UBound(a_campanha) Then
a_sql_series(j + 1, 0) = a_sql_series(j + 1, 0) &
") "
a_sql_series(j + 1, 1) = a_sql_series(j + 1, 1) &
") "
End If
k = k + 1
End While
a_sql_series(j + 1, 0) = a_sql_series(j + 1, 0) & " ORDER
BY periodo_codigo"
j = j + 1
k = 1
End While


'''************************************************************
'''*** End Query Building
'''************************************************************



'declare chartsapce, chart and "series objects" of OWC

'new chartspace
Dim chartspace1
chartspace1 = New OWC.ChartSpace()
chartspace1.Clear()

'new chart
chartspace1.charts.add()

'DB Connection

Dim ConnStr As String
ConnStr = f_conexion_string_bd(Session("username"),
Session("password"))
Dim PubsConn As New SqlClient.SqlConnection(ConnStr)
PubsConn.Open()

'Loop--> creation of graphic
Dim m As Integer
m = 0
While m <= UBound(a_sql_series)


Dim countCmd As New SqlCommand(a_sql_series(m, 1),
PubsConn)

Dim perfilCmd As New SqlClient.SqlCommand(a_sql_series(m,
0), PubsConn)

'Declare DataReader object
Dim data_reader As SqlClient.SqlDataReader

'Declare variables
Dim i As Integer
Dim numpoints 'number of datapoints
Dim categories() 'array with x values
Dim values() 'array with y values


'1st: find number of datapoints
data_reader = countCmd.ExecuteReader()
data_reader.Read()
numpoints = data_reader.GetValue(0)
data_reader.Close()


'Redim arrays
ReDim values(numpoints - 1)
ReDim categories(numpoints - 1)

'2nd: bind arrays
data_reader = perfilCmd.ExecuteReader


i = 0

While data_reader.Read
categories(i) = data_reader.GetValue(0)
'Response.Write(categories(i) & "<br>")
values(i) = data_reader.GetValue(1)
'Response.Write(values(i) & "<p>")
i = i + 1
End While




'3th create graphs


chartspace1.charts(0).seriescollection.add(m)

chartspace1.charts(0).seriescollection(m).type =
chartspace1.constants.chChartTypeLineMarkers
chartspace1.Charts(0).SeriesCollection(m).SetData(OWC.ChartDimensionsEnum.chDimCategories,
OWC.ChartSpecialDataSourcesEnum.chDataLiteral, categories)
chartspace1.Charts(0).SeriesCollection(m).SetData(OWC.ChartDimensionsEnum.chDimValues,
OWC.ChartSpecialDataSourcesEnum.chDataLiteral, values)


data_reader.Close()


m = m + 1
End While


PubsConn.Close()



'Format chart
With chartspace1.Charts(0)
.HasLegend = True
.Legend.Position =
OWC.ChartLegendPositionEnum.chLegendPositionBottom
.HasTitle = True
.Title.Caption = "Gráfico"
.Axes(0).HasTitle = True
.Axes(0).Title.Caption = "Campanha"
.Axes(1).HasTitle = True
.Axes(1).Title.Caption = "parametro"
End With



With chartspace1.Charts(0).SeriesCollection(0)

.line.color = "white"
.interior.color = "white"
.border.color = "white"
.caption = ""
.Marker.Style = ChartMarkerStyleEnum.chMarkerStyleNone
'.DataLabelsCollection.Add()
End With


With chartspace1.Charts(0).SeriesCollection(1)
'.line.color = "black"
'.zorder = 200

End With
'chartspace1.Charts(0).SeriesCollection(2).

'Legends
Dim n As Integer
n = 1
Dim sql_estacao As String

While n <= UBound(a_estacao) + 1
sql_estacao = "SELECT nome FROM l_local WHERE codigo=" &
a_estacao(n - 1)
Dim estacaoCmd As New SqlClient.SqlCommand(sql_estacao,
PubsConn2)
Dim lista_estacao As SqlClient.SqlDataReader
lista_estacao = estacaoCmd.ExecuteReader()
lista_estacao.Read()
chartspace1.Charts(0).SeriesCollection(n).caption =
lista_estacao.GetValue(0)
lista_estacao.Close()

n = n + 1

End While


PubsConn2.Close()

Response.ContentType = "image/gif"
Response.Expires = 0
Response.BinaryWrite(chartspace1.GetPicture("gif", 600, 400))



Response.End()




End Sub

End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top