/// <summary> /// Creates all the <see cref="PieItem"/>s for a single Pie Chart. /// </summary> /// <param name="values"> /// double array containing all <see cref="PieItem.Value"/>s for a single PieChart. /// </param> /// <param name="labels"> /// string array containing all <see cref="CurveItem.Label"/>s for a single PieChart. /// </param> /// <returns> /// an array containing references to all <see cref="PieItem"/>s comprising the Pie Chart. /// </returns> public PieItem[] AddPieSlices(double[] values, string[] labels) { PieItem[] slices = new PieItem[values.Length]; for (int x = 0; x < values.Length; x++) { slices[x] = new PieItem(values[x], labels[x]); this.CurveList.Add(slices[x]); } return slices; }
/// <summary> /// Build the string that will be displayed as the slice label as determined by /// <see cref="LabelType"/>. /// </summary> /// <param name="curve"> /// reference to the <see cref="PieItem"/> /// </param> private static void BuildLabelString(PieItem curve) { // set up label string formatting NumberFormatInfo labelFormat = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone(); labelFormat.NumberDecimalDigits = curve._valueDecimalDigits; labelFormat.PercentPositivePattern = 1; // no space between number and % sign labelFormat.PercentDecimalDigits = curve._percentDecimalDigits; switch (curve._labelType) { case PieLabelType.Value: curve._labelStr = curve._pieValue.ToString("F", labelFormat); break; case PieLabelType.Percent: curve._labelStr = (curve._sweepAngle / 360).ToString("P", labelFormat); break; case PieLabelType.Name_Value: curve._labelStr = curve._label._text + ": " + curve._pieValue.ToString("F", labelFormat); break; case PieLabelType.Name_Percent: curve._labelStr = curve._label._text + ": " + (curve._sweepAngle / 360).ToString("P", labelFormat); break; case PieLabelType.Name_Value_Percent: curve._labelStr = curve._label._text + ": " + curve._pieValue.ToString("F", labelFormat) + " (" + (curve._sweepAngle / 360).ToString("P", labelFormat) + ")"; break; case PieLabelType.Name: curve._labelStr = curve._label._text; break; case PieLabelType.None: default: break; } }
/// <summary> /// Add a <see cref="PieItem"/> to the display, providing a gradient fill for the pie color. /// </summary> /// <param name="value"> /// The value associated with this <see cref="PieItem"/> instance. /// </param> /// <param name="color1"> /// The starting display color for the gradient <see cref="Fill"/> for this /// <see cref="PieItem"/> instance. /// </param> /// <param name="color2"> /// The ending display color for the gradient <see cref="Fill"/> for this /// <see cref="PieItem"/> instance. /// </param> /// <param name="fillAngle"> /// The angle for the gradient <see cref="Fill"/>. /// </param> /// <param name="displacement"> /// The amount this <see cref="PieItem"/> instance will be displaced from the center point. /// </param> /// <param name="label"> /// Text label for this <see cref="PieItem"/> instance. /// </param> /// <returns> /// The <see cref="PieItem"/>. /// </returns> public PieItem AddPieSlice(double value, Color color1, Color color2, float fillAngle, double displacement, string label) { PieItem slice = new PieItem(value, color1, color2, fillAngle, displacement, label); this.CurveList.Add(slice); return slice; }
/// <summary> /// Initializes a new instance of the <see cref="PieItem"/> class. /// The Copy Constructor /// </summary> /// <param name="rhs"> /// The <see cref="PieItem"/> object from which to copy /// </param> public PieItem(PieItem rhs) : base(rhs) { this._pieValue = rhs._pieValue; this._fill = rhs._fill.Clone(); this.Border = rhs._border.Clone(); this._displacement = rhs._displacement; this._labelDetail = rhs._labelDetail.Clone(); this._labelType = rhs._labelType; this._valueDecimalDigits = rhs._valueDecimalDigits; this._percentDecimalDigits = rhs._percentDecimalDigits; }