We help IT Professionals succeed at work.

Office Web Component Charting Asp.net 2.0 - unable to display generated charts

jaxrpc
jaxrpc asked
on
1,179 Views
Last Modified: 2010-05-18
hi, i need to have some web chart for my demo site, so i have searched and found out about OWC. By generating charts using OWC at the server-side and save it to disk and the client picking it up. What i need to do is a stacked - column chart with a line chart in a single chart...with the stacked column using plotted against the left y axis and the line plotted against the right y axis. I have managed to do it for columnchart (non stacked) and with a line plotted against the right y axis. I need some help with doing it for stacked column perferably some sample codes. And another problem is after generating the gif and strSavePath = Server.MapPath(".") & "\Sample.gif" ...it doesnt work...

Anyway below are my code for the column and line ...it is working but i am trying to make it into a combined chart columnstacked and line. thanks.

  Dim oChart
        Dim oSeries1, oSeries2
        Dim oAxis1, oAxis2
        Dim oConst
        Dim chartspace1 As New ChartSpace
        Dim a(9)
        a(0) = "A"
        a(1) = "B"
        a(2) = "C"
        a(3) = "D"
        a(4) = "E"
        a(5) = "F"
        a(6) = "G"
        a(7) = "H"
        a(8) = "I"
        a(9) = "J"

        Dim b(9)
        b(0) = 5000
        b(1) = 6025
        b(2) = 5575
        b(3) = 5900
        b(4) = 3200
        b(5) = 3120
        b(6) = 2302
        b(7) = 3230
        b(8) = 8000
        b(9) = 2323

        Dim c(3)
        c(0) = 0.1
        c(1) = 0.2
        c(2) = 0.1
        c(3) = 0.15
        'ChartSpace1.Clear()
        oConst = chartspace1.Constants

        'Create a new chart in the ChartSpace.
        oChart = ChartSpace1.Charts.Add

        'Add a series of type Column.
        oSeries1 = chartspace1.Charts(0).SeriesCollection.Add
        oSeries1.Caption = "Sales"
       
        oSeries1.SetData(OWC11.ChartDimensionsEnum.chDimCategories, OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, _
                         a)
        oSeries1.SetData(OWC11.ChartDimensionsEnum.chDimValues, OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, _
                         b)
        oSeries1.Type = ChartChartTypeEnum.chChartTypeColumnClustered



        'Add a second series of type Line.

        oSeries2 = chartspace1.Charts(0).SeriesCollection.Add
        oSeries2.Caption = "Discount"
       
        oSeries2.SetData(OWC11.ChartDimensionsEnum.chDimCategories, OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, _
                         a)
        oSeries2.SetData(OWC11.ChartDimensionsEnum.chDimValues, OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, _
                         c)
        oSeries2.Type = ChartChartTypeEnum.chChartTypeLine


        ' Change the Min/Max, Numberformat and Gridlines for the value-axis of the first series.

        oAxis1 = chartspace1.Charts(0).Axes(ChartAxisPositionEnum.chAxisPositionLeft)
        oAxis1.Scaling.Maximum = 8000
        oAxis1.Scaling.Minimum = 0
        oAxis1.NumberFormat = "$0"
        oAxis1.HasMajorGridlines = False

        ' Ungroup the series so that they can have separate value-axis scaling.
        oSeries2.Ungroup(True)

        ' Add a new value-axis for the second series. Position the new axis on the right side
        'of the chart and modify the gridlines and numberformat.

        oAxis2 = oChart.Axes.Add(oSeries2.Scalings(OWC11.ChartDimensionsEnum.chDimValues))
        oAxis2.Position = ChartAxisPositionEnum.chAxisPositionRight
        oAxis2.HasMajorGridlines = False
        oAxis2.NumberFormat = "0%"

        'Display the legend.
        oChart.HasLegend = True
        oChart.Legend.Position = ChartLegendPositionEnum.chLegendPositionBottom

        'Display the title for the chart.
        oChart.HasTitle = True
        oChart.Title.Caption = "Sales & Discounts"




        strFullPathAndName =  Server.MapPath(".") & "\Sample.gif"        
chartspace1.ExportPicture(strFullPathAndName, "gif", 800, 600)
        Image1.ImageUrl = strFullPathAndName
        Image1.Visible = True
   
Comment
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
hi, sorry for being a newbie..... what is meant by a virtual path?
this is a path accessible from the web.

"~" will map your physical path "c:\..." to a web path "http://localhost/..."
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.