Advertisement
Advertisement
| 02.28.2008 at 06:47AM PST, ID: 23200380 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: |
Dim objChart As Excel.Chart
Dim ChrtsYearToDate As Excel.ChartObjects
Dim ChrtYearToDate As Excel.ChartObject
Dim chrtSheet As Excel.Worksheet = wb.Worksheets.Add
Dim dataSheet As Excel.Worksheet = wb.Worksheets.Item("Year To Date NPS")
'Dim objSeries As Excel.SeriesCollection
chrtSheet.Name = "Year To Date Chart"
'dataSheet.Name = "Year To Date NPS"
ChrtsYearToDate = chrtSheet.ChartObjects
'set chart location
ChrtYearToDate = ChrtsYearToDate.Add(0, 0, 800, 400)
objChart = ChrtYearToDate.Chart
'use the follwoing line if u want
'to draw chart on the default location
objChart.Location(Excel.XlChartLocation.xlLocationAsObject, chrtSheet.Name)
With objChart
'set data range for chart
Dim chartRange As Excel.Range
chartRange = dataSheet.Range("A1", "D3")
.SetSourceData(chartRange)
'set how you want to draw chart i.e column wise or row wise
.PlotBy = Excel.XlRowCol.xlRows
'set data lables for bars
.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowNone)
'set legend to be displayed or not and location
.HasLegend = True
.Legend.Position = Excel.XlLegendPosition.xlLegendPositionRight
'select chart type
.ChartType = Excel.XlChartType.xlColumnClustered
'chart title
.HasTitle = True
.ChartTitle.Text = "Year To Date NPS"
'set titles for Axis values and categories
Dim xlAxisCategory As Excel.Axes
Dim xlAxisValue As Excel.Axes
xlAxisCategory = CType(objChart.Axes(, Excel.XlAxisGroup.xlPrimary), Excel.Axes)
xlAxisCategory.Item(Excel.XlAxisType.xlCategory).HasTitle = True
xlAxisCategory.Item(Excel.XlAxisType.xlCategory).AxisTitle.Characters.Text = "Week Number"
xlAxisValue = CType(objChart.Axes(, Excel.XlAxisGroup.xlPrimary), Excel.Axes)
xlAxisValue.Item(Excel.XlAxisType.xlValue).HasTitle = True
xlAxisValue.Item(Excel.XlAxisType.xlValue).AxisTitle.Characters.Text = "Percent"
xlAxisValue.Item(Excel.XlAxisType.xlValue).MaximumScale = 100
End With
|