From 1f7e90aaf41b41888976c2744a63ea3c265612b6 Mon Sep 17 00:00:00 2001 From: Mahdi Hosseinzadeh Date: Sat, 29 May 2021 14:19:00 +0430 Subject: [PATCH] Update implementation guides --- ...nting-the-gap.svg => implementing-gap.svg} | 0 .../implementing-outside-label.svg | 361 ++++++++++++------ 2 files changed, 246 insertions(+), 115 deletions(-) rename piechart/implementation-guides/{implementing-the-gap.svg => implementing-gap.svg} (100%) diff --git a/piechart/implementation-guides/implementing-the-gap.svg b/piechart/implementation-guides/implementing-gap.svg similarity index 100% rename from piechart/implementation-guides/implementing-the-gap.svg rename to piechart/implementation-guides/implementing-gap.svg diff --git a/piechart/implementation-guides/implementing-outside-label.svg b/piechart/implementation-guides/implementing-outside-label.svg index 6f38b6b4..d4605e7f 100644 --- a/piechart/implementation-guides/implementing-outside-label.svg +++ b/piechart/implementation-guides/implementing-outside-label.svg @@ -9,12 +9,12 @@ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="341.41" - height="624.1" - viewBox="0 0 341.41 624.1" + height="700" + viewBox="0 0 341.41 700" version="1.1" id="svg8" inkscape:version="1.0.2-2 (e86c870879, 2021-01-15)" - sodipodi:docname="implementain-outside-label.svg.2021_05_28_19_44_13.0.svg"> + sodipodi:docname="implementing-outside-label.svg"> + pieRadius @@ -570,7 +576,7 @@ sodipodi:role="line" id="tspan1496" x="-11" - y="49"> + y="49" /> Place the text (baseline) on the circumference of the disk:x = rcos(θ) = pieRadius * cos(middleAngle)y = rsin(θ) = pieRadius * sin(middleAngle)This is for when the origin is at (0,0) but we were in(centerX,centerY) so adjust the x and y:x = x + centerXy= y + centerY + transform="translate(59.356,155.31)"> Shift the x and y so that it is the center of the textthat is placed on the desired point (circumference)and not the baseline of the text.This also makes future calculations easier.y = y + (h/2) - descent + transform="translate(59.356,301.3)"> Now, calculate the shift (a,b) to move the rectangle alongthe middleAngle just enough so that it does not overlapthe disk anymore.The formula for this shiftring differes for differentmiddleAngles:θ∈[0,arcsin(h/2))θ∈[arcsin(h/2),arccos(w/2)]θ∈(arccos(w/2),π/2](a,b) = ... // calculate the shift @@ -870,7 +876,7 @@ y="0" xlink:href="#circle1427" id="use2505" - transform="translate(-0.04045,437.65)" + transform="translate(0.2806,509.65)" width="100%" height="100%" /> + transform="translate(64.428,365.31)"> + style="font-size:2.66667px;line-height:1.25;font-family:Roboto;-inkscape-font-specification:Roboto;text-decoration:none;text-decoration-line:none;text-decoration-color:#000000;white-space:pre;shape-inside:url(#rect2527);fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-opacity:1;stop-color:#000000;" /> First, convert the middleAngle to its first-quadrant (0≤θ≤90)equivelant (if it is in a quadrant other than the first quadrant)in the first quadrant.Note that the quadrent shown here is the one generallyin Android it is the bottom right quadrant that is thefirst quadrant. However, it does not make any + y="476" /> Convert the shift (a,b) to the middleAngleoriginal quadrant if necessary:for second quadrant: a = -afor third quadrant: a = -a, b = -bfor fourth quadrant: b = -b + y="508" /> Finally, shift the x and y:x = x + ay = y + b + To place the text with a margin, imagine a bigger disk that you want to put the rectangleon it. So instead of pieRadius, use pieRadius + margin:x = rcos(θ) = (pieRadius + margin) * cos(middleAngle)y = rsin(θ) = (pieRadius + margin) * sin(middleAngle)Again, don't forget to account for centerX and centerY. + + + + + + + + + pieRadius + margin + + + + + + alaki