Whiteangel Posted February 25, 2014 at 06:37 PM Report #546629 Posted February 25, 2014 at 06:37 PM (edited) Boas pessoal, Criei um chart "grafico" e agora queria imprimir através de um PrintDocument mas não como o imprimir. Podem ajudar?? Dim ChartArea1 As ChartArea = New ChartArea() Dim Legend1 As Legend = New Legend() Dim Series1 As Series = New Series() Dim Chart1 = New DataVisualization.Charting.Chart() Me.Controls.Add(Chart1) ChartArea1.Name = "ChartArea1" Chart1.ChartAreas.Add(ChartArea1) Legend1.Name = "Legend1" Chart1.Legends.Add(Legend1) Chart1.Location = New System.Drawing.Point(250, 100) Chart1.Name = "Chart1" Series1.ChartArea = "ChartArea1" Series1.Legend = "Legend1" Series1.Name = "Unidades" Chart1.Series.Add(Series1) Chart1.Size = New System.Drawing.Size(750, 550) Chart1.TabIndex = 0 Chart1.Text = "Chart1" With Chart1 'define o tipo de gráfico .Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Column 'define o texto da legenda .Series(0).LegendText = "Unidades" .Legends(0).Font = New Font("Times New Roman", 12, FontStyle.Bold) 'Adicionar título .Titles.Add("Produtos em Armazém") .Titles(0).Font = New Font("JasmineUPC", 32, FontStyle.Bold) .Titles(0).ForeColor = Color.Blue 'define o titulo do eixo y , sua fonte e a cor .ChartAreas(0).AxisY.Title = "Quantidade" .ChartAreas(0).AxisY.TitleFont = New Font("Comic Sans MS", 16, FontStyle.Bold) .ChartAreas(0).AxisY.TitleForeColor = Color.Blue 'define o titulo do eixo x , sua fonte e a cor .ChartAreas(0).AxisX.Title = "Produto" .ChartAreas(0).AxisX.TitleFont = New Font("Comic Sans MS", 16, FontStyle.Bold) .ChartAreas(0).AxisX.TitleForeColor = Color.Blue 'define a paleta de cores usada .Palette = ChartColorPalette.EarthTones 'define cor de fundo .BackColor = Color.Orange .BackSecondaryColor = Color.LightSalmon .BackGradientStyle = GradientStyle.TopBottom 'vincula os dados ao gráfico .Series("Unidades").XValueMember = "Produto" .Series("Unidades").YValueMembers = "Quantidade" 'exibe os valores nos eixos .Series(0).IsValueShownAsLabel = True 'desabilita a exibição 3D .ChartAreas(0).Area3DStyle.Enable3D = True End With Dim Chart1 = New DataVisualization.Charting.Chart() ' Create and initialize print font Dim printFont As New System.Drawing.Font("Arial", 10) ' Create Rectangle structure, used to set the position of the chart Dim myRec As New System.Drawing.Rectangle(10, 30, 150, 150) ' Draw a line of text, followed by the chart, and then another line of text e.Graphics.DrawString("Line before chart", printFont, Brushes.Black, 10, 10) Chart1.Printing.PrintPaint(e.Graphics, myRec) e.Graphics.DrawString("Line after chart", printFont, Brushes.Black, 10, 200) Edited February 25, 2014 at 06:47 PM by Whiteangel
ribeiro55 Posted February 27, 2014 at 10:24 AM Report #546831 Posted February 27, 2014 at 10:24 AM https://www.portugal-a-programar.pt/topic/65124-chart/ Sérgio Ribeiro "Great coders aren't born. They're compiled and released""Expert coders do not need a keyboard. They just throw magnets at the RAM chips"
Recommended Posts