PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

PDFSharp charting - line caps and line width
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3534
Page 1 of 1

Author:  Steffen_cl [ Wed Jan 25, 2017 7:31 am ]
Post subject:  PDFSharp charting - line caps and line width

Hello,

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?
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:
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))
        Next


        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)
        chartFrame.Add(chart)

        chartFrame.DrawChart(gfx)

#End Region


#Region "Speichern und Öffnen im PDF Viewer"

        Dim filename As String = "Test Chart.pdf"

        ' Save the document...
        document.Save(filename)

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


#End Region


    End Sub
End Class

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/