Giter VIP home page Giter VIP logo

pdfsharp's People

Contributors

jasonpierce avatar

Watchers

 avatar

pdfsharp's Issues

Set line chart x values on major gridlines

I have tried now to set the x-values for a line statistic to the major gridlines. But this does not work. This is how I try it in a ASP.NET MVC application:

        var doc = new PdfDocument();
        var page = doc.AddPage();
        page.Orientation = PdfSharp.PageOrientation.Landscape;
        page.Size = PdfSharp.PageSize.A4;

        var gfx = XGraphics.FromPdfPage(page);

        var chart = new Chart();
        chart.Type = ChartType.Line;

        chart.YAxis.MajorTickMark = TickMarkType.Outside;
        chart.YAxis.LineFormat.Color = XColors.Black;
        chart.YAxis.LineFormat.Width = 0.5;
        chart.YAxis.LineFormat.Visible = true;
        chart.YAxis.TickLabels.Format = "0";

        chart.XAxis.MajorTickMark = TickMarkType.None;
        chart.XAxis.MinorTickMark = TickMarkType.Outside;
        chart.XAxis.LineFormat.Color = XColors.Black;
        chart.XAxis.LineFormat.Width = 0.5;
        chart.XAxis.LineFormat.Visible = true;
        chart.XAxis.MajorTick = 0.0;
        chart.XAxis.MinorTick = 0.0;
        chart.XAxis.HasMajorGridlines = false;
        chart.XAxis.HasMinorGridlines = false;
        


        var series = chart.SeriesCollection.AddSeries();
        var yValues = new int[]{ 0, 5, 3, 6, 7 };
        series.HasDataLabel = true;
        chart.PlotArea.LineFormat.Width = 1;

        var xseries = chart.XValues.AddXSeries();
                    
        for(var i = 0; i < yValues.Length; i++)
        {
            series.Add(yValues[i]);
            xseries.Add("abc");
        }

        series.LineFormat.Color = XColors.Orange;
        series.MarkerStyle = MarkerStyle.None;
        series.LineFormat.Width = 5;

        chart.PlotArea.FillFormat.Color = XColors.White;

        var chartFrame = new ChartFrame();
        chartFrame.Location = new XPoint(20, 80);
        chartFrame.Size = new XSize(400, 400);
        chartFrame.Add(chart);

        chartFrame.DrawChart(gfx);

        var ms = new MemoryStream();
        doc.Save(ms);
        var fileBytes = ms.ToArray();
        ms.Close();

        return File(fileBytes, "application/pdf", "filename.pdf");

This is what I get:
image

But I expected the red line and the red lettering (drawn by hand):

image

How can I implement this? Is that even possible? Many thanks.

Add NuGet spec

The project needs a NuGet spec to support installation via NuGet repositories

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.