Hi pallavi,
Please chage your codes to the following codes and note the red color codes.
Imports Aspose.Chart
Imports
System.Drawing.Imaging
Imports
System.IO
Imports
System.Data
Imports
System.Drawing
Imports
System.Net.Mail.SmtpClient
Partial
Class Microsite_test
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim ChartObject As New Chart
Dim GEARSObject As New DataAccess
Dim ResultsDataset As New DataSet
Dim DealerDataTable As New DataTable
Dim CountryDataTable As New DataTable
Dim EuropeanDataTable As New DataTable
Dim RetailedC As New Series
'Apply license file
Dim License As New License
License.SetLicense(
"Aspose.Chart.lic")
ChartObject = ChartSize(ChartObject, 600, 1000)
'Define the style of the chart axis
ChartObject.ChartArea.AxisX.AxisLabels.IsDataPointNameVisible =
True
ChartObject.ChartArea.AxisY.IsAutoCalc =
False
ChartObject.ChartArea.AxisY.IsMinorGridVisible =
True
ChartObject.ChartArea.AxisY.IsMajorGridVisible =
False
ChartObject.ChartArea.AxisY.Interval = 10
ChartObject.ChartArea.AxisY.Minimum = 0
ChartObject.ChartArea.AxisY.Maximum = 100
ChartObject.ChartArea.AxisY2.DefaultLabel.Format =
"P0"
ChartObject.ChartArea.AxisY2.Interval = 10
ChartObject.ChartArea.AxisY2.Minimum = 0
ChartObject.ChartArea.AxisY2.Maximum = 100
ChartObject.ChartArea.AxisY2.IsMajorGridVisible =
False
ChartObject.ChartArea.LegendBox.IsVisible =
True
ChartObject.ChartArea.LegendBox.LegendPositionType = LegendPositionType.Bottom
ChartObject.ChartArea.AxisX.DefaultLabel.FontAngle = -90
ChartObject.ChartArea.AxisX.Title.Text =
"Recall Number"
ChartObject.ChartArea.AxisY.Title.Text =
"Qty,Units(Wholesale/Retail & Claims)"
'THIS IS A FUNCTION WHICH RETURNS DATASET VALES LIKE 4,3,7,0,1
ResultsDataset = ReportData_Chart()
RetailedC = BarSeries(RetailedC,
"Retailed Claims")
EuropeanDataTable = ResultsDataset.Tables(3)
RetailedC.DataPoints.DataBindXY(EuropeanDataTable.Rows,
"CampaignCode", EuropeanDataTable.Rows, "Total")
RetailedC = DisplaySeriesBarCounts(RetailedC)
RetailedC.IsPrimaryAxisY =
True
ChartObject.SeriesCollection.Add(RetailedC)
'Line chart
'THIS IS A FUNCTION WHICH RETURNS DATASET VALUES LIKE 100,18,32,0
ResultsDataset = ReportData_LineChart_Completion()
Dim MktPercentage As Integer
Dim CompletionSeries As New Series
CompletionSeries.ChartType = ChartType.Line
CompletionSeries.DefaultDataPoint.BorderWidth = 1
CompletionSeries.DefaultDataPoint.Color = Color.Red
CompletionSeries.DefaultDataPoint.BorderColor = Color.Red
CompletionSeries.IsPrimaryAxisY =
False
'Calculates percentage total
Dim MktPercentageTotalValue As Double
If ResultsDataset.Tables(0).Rows.Count > 0 Then
For Counter As Integer = 0 To RetailedC.DataPoints.Count - 1
MktPercentageTotalValue += Double.Parse(ResultsDataset.Tables(0).Rows(Counter).Item("Percentage"))
Next
End If
If ResultsDataset.Tables(0).Rows.Count > 0 Then
CompletionSeries.Name = "percentage Completion - "
For Counter As Integer = 0 To RetailedC.DataPoints.Count - 1
MktPercentage = ResultsDataset.Tables(0).Rows(Counter).Item("Percentage")
CompletionSeries.DataPoints.Add(New DataPoint(RetailedC.DataPoints(Counter).XValue, MktPercentage / MktPercentageTotalValue))
Next
ChartObject.SeriesCollection.Add(CompletionSeries)
End If
SaveImage(ChartObject)
End Sub
Private Function BarSeries(ByVal SeriesOBJ As Series, ByVal Description As String) As Series
SeriesOBJ.ChartType = ChartType.Bar
SeriesOBJ.Name = Description
SeriesOBJ.DefaultDataPoint.IsLabelVisible =
True
SeriesOBJ.CustomAttributes.BarWidth = 11
SeriesOBJ.DefaultDataPoint.LabelPosition = LabelPositionType.Outside
SeriesOBJ.DefaultDataPoint.LabelAngle = 0
Return SeriesOBJ
End Function
Private Function DisplaySeriesBarCounts(ByVal SeriesOBJ As Series) As Series
For i As Integer = 0 To SeriesOBJ.DataPoints.Count - 1
SeriesOBJ.DataPoints(i).Font =
New Drawing.Font("Arial Narrow", 7, FontStyle.Bold)
Next
Return SeriesOBJ
End Function
Private Sub SaveImage(ByVal ChartOBJ As Aspose.Chart.Chart)
'Save the chart image into a memory stream
Dim ms As New MemoryStream
ChartOBJ.Save(ms, ImageFormat.Png)
'Save the chart image from the memory stream to the response
Response.Clear()
Response.ContentType =
"image/png"
Response.OutputStream.Write(ms.ToArray, 0,
CInt(ms.Length))
End Sub
Private Function ChartSize(ByVal ChartOBJ As Aspose.Chart.Chart, ByVal Height As Integer, ByVal Width As Integer) As Aspose.Chart.Chart
'Define the size of the chart
ChartOBJ.Height = Height
ChartOBJ.Width = Width
Return ChartOBJ
End Function
End Class
Roger Mo
Developer
Aspose Nanjing Team
Contact Us