@@ -7638,7 +7638,7 @@ DvtDataCursor.prototype.getBehavior = function() {
7638
7638
DvtDataCursor.prototype.setBehavior = function(behavior) {
7639
7639
this._behavior = behavior;
7640
7640
};
7641
- // Copyright (c) 2013, 2015 , Oracle and/or its affiliates. All rights reserved.
7641
+ // Copyright (c) 2013, 2016 , Oracle and/or its affiliates. All rights reserved.
7642
7642
/**
7643
7643
* Creates a funnel shape.
7644
7644
* @extends {DvtPath}
@@ -7710,19 +7710,37 @@ DvtFunnelSlice.prototype.Init = function(chart, seriesIndex, numDrawnSeries, fun
7710
7710
7711
7711
/** The ratio of rx/ry in the 3D funnel opening
7712
7712
* @private */
7713
- DvtFunnelSlice._FUNNEL_3D_WIDTH_RATIO = .12 ;
7713
+ DvtFunnelSlice._FUNNEL_3D_WIDTH_RATIO = .08 ;
7714
7714
/** Angle for creating the funnel sides
7715
7715
* @private */
7716
- DvtFunnelSlice._FUNNEL_ANGLE_2D = 31 ;
7716
+ DvtFunnelSlice._FUNNEL_ANGLE_2D = 36 ;
7717
7717
/** Ratio between the smallest and largest slices
7718
7718
* @private */
7719
- DvtFunnelSlice._FUNNEL_RATIO = 6 / 22 ;
7719
+ DvtFunnelSlice._FUNNEL_RATIO = 1 / 3 ;
7720
7720
/** Color for funnel slice border. Could be overridden in styleDefaults.
7721
7721
* @private */
7722
7722
DvtFunnelSlice._BORDER_COLOR = '#FFFFFF';
7723
7723
/** Minimum number of characters to use when truncating.
7724
7724
* @private */
7725
7725
DvtFunnelSlice._MIN_CHARS_DATA_LABEL = 3;
7726
+ /** Length of the first line.
7727
+ * @private */
7728
+ DvtFunnelSlice._LINE_FRACTION = 2 / 3;
7729
+ /** Fraction into which the funnel area is divided by the first line.
7730
+ * @private */
7731
+ DvtFunnelSlice._AREA_FRACTION = 0.41;
7732
+ /** Fraction into which the funnel height is divided by the first line.
7733
+ * @private */
7734
+ DvtFunnelSlice._HEIGHT_FRACTION = 0.28;
7735
+ /** Length of the second line.
7736
+ * @private */
7737
+ DvtFunnelSlice._LINE_FRACTION_2 = 0.4;
7738
+ /** Fraction into which the funnel area is divided by the second line.
7739
+ * @private */
7740
+ DvtFunnelSlice._AREA_FRACTION_2 = 0.8;
7741
+ /** Fraction into which the funnel height is divided by the second line.
7742
+ * @private */
7743
+ DvtFunnelSlice._HEIGHT_FRACTION_2 = 0.7;
7726
7744
7727
7745
7728
7746
/**
@@ -7736,23 +7754,91 @@ DvtFunnelSlice.prototype._getPath = function() {
7736
7754
var offset = (this._numDrawnSeries + 1) * this._gap;
7737
7755
var angle = DvtMath.degreesToRads(DvtFunnelSlice._FUNNEL_ANGLE_2D - 2 * this._3dRatio);
7738
7756
7739
- var rx = (this._funnelWidth - (gapCount * this._gap)) / Math.sin(DvtMath.degreesToRads(DvtFunnelSlice._FUNNEL_ANGLE_2D));
7757
+ var totalWidth = this._funnelWidth - gapCount * this._gap;
7758
+ var rx = totalWidth / Math.sin(DvtMath.degreesToRads(DvtFunnelSlice._FUNNEL_ANGLE_2D));
7740
7759
var ry = this._funnelHeight / Math.sin(angle);
7741
7760
var ratio = this._3dRatio * this._funnelWidth / this._funnelHeight * DvtFunnelSlice._FUNNEL_3D_WIDTH_RATIO;
7742
7761
if (ratio < 0.00001)
7743
7762
ratio = 0;
7744
- var delta = angle * (1 - this._startPercent);
7745
- var gamma = angle * (1 - this._startPercent - this._valuePercent);
7763
+
7764
+ // Dividing the funnel into three trapezoids to come up with a better approximation for the dimensions. We draw two lines,
7765
+ // at .28 and .7 of the height, and they split the area to the ratio .41: .39: .2.
7766
+ var b1 = this._funnelHeight;
7767
+ var b2 = this._funnelHeight * DvtFunnelSlice._FUNNEL_RATIO;
7768
+ var p1, p2; // The percent at which we are calculating the width
7769
+ var b11, b12, b21, b22; // The first and second base of the trapezoid into which the percent we are looking at falls.
7770
+ var f1, f2; // The fraction of the area included in the trapezoid we are considering.
7771
+ var t1, t2; // Total width of the trapezoid we are considering.
7772
+ var h1, h2; // Horizontal distance from the slice to the center of the ellipse for drawing the funnel arcs.
7773
+
7774
+ // calculating first edge
7775
+ if (this._startPercent < DvtFunnelSlice._AREA_FRACTION) {
7776
+ p1 = this._startPercent;
7777
+ b11 = b1;
7778
+ b21 = this._funnelHeight * DvtFunnelSlice._LINE_FRACTION;
7779
+ f1 = DvtFunnelSlice._AREA_FRACTION;
7780
+ t1 = totalWidth * DvtFunnelSlice._HEIGHT_FRACTION;
7781
+ h1 = totalWidth * (1 - DvtFunnelSlice._HEIGHT_FRACTION);
7782
+ }
7783
+ else if (this._startPercent < DvtFunnelSlice._AREA_FRACTION_2) {
7784
+ p1 = this._startPercent - DvtFunnelSlice._AREA_FRACTION;
7785
+ b11 = this._funnelHeight * DvtFunnelSlice._LINE_FRACTION;
7786
+ b21 = this._funnelHeight * DvtFunnelSlice._LINE_FRACTION_2;
7787
+ f1 = DvtFunnelSlice._AREA_FRACTION_2 - DvtFunnelSlice._AREA_FRACTION;
7788
+ t1 = totalWidth * (DvtFunnelSlice._HEIGHT_FRACTION_2 - DvtFunnelSlice._HEIGHT_FRACTION);
7789
+ h1 = totalWidth * (1 - DvtFunnelSlice._HEIGHT_FRACTION_2);
7790
+ }
7791
+ else {
7792
+ p1 = this._startPercent - DvtFunnelSlice._AREA_FRACTION_2;
7793
+ b11 = this._funnelHeight * DvtFunnelSlice._LINE_FRACTION_2;
7794
+ b21 = b2;
7795
+ f1 = 1 - DvtFunnelSlice._AREA_FRACTION_2;
7796
+ t1 = totalWidth * (1 - DvtFunnelSlice._HEIGHT_FRACTION_2);
7797
+ h1 = 0;
7798
+ }
7799
+
7800
+ // Calculating second edge
7801
+ if (this._startPercent + this._valuePercent < DvtFunnelSlice._AREA_FRACTION) {
7802
+ b12 = b1;
7803
+ b22 = this._funnelHeight * DvtFunnelSlice._LINE_FRACTION;
7804
+ p2 = this._startPercent + this._valuePercent;
7805
+ f2 = DvtFunnelSlice._AREA_FRACTION;
7806
+ t2 = totalWidth * DvtFunnelSlice._HEIGHT_FRACTION;
7807
+ h2 = totalWidth * (1 - DvtFunnelSlice._HEIGHT_FRACTION);
7808
+ }
7809
+ else if (this._startPercent + this._valuePercent < DvtFunnelSlice._AREA_FRACTION_2) {
7810
+ b12 = this._funnelHeight * DvtFunnelSlice._LINE_FRACTION;
7811
+ b22 = this._funnelHeight * DvtFunnelSlice._LINE_FRACTION_2;
7812
+ p2 = this._startPercent + this._valuePercent - DvtFunnelSlice._AREA_FRACTION;
7813
+ f2 = DvtFunnelSlice._AREA_FRACTION_2 - DvtFunnelSlice._AREA_FRACTION;
7814
+ t2 = totalWidth * (DvtFunnelSlice._HEIGHT_FRACTION_2 - DvtFunnelSlice._HEIGHT_FRACTION);
7815
+ h2 = totalWidth * (1 - DvtFunnelSlice._HEIGHT_FRACTION_2);
7816
+ }
7817
+ else {
7818
+ b12 = this._funnelHeight * DvtFunnelSlice._LINE_FRACTION_2;
7819
+ b22 = b2;
7820
+ p2 = this._startPercent + this._valuePercent - DvtFunnelSlice._AREA_FRACTION_2;
7821
+ f2 = 1 - DvtFunnelSlice._AREA_FRACTION_2;
7822
+ t2 = totalWidth * (1 - DvtFunnelSlice._HEIGHT_FRACTION_2);
7823
+ h2 = 0;
7824
+ }
7825
+
7826
+ var w1 = Math.sqrt((f1 - p1) / f1 * b11 * b11 + p1 / f1 * b21 * b21);
7827
+ var w2 = Math.sqrt((f2 - p2) / f2 * b12 * b12 + p2 / f2 * b22 * b22);
7828
+
7829
+ var startAngle = 0.98 * Math.asin((((w1 - b21) * (t1) / (b11 - b21)) + h1) / rx);
7830
+ var endAngle = 0.98 * Math.asin((((w2 - b22) * (t2) / (b12 - b22)) + h2) / rx);
7831
+
7746
7832
var c1 = (1 + DvtFunnelSlice._FUNNEL_RATIO) / 2 * this._funnelHeight + ry;
7747
7833
var c2 = (1 - DvtFunnelSlice._FUNNEL_RATIO) / 2 * this._funnelHeight - ry;
7748
7834
var ar, arcDir1, arcDir2;
7749
7835
7750
7836
if (isBiDi) {
7751
- ar = [rx * Math.sin(delta ) + offset, c1 - ry * Math.cos(delta ), rx * Math.sin(gamma ) + offset, c1 - ry * Math.cos(gamma ), rx * Math.sin(gamma ) + offset, c2 + ry * Math.cos(gamma ), rx * Math.sin(delta ) + offset, c2 + ry * Math.cos(delta )];
7837
+ ar = [rx * Math.sin(startAngle ) + offset, c1 - ry * Math.cos(startAngle ), rx * Math.sin(endAngle ) + offset, c1 - ry * Math.cos(endAngle ), rx * Math.sin(endAngle ) + offset, c2 + ry * Math.cos(endAngle ), rx * Math.sin(startAngle ) + offset, c2 + ry * Math.cos(startAngle )];
7752
7838
arcDir1 = 0;
7753
7839
arcDir2 = 1;
7754
7840
} else {
7755
- ar = [this._funnelWidth - offset - rx * Math.sin(delta ), c1 - ry * Math.cos(delta ), this._funnelWidth - offset - rx * Math.sin(gamma ), c1 - ry * Math.cos(gamma ), this._funnelWidth - offset - rx * Math.sin(gamma ), c2 + ry * Math.cos(gamma ), this._funnelWidth - offset - rx * Math.sin(delta ), c2 + ry * Math.cos(delta )];
7841
+ ar = [this._funnelWidth - offset - rx * Math.sin(startAngle ), c1 - ry * Math.cos(startAngle ), this._funnelWidth - offset - rx * Math.sin(endAngle ), c1 - ry * Math.cos(endAngle ), this._funnelWidth - offset - rx * Math.sin(endAngle ), c2 + ry * Math.cos(endAngle ), this._funnelWidth - offset - rx * Math.sin(startAngle ), c2 + ry * Math.cos(startAngle )];
7756
7842
arcDir1 = 1;
7757
7843
arcDir2 = 0;
7758
7844
}
@@ -7815,7 +7901,7 @@ DvtFunnelSlice.prototype._getSliceLabel = function(sliceBounds, barBounds) {
7815
7901
label.setCSSStyle(style);
7816
7902
7817
7903
// Truncating text and dropping if doesn't fit.
7818
- if (! DvtTextUtils.fitText(label, sliceBounds.h - 10 , sliceBounds.w, this, DvtFunnelSlice._MIN_CHARS_DATA_LABEL))
7904
+ if (! DvtTextUtils.fitText(label, sliceBounds.h - this._3dRatio * (0.8 - this._valuePercent) * 50 , sliceBounds.w, this, DvtFunnelSlice._MIN_CHARS_DATA_LABEL))
7819
7905
return;
7820
7906
7821
7907
var textDim = label.measureDimensions();
0 commit comments