BVB Source Codes

PDF file browser Show PieExplodedPlotAreaRenderer.cs Source code

Return Download PDF file browser: download PieExplodedPlotAreaRenderer.cs Source code - Download PDF file browser Source code - Type:.cs
  1. //
  2. // PDFsharp.Charting - A charting library based on PDFsharp
  3. //
  4. // Authors:
  5. //   Niklas Schneider (mailto:Niklas.Schneider@pdfsharp.com)
  6. //
  7. // Copyright (c) 2005 empira Software GmbH, Cologne (Germany)
  8. //
  9. // http://www.pdfsharp.com
  10. //
  11. // Permission is hereby granted, free of charge, to any person obtaining
  12. // a copy of this software and associated documentation files (the
  13. // "Software"), to deal in the Software without restriction, including
  14. // without limitation the rights to use, copy, modify, merge, publish,
  15. // distribute, sublicense, and/or sell copies of the Software, and to
  16. // permit persons to whom the Software is furnished to do so, subject to
  17. // the following conditions:
  18. //
  19. // The above copyright notice and this permission notice shall be
  20. // included in all copies or substantial portions of the Software.
  21. //
  22. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29.  
  30. using System;
  31. using PdfSharp.Drawing;
  32.  
  33. namespace PdfSharp.Charting.Renderers
  34. {
  35.   /// <summary>
  36.   /// Represents a exploded pie plot area renderer.
  37.   /// </summary>
  38.   internal class PieExplodedPlotAreaRenderer : PiePlotAreaRenderer
  39.         {
  40.     /// <summary>
  41.     /// Initializes a new instance of the PieExplodedPlotAreaRenderer class
  42.     /// with the specified renderer parameters.
  43.     /// </summary>
  44.     internal PieExplodedPlotAreaRenderer(RendererParameters parms) : base(parms)
  45.                 {
  46.                 }
  47.  
  48.     /// <summary>
  49.     /// Calculate angles for each sector.
  50.     /// </summary>
  51.     protected override void CalcSectors()
  52.     {
  53.       ChartRendererInfo cri = (ChartRendererInfo)this.rendererParms.RendererInfo;
  54.       if (cri.seriesRendererInfos.Length == 0)
  55.         return;
  56.  
  57.       SeriesRendererInfo sri = cri.seriesRendererInfos[0];
  58.  
  59.       double sumValues = sri.SumOfPoints;
  60.       if (sumValues == 0)
  61.         return;
  62.  
  63.       double textMeasure = 0;
  64.       if (sri.dataLabelRendererInfo != null && sri.dataLabelRendererInfo.Position == DataLabelPosition.OutsideEnd)
  65.       {
  66.         foreach (DataLabelEntryRendererInfo dleri in sri.dataLabelRendererInfo.Entries)
  67.         {
  68.           textMeasure = Math.Max(textMeasure, dleri.Width);
  69.           textMeasure = Math.Max(textMeasure, dleri.Height);
  70.         }
  71.       }
  72.  
  73.       XRect pieRect = cri.plotAreaRendererInfo.Rect;
  74.       if (textMeasure != 0)
  75.       {
  76.         pieRect.X += textMeasure;
  77.         pieRect.Y += textMeasure;
  78.         pieRect.Width -= 2 * textMeasure;
  79.         pieRect.Height -= 2 * textMeasure;
  80.       }
  81.  
  82.       XPoint origin = new XPoint(pieRect.X + pieRect.Width / 2, pieRect.Y + pieRect.Height / 2);
  83.       XRect innerRect = XRect.Empty;
  84.       XPoint p1 = XPoint.Empty;
  85.  
  86.       double midAngle = 0, sectorStartAngle = 0, sectorSweepAngle = 0,
  87.              deltaAngle = 2, startAngle = 270, sweepAngle = 0,
  88.              rInnerCircle = pieRect.Width / 15,
  89.              rOuterCircle = pieRect.Width / 2;
  90.  
  91.       foreach (SectorRendererInfo sector in sri.pointRendererInfos)
  92.       {
  93.         if (!double.IsNaN(sector.point.value) && sector.point.value != 0)
  94.         {
  95.           sweepAngle = 360 / (sumValues / Math.Abs(sector.point.value));
  96.  
  97.           midAngle = startAngle + sweepAngle / 2;
  98.           sectorStartAngle = Math.Max(0, startAngle + deltaAngle);
  99.           sectorSweepAngle = Math.Max(sweepAngle, sweepAngle - deltaAngle);
  100.  
  101.           p1.X = origin.X + rInnerCircle * Math.Cos(midAngle / 180 * Math.PI);
  102.           p1.Y = origin.Y + rInnerCircle * Math.Sin(midAngle / 180 * Math.PI);
  103.           innerRect.X = p1.X - rOuterCircle + rInnerCircle;
  104.           innerRect.Y = p1.Y - rOuterCircle + rInnerCircle;
  105.           innerRect.Width = (rOuterCircle - rInnerCircle) * 2;
  106.           innerRect.Height = innerRect.Width;
  107.  
  108.           sector.Rect = innerRect;
  109.           sector.StartAngle = sectorStartAngle;
  110.           sector.SweepAngle = sectorSweepAngle;
  111.  
  112.           startAngle += sweepAngle;
  113.         }
  114.         else
  115.         {
  116.           sector.StartAngle = double.NaN;
  117.           sector.SweepAngle = double.NaN;
  118.         }
  119.       }
  120.     }
  121.   }
  122. }
  123.  
downloadPieExplodedPlotAreaRenderer.cs Source code - Download PDF file browser Source code
Related Source Codes/Software:
Campus id - This system includes a campus dormitory management... 2015-04-10
ShopXP online system source code - ShopXP ShoppingNet online system source code infor... 2015-04-10
TOM cat demo in learning to speak - 实现汤米猫学说话的演示,即实现变声功能鲜豔,,,,,,,开发者说:自己经常来看code4app,看看... 2015-04-10
Another OpenFolder - Implements can commence in the middle of the scree... 2015-04-10
Bus query system - A simple bus query system. Can be divided into rou... 2015-04-10
Customer service management system - To a store and development of customer service man... 2015-04-10
OA office automation system - OA office automation system is tomorrow technology... 2015-04-10
Chapters novel divider (ChapCuttor) - Chapter divider (ChapCuttor) by & have spent Black... 2015-04-10
Graduation design file (graphics algorithm design) - Reference image effect algorithm design the softwa... 2015-04-10
CheatEngine5.6 source code - Game cheat the 5.6 version of the source code, it ... 2015-04-10
Online ZhaXunWang science formula query V1.0 - Including junior middle school and high school sci... 2016-10-20
Observe science formula query v1.0 - Observe network science formulas 2016-10-20
Lele v1.1 QQ login system - "Le Le QQ Group landing system Ver1.1" * Fix QQ ... 2016-10-20
The new network domain name host distribution system V1.0 - Use Notepad to open \Global.asa idc1688 into your ... 2016-10-20
QQ group v2.1 release system - ha ha - "Copyright" This system is based on the Wu Meng de... 2016-10-20
Interesting content ASPCMS v1.0 - Update log: 2016-10-20
Residential feng shui fortune-telling v1.0 - The project according to the orientation of the ar... 2016-10-20
The self-help chain home beautiful - The self-help chain home beautiful 2016-10-20
EXW FLASH web site management system v2.0 - EXW FLASH introduction: EXW website management sys... 2016-10-20
WAP2.0 web site management system V1.0 - System installation steps 1, install the QuickWAP ... 2016-10-20

 Back to top