jason_limwk
September 21st, 2005, 11:13 PM
got a sample coding and i am confuse on how to change the coding ...
now.. i already change the coding to wat i wana do for my assg.. intro of this...
in my datagrid, there are some data.. then i will use the data as the data for me to plt a graph... but now i wana limits the data o be ploted meaning when my data in the datagrid is more than 500 , i will not plot the value... (but i still nid the data in the datagrid..) thats y i kenot remove it at the veri beginning.. so now how should i fix it ? any ideas? the coding is...
Private Sub btnGraph_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGraph.Click
imgGraph.Visible = True
btnPrev.Visible = False
lblMemo.Text = ""
memo = 0
Dim oChartSpace As OWC11.ChartSpaceClass = New OWC11.ChartSpaceClass
Dim chartType As OWC11.ChartChartTypeEnum
Dim chartValuesArr As String() = TextBox1.Text.Split(",")
Dim chartCategoriesArr As String() = TextBox2.Text.Split(",")
Dim i As Integer
If chartValuesArr.Length <= 50 Then
For i = 0 To chartValuesArr.Length - 1
chartValuesStr += chartValuesArr(i) + ","
chartCategoriesStr += chartCategoriesArr(i) + ","
Next
Else
btnNext.Visible = True
For i = 0 To 50
chartValuesStr += chartValuesArr(i) + ","
chartCategoriesStr += chartCategoriesArr(i) + ","
Next
End If
chartValuesStr = chartValuesStr.Substring(0, chartValuesStr.Length - 1)
chartCategoriesStr = chartCategoriesStr.Substring(0, chartCategoriesStr.Length - 1)
'--------------------------------------------------------------
' Try using different chart types just for fun
'-------------------------------------------------------------
'chartType = ChartChartTypeEnum.chChartTypeArea
'chartType = ChartChartTypeEnum.chChartTypeArea3D
'chartType = ChartChartTypeEnum.chChartTypeBarClustered
'chartType = ChartChartTypeEnum.chChartTypeBar3D
'chartType = ChartChartTypeEnum.chChartTypeColumnClustered
'chartType = ChartChartTypeEnum.chChartTypeColumn3D
'chartType = ChartChartTypeEnum.chChartTypeDoughnut
'chartType = ChartChartTypeEnum.chChartTypeLineStacked
'chartType = ChartChartTypeEnum.chChartTypeLine3D
chartType = OWC11.ChartChartTypeEnum.chChartTypeLineMarkers
'chartType = ChartChartTypeEnum.chChartTypePie
'chartType = ChartChartTypeEnum.chChartTypePie3D
'chartType = ChartChartTypeEnum.chChartTypeRadarSmoothLine
'chartType = ChartChartTypeEnum.chChartTypeSmoothLine
'------------------------------------------------------------------------
' Give pie and doughnut charts a legend on the bottom. For the rest of
' them let the control figure it out on its own.
'------------------------------------------------------------------------
'chartType = OWC11.ChartChartTypeEnum.chChartTypeColumn3D
'If chartType = OWC11.ChartChartTypeEnum.chChartTypePie Or _
' chartType = OWC11.ChartChartTypeEnum.chChartTypePie3D Or _
' chartType = OWC11.ChartChartTypeEnum.chChartTypeDoughnut Then
' oChartSpace.HasChartSpaceLegend = True
' oChartSpace.ChartSpaceLegend.Position = OWC11.ChartLegendPositionEnum.chLegendPositionBottom
'End If
oChartSpace.Border.Color = "blue"
oChartSpace.Charts.Add(0)
oChartSpace.Charts(0).HasTitle = True
oChartSpace.Charts(0).Type = chartType
oChartSpace.Charts(0).Title.Caption = "Cycletime vs Datapoints"
oChartSpace.Charts(0).Title.Font.Bold = True
oChartSpace.Charts(0).SeriesCollection.Add(0)
oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection.Add()
'------------------------------------------------------------------------
'If you Then 're charting a pie or a variation thereof percentages make a lot
' more sense than values...
'------------------------------------------------------------------------
'If chartType = OWC11.ChartChartTypeEnum.chChartTypePie Or _
' chartType = OWC11.ChartChartTypeEnum.chChartTypePie3D Or _
' chartType = OWC11.ChartChartTypeEnum.chChartTypeDoughnut Then
' oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).HasPercentage = True
' oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).HasValue = False
'Else
' '------------------------------------------------------------------------
' ' Not so for other chart types where values have more meaning than
' ' percentages.
' '------------------------------------------------------------------------
' oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).HasPercentage = False
oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).HasValue = True
'End If
'------------------------------------------------------------------------
' Plug your own visual bells and whistles here
' ------------------------------------------------------------------------
oChartSpace.Charts(0).SeriesCollection(0).Caption = "Cycletime vs Datapoints"
oChartSpace.Charts(0).SeriesCollection(0).TipText = "Cycletime vs Datapoints"
oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).Font.Name = "verdana"
oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).Font.Size = 10
oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).Font.Bold = True
oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).Font.Color = "white"
oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).Position = OWC11.ChartDataLabelPositionEnum.chLabelPositionCenter
oChartSpace.Charts(0).SeriesCollection(0).Type = OWC11.ChartChartTypeEnum.chChartTypeLineStacked
oChartSpace.Charts(0).SeriesCollection(0).Marker.Style = OWC11.ChartMarkerStyleEnum.chMarkerStyleCircle
oChartSpace.Charts(0).SeriesCollection(0).Line.DashStyle = OWC11.ChartLineDashStyleEnum.chLineSquareDot
oChartSpace.Charts(0).SeriesCollection(0).SetData(OWC11.ChartDimensionsEnum.chDimCategories, Convert.ToInt32(OWC11.ChartSpecialDataSourcesEnum.chDataLiteral), chartCategoriesStr)
oChartSpace.Charts(0).SeriesCollection(0).SetData(OWC11.ChartDimensionsEnum.chDimValues, Convert.ToInt32(OWC11.ChartSpecialDataSourcesEnum.chDataLiteral), chartValuesStr)
'------------------------------------------------------------------------
' Pick your favorite image forma
' ------------------------------------------------------------------------
Dim height, width As Integer
height = 500
width = 700
Dim byteArr As Byte() = DirectCast(oChartSpace.GetPicture("png", width, height), Byte())
' ------------------------------------------------------------------------
' Store the chart image in Session to be picked up by an HttpHandler later
' ------------------------------------------------------------------------
Dim ctx As HttpContext = HttpContext.Current
Dim chartID As String = Guid.NewGuid().ToString()
ctx.Session(chartID) = byteArr
imgGraph.ImageUrl = String.Concat("chart.ashx?", chartID)
End Sub
thank you
now.. i already change the coding to wat i wana do for my assg.. intro of this...
in my datagrid, there are some data.. then i will use the data as the data for me to plt a graph... but now i wana limits the data o be ploted meaning when my data in the datagrid is more than 500 , i will not plot the value... (but i still nid the data in the datagrid..) thats y i kenot remove it at the veri beginning.. so now how should i fix it ? any ideas? the coding is...
Private Sub btnGraph_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGraph.Click
imgGraph.Visible = True
btnPrev.Visible = False
lblMemo.Text = ""
memo = 0
Dim oChartSpace As OWC11.ChartSpaceClass = New OWC11.ChartSpaceClass
Dim chartType As OWC11.ChartChartTypeEnum
Dim chartValuesArr As String() = TextBox1.Text.Split(",")
Dim chartCategoriesArr As String() = TextBox2.Text.Split(",")
Dim i As Integer
If chartValuesArr.Length <= 50 Then
For i = 0 To chartValuesArr.Length - 1
chartValuesStr += chartValuesArr(i) + ","
chartCategoriesStr += chartCategoriesArr(i) + ","
Next
Else
btnNext.Visible = True
For i = 0 To 50
chartValuesStr += chartValuesArr(i) + ","
chartCategoriesStr += chartCategoriesArr(i) + ","
Next
End If
chartValuesStr = chartValuesStr.Substring(0, chartValuesStr.Length - 1)
chartCategoriesStr = chartCategoriesStr.Substring(0, chartCategoriesStr.Length - 1)
'--------------------------------------------------------------
' Try using different chart types just for fun
'-------------------------------------------------------------
'chartType = ChartChartTypeEnum.chChartTypeArea
'chartType = ChartChartTypeEnum.chChartTypeArea3D
'chartType = ChartChartTypeEnum.chChartTypeBarClustered
'chartType = ChartChartTypeEnum.chChartTypeBar3D
'chartType = ChartChartTypeEnum.chChartTypeColumnClustered
'chartType = ChartChartTypeEnum.chChartTypeColumn3D
'chartType = ChartChartTypeEnum.chChartTypeDoughnut
'chartType = ChartChartTypeEnum.chChartTypeLineStacked
'chartType = ChartChartTypeEnum.chChartTypeLine3D
chartType = OWC11.ChartChartTypeEnum.chChartTypeLineMarkers
'chartType = ChartChartTypeEnum.chChartTypePie
'chartType = ChartChartTypeEnum.chChartTypePie3D
'chartType = ChartChartTypeEnum.chChartTypeRadarSmoothLine
'chartType = ChartChartTypeEnum.chChartTypeSmoothLine
'------------------------------------------------------------------------
' Give pie and doughnut charts a legend on the bottom. For the rest of
' them let the control figure it out on its own.
'------------------------------------------------------------------------
'chartType = OWC11.ChartChartTypeEnum.chChartTypeColumn3D
'If chartType = OWC11.ChartChartTypeEnum.chChartTypePie Or _
' chartType = OWC11.ChartChartTypeEnum.chChartTypePie3D Or _
' chartType = OWC11.ChartChartTypeEnum.chChartTypeDoughnut Then
' oChartSpace.HasChartSpaceLegend = True
' oChartSpace.ChartSpaceLegend.Position = OWC11.ChartLegendPositionEnum.chLegendPositionBottom
'End If
oChartSpace.Border.Color = "blue"
oChartSpace.Charts.Add(0)
oChartSpace.Charts(0).HasTitle = True
oChartSpace.Charts(0).Type = chartType
oChartSpace.Charts(0).Title.Caption = "Cycletime vs Datapoints"
oChartSpace.Charts(0).Title.Font.Bold = True
oChartSpace.Charts(0).SeriesCollection.Add(0)
oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection.Add()
'------------------------------------------------------------------------
'If you Then 're charting a pie or a variation thereof percentages make a lot
' more sense than values...
'------------------------------------------------------------------------
'If chartType = OWC11.ChartChartTypeEnum.chChartTypePie Or _
' chartType = OWC11.ChartChartTypeEnum.chChartTypePie3D Or _
' chartType = OWC11.ChartChartTypeEnum.chChartTypeDoughnut Then
' oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).HasPercentage = True
' oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).HasValue = False
'Else
' '------------------------------------------------------------------------
' ' Not so for other chart types where values have more meaning than
' ' percentages.
' '------------------------------------------------------------------------
' oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).HasPercentage = False
oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).HasValue = True
'End If
'------------------------------------------------------------------------
' Plug your own visual bells and whistles here
' ------------------------------------------------------------------------
oChartSpace.Charts(0).SeriesCollection(0).Caption = "Cycletime vs Datapoints"
oChartSpace.Charts(0).SeriesCollection(0).TipText = "Cycletime vs Datapoints"
oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).Font.Name = "verdana"
oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).Font.Size = 10
oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).Font.Bold = True
oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).Font.Color = "white"
oChartSpace.Charts(0).SeriesCollection(0).DataLabelsCollection(0).Position = OWC11.ChartDataLabelPositionEnum.chLabelPositionCenter
oChartSpace.Charts(0).SeriesCollection(0).Type = OWC11.ChartChartTypeEnum.chChartTypeLineStacked
oChartSpace.Charts(0).SeriesCollection(0).Marker.Style = OWC11.ChartMarkerStyleEnum.chMarkerStyleCircle
oChartSpace.Charts(0).SeriesCollection(0).Line.DashStyle = OWC11.ChartLineDashStyleEnum.chLineSquareDot
oChartSpace.Charts(0).SeriesCollection(0).SetData(OWC11.ChartDimensionsEnum.chDimCategories, Convert.ToInt32(OWC11.ChartSpecialDataSourcesEnum.chDataLiteral), chartCategoriesStr)
oChartSpace.Charts(0).SeriesCollection(0).SetData(OWC11.ChartDimensionsEnum.chDimValues, Convert.ToInt32(OWC11.ChartSpecialDataSourcesEnum.chDataLiteral), chartValuesStr)
'------------------------------------------------------------------------
' Pick your favorite image forma
' ------------------------------------------------------------------------
Dim height, width As Integer
height = 500
width = 700
Dim byteArr As Byte() = DirectCast(oChartSpace.GetPicture("png", width, height), Byte())
' ------------------------------------------------------------------------
' Store the chart image in Session to be picked up by an HttpHandler later
' ------------------------------------------------------------------------
Dim ctx As HttpContext = HttpContext.Current
Dim chartID As String = Guid.NewGuid().ToString()
ctx.Session(chartID) = byteArr
imgGraph.ImageUrl = String.Concat("chart.ashx?", chartID)
End Sub
thank you