[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2007-10-09
3
Medium Priority
?
1,158 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
   
0
Comment
Question by:jaxrpc
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
iuconStefan earned 1500 total points
ID: 20039994
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"
0
 

Author Comment

by:jaxrpc
ID: 20041244
hi, sorry for being a newbie..... what is meant by a virtual path?
0
 
LVL 4

Expert Comment

by:iuconStefan
ID: 20041984
this is a path accessible from the web.

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

829 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