Office Web Component Charting 2.0 - unable to display generated charts

Posted on 2007-10-09
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" doesnt work...

Anyway below are my code for the column and line 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
        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, _
        oSeries1.SetData(OWC11.ChartDimensionsEnum.chDimValues, OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, _
        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, _
        oSeries2.SetData(OWC11.ChartDimensionsEnum.chDimValues, OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, _
        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.

        ' 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
Question by:jaxrpc
    LVL 4

    Accepted Solution

    Your ImageUrl is wrong.

    MapPath generates a fully qualified path name e.g. ("c:\myweb\sample.gif")
    Image1.ImageUrl requires a virtual path.
    Try simply this: Image1.ImageUrl = "sample.gif"

    If you need another path use something like this:

    strFullPathAndName =  Server.MapPath("~/images") & "\Sample.gif"        
    Image1.ImageUrl = "~/images/Sample.gif"

    Author Comment

    hi, sorry for being a newbie..... what is meant by a virtual path?
    LVL 4

    Expert Comment

    this is a path accessible from the web.

    "~" will map your physical path "c:\..." to a web path "http://localhost/..."

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now