PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Jan 22, 2021 1:11 pm

All times are UTC

Forum rules

Please read this before posting on this forum: Forum Rules

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Wed Jan 25, 2017 7:31 am 

Joined: Thu Dec 08, 2016 7:05 am
Posts: 1

I have some problems with the charting functions. I prepared a little example with VB.Net which I have attached.

I would ask you to take a closer look at it and send me short feedback, please.

1. I tried to edit the line width of a series but it doesn't work as expect. Maybe I did it wrong in my code?
Series.LineFormat.Width = 10

2. Furthermore I would like to define triangle line caps at the end of the x and y axis.. Is it possible? I didn't find any option.

Edit: Project can be downloaded about this link (because the project is too big for upload here):
https://www.dropbox.com/s/b90iohpw9r482 ... e.rar?dl=0

Here ist also the code:
Imports PdfSharp
Imports PdfSharp.Charting
Imports PdfSharp.Drawing
Imports PdfSharp.Pdf

Public Class PrintOut

    Public Shared Sub Main()

        ' Create a new PDF document
        Dim document As PdfDocument = New PdfDocument
        document.Info.Title = "Print out report"

        ' Create an empty page
        Dim page As PdfPage

        page = document.AddPage
        page.Size = PageSize.A4

        Dim Rand_Links = page.Width.Point + 45
        Dim Rand_Rechts = page.Width.Point - 45
        ' Get an XGraphics object for drawing
        Dim gfx As XGraphics = XGraphics.FromPdfPage(page)

#Region "Chart"
        Dim chart As Chart = New Chart
        chart.Font.Name = "Segoe UI"
        chart.Font.Size = 9

        chart.Type = ChartType.Line

        'chart.YAxis.MajorTick = 10
        'chart.YAxis.MaximumScale = 100
        chart.YAxis.MajorTickMark = TickMarkType.Outside
        chart.YAxis.LineFormat.Color = XColors.Black
        chart.YAxis.LineFormat.Width = 0.5
        chart.YAxis.LineFormat.Visible = True

        chart.XAxis.LineFormat.DashStyle = XDashStyle.Custom
        'chart.XAxis.MajorTick = 0.5
        chart.XAxis.TickLabels.Format = "0.0"
        chart.XAxis.MajorTickMark = TickMarkType.Outside
        chart.XAxis.LineFormat.Color = XColors.Black
        chart.XAxis.LineFormat.Width = 0.5
        chart.XAxis.LineFormat.Visible = True

        Dim Series As Series = chart.SeriesCollection.AddSeries
        Dim XValues() As Double = {1, 2, 3, 6, 9}
        Dim YValues() As Double = {2, 5, 3, 6, 7}
        For i = 0 To UBound(XValues)
            Series.Add(XValues(i), YValues(i))

        Series.LineFormat.Color = XColors.Orange
        Series.MarkerStyle = MarkerStyle.None
        Series.LineFormat.Width = 10

        chart.PlotArea.FillFormat.Color = XColors.White

        Dim chartFrame As New ChartFrame
        chartFrame.Location = New XPoint(10, 10)
        chartFrame.Size = New XSize(200, 200)


#End Region

#Region "Speichern und Öffnen im PDF Viewer"

        Dim filename As String = "Test Chart.pdf"

        ' Save the document...

        ' ...and start a viewer.
        Dim p As Process = Process.Start(filename)

#End Region

    End Sub
End Class

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 14 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group