|
661 | 661 |
|
662 | 662 | // The group within which to put all of this chart's objects |
663 | 663 | this._group = svg.append("g"); |
664 | | - this._group.attr('class', 'dimple-chart'); |
665 | | - this._gridlines_group = this._group.insert('g'); |
666 | | - this._gridlines_group.attr('class', 'dimple-gridlines-group'); |
667 | | - this._axis_group = this._group.insert('g'); |
668 | | - this._axis_group.attr('class', 'dimple-axis-group'); |
669 | 664 | // The group within which to put tooltips. This is not initialised here because |
670 | 665 | // the group would end up behind other chart contents in a multi chart output. It will |
671 | 666 | // therefore be added and removed by the mouse enter/leave events |
|
1017 | 1012 | returnData.forEach(function (ret) { |
1018 | 1013 | if (x !== null) { |
1019 | 1014 | if (useCount.x === true) { ret.xValue = ret.xValueList.length; } |
1020 | | - if (x._hasMeasure() && x._hasCategories()) { |
1021 | | - tot = (totals.x[ret.xField.join("/")] || 0) + (x._hasMeasure() ? Math.abs(ret.xValue) : 0); |
1022 | | - } else { |
1023 | | - tot = (totals.x[ret.xField.join("/")] || 0) + (y._hasMeasure() ? Math.abs(ret.yValue) : 0); |
1024 | | - } |
| 1015 | + tot = (totals.x[ret.xField.join("/")] || 0) + (y._hasMeasure() ? Math.abs(ret.yValue) : 0); |
1025 | 1016 | totals.x[ret.xField.join("/")] = tot; |
1026 | 1017 | } |
1027 | 1018 | if (y !== null) { |
1028 | 1019 | if (useCount.y === true) { ret.yValue = ret.yValueList.length; } |
1029 | | - if (y._hasMeasure() && y._hasCategories()) { |
1030 | | - tot = (totals.y[ret.yField.join("/")] || 0) + (y._hasMeasure() ? Math.abs(ret.yValue) : 0); |
1031 | | - } else { |
1032 | | - tot = (totals.y[ret.yField.join("/")] || 0) + (x._hasMeasure() ? Math.abs(ret.xValue) : 0); |
1033 | | - } |
| 1020 | + tot = (totals.y[ret.yField.join("/")] || 0) + (x._hasMeasure() ? Math.abs(ret.xValue) : 0); |
1034 | 1021 | totals.y[ret.yField.join("/")] = tot; |
1035 | 1022 | } |
1036 | 1023 | if (p !== null) { |
|
1150 | 1137 |
|
1151 | 1138 | }; |
1152 | 1139 |
|
| 1140 | + |
1153 | 1141 | // Copyright: 2015 AlignAlytics |
1154 | 1142 | // License: "https://github.com/PMSI-AlignAlytics/dimple/blob/master/MIT-LICENSE.txt" |
1155 | 1143 | // Source: /src/objects/chart/methods/_getDelay.js |
|
1614 | 1602 | tooltipLabel: 'dimple-custom-tooltip-label', |
1615 | 1603 | tooltipDropLine: 'dimple-custom-tooltip-dropline', |
1616 | 1604 | lineMarker: 'dimple-custom-line-marker', |
1617 | | - lineMarkerCircle: 'dimple-custom-line-marker-circle', |
1618 | 1605 | legendLabel: 'dimple-custom-legend-label', |
1619 | 1606 | legendKey: 'dimple-custom-legend-key', |
1620 | 1607 | areaSeries: 'dimple-custom-series-area', |
|
1636 | 1623 | 'dimple-custom-format-10' |
1637 | 1624 | ] |
1638 | 1625 | }; |
1639 | | - |
1640 | 1626 | // Copyright: 2015 AlignAlytics |
1641 | 1627 | // License: "https://github.com/PMSI-AlignAlytics/dimple/blob/master/MIT-LICENSE.txt" |
1642 | 1628 | // Source: /src/objects/chart/methods/defaultColors.js |
|
1843 | 1829 | if (axis.gridlineShapes === null) { |
1844 | 1830 | if (axis.showGridlines || (axis.showGridlines === null && !axis._hasCategories() && ((!xGridSet && axis.position === "x") || (!yGridSet && axis.position === "y")))) { |
1845 | 1831 | // Add a group for the gridlines to allow css formatting |
1846 | | - axis.gridlineShapes = this._gridlines_group.append("g").attr("class", "dimple-gridline"); |
| 1832 | + axis.gridlineShapes = this._group.append("g").attr("class", "dimple-gridline"); |
1847 | 1833 | if (axis.position === "x") { |
1848 | 1834 | xGridSet = true; |
1849 | 1835 | } else { |
|
1859 | 1845 | } |
1860 | 1846 | if (axis.shapes === null) { |
1861 | 1847 | // Add a group for the axes to allow css formatting |
1862 | | - axis.shapes = this._axis_group.append("g") |
| 1848 | + axis.shapes = this._group.append("g") |
1863 | 1849 | .attr("class", "dimple-axis dimple-axis-" + axis.position) |
1864 | 1850 | .each(function () { |
1865 | 1851 | if (!chart.noFormats) { |
|
2047 | 2033 | // Add a title for the axis - NB check for null here, by default the title is undefined, in which case |
2048 | 2034 | // use the dimension name |
2049 | 2035 | if (!axis.hidden && (axis.position === "x" || axis.position === "y") && axis.title !== null) { |
2050 | | - axis.titleShape = this._axis_group.append("text") |
| 2036 | + axis.titleShape = this._group.append("text") |
2051 | 2037 | .attr("class", "dimple-axis dimple-title " + chart.customClassList.axisTitle + " dimple-axis-" + axis.position); |
2052 | 2038 | axis.titleShape |
2053 | 2039 | .attr("x", titleX) |
|
2191 | 2177 | this._heightPixels = function () { |
2192 | 2178 | return dimple._parentHeight(this.svg.node()) - this._yPixels() - dimple._parseYPosition(bottom, this.svg.node()); |
2193 | 2179 | }; |
| 2180 | + // Refresh the axes to redraw them against the new bounds |
| 2181 | + this.draw(0, true); |
2194 | 2182 | // return the chart object for method chaining |
2195 | 2183 | return this; |
2196 | 2184 | }; |
|
2568 | 2556 | this.tooltipFontFamily = "sans-serif"; |
2569 | 2557 | // Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.axis#wiki-radius |
2570 | 2558 | this.radius = "auto"; |
2571 | | - // The group within which to put all of this series's objects |
2572 | | - this._group = chart._group.append("g"); |
2573 | | - this._group.attr('class', 'dimple-series-group-' + chart.series.length); |
2574 | 2559 |
|
2575 | 2560 | // Any event handlers joined to this series |
2576 | 2561 | this._eventHandlers = []; |
|
3157 | 3142 | p, |
3158 | 3143 | b, |
3159 | 3144 | l, |
3160 | | - lIndex, |
3161 | 3145 | lastAngle, |
3162 | 3146 | catCoord, |
3163 | 3147 | valCoord, |
|
3424 | 3408 | p = getArea(interpolation, "_previousOrigin")(finalPointArray); |
3425 | 3409 | b = getArea((interpolation === "step-after" ? "step-before" : (interpolation === "step-before" ? "step-after" : interpolation)), "_previousOrigin")(basePoints); |
3426 | 3410 | l = getArea("linear", "_previousOrigin")(finalPointArray); |
3427 | | - lIndex = l.indexOf("L") === -1 ? undefined : l.indexOf("L"); |
3428 | | - areaData[i].entry = p + (b && b.length > 0 ? "L" + b.substring(1) : "") + (l && l.length > 0 ? "L" + l.substring(1, lIndex) : 0); |
| 3411 | + areaData[i].entry = p + (b && b.length > 0 ? "L" + b.substring(1) : "") + (l && l.length > 0 ? "L" + l.substring(1, l.indexOf("L")) : 0); |
3429 | 3412 |
|
3430 | 3413 | p = getArea(interpolation)(finalPointArray); |
3431 | 3414 | b = getArea(interpolation === "step-after" ? "step-before" : (interpolation === "step-before" ? "step-after" : interpolation))(basePoints); |
3432 | 3415 | l = getArea("linear")(finalPointArray); |
3433 | | - lIndex = l.indexOf("L") === -1 ? undefined : l.indexOf("L"); |
3434 | | - areaData[i].update = p + (b && b.length > 0 ? "L" + b.substring(1) : "") + (l && l.length > 0 ? "L" + l.substring(1, lIndex) : 0); |
| 3416 | + areaData[i].update = p + (b && b.length > 0 ? "L" + b.substring(1) : "") + (l && l.length > 0 ? "L" + l.substring(1, l.indexOf("L")) : 0); |
3435 | 3417 |
|
3436 | 3418 | p = getArea(interpolation, "_origin")(finalPointArray); |
3437 | 3419 | b = getArea((interpolation === "step-after" ? "step-before" : (interpolation === "step-before" ? "step-after" : interpolation)), "_origin")(basePoints); |
3438 | 3420 | l = getArea("linear", "_origin")(finalPointArray); |
3439 | | - lIndex = l.indexOf("L") === -1 ? undefined : l.indexOf("L"); |
3440 | | - areaData[i].exit = p + (b && b.length > 0 ? "L" + b.substring(1) : "") + (l && l.length > 0 ? "L" + l.substring(1, lIndex) : 0); |
| 3421 | + areaData[i].exit = p + (b && b.length > 0 ? "L" + b.substring(1) : "") + (l && l.length > 0 ? "L" + l.substring(1, l.indexOf("L")) : 0); |
3441 | 3422 |
|
3442 | 3423 | // Add the color in this loop, it can't be done during initialisation of the row because |
3443 | 3424 | // the areas should be ordered first (to ensure standard distribution of colors |
|
3450 | 3431 | } |
3451 | 3432 |
|
3452 | 3433 | if (series.shapes === null || series.shapes === undefined) { |
3453 | | - theseShapes = series._group.selectAll("." + className).data(areaData); |
| 3434 | + theseShapes = chart._group.selectAll("." + className).data(areaData); |
3454 | 3435 | } else { |
3455 | 3436 | theseShapes = series.shapes.data(areaData, function (d) { return d.key; }); |
3456 | 3437 | } |
|
3544 | 3525 | } |
3545 | 3526 |
|
3546 | 3527 | if (series.shapes === null || series.shapes === undefined) { |
3547 | | - theseShapes = series._group.selectAll("." + classes.join(".")).data(chartData); |
| 3528 | + theseShapes = chart._group.selectAll("." + classes.join(".")).data(chartData); |
3548 | 3529 | } else { |
3549 | 3530 | theseShapes = series.shapes.data(chartData, function (d) { return d.key; }); |
3550 | 3531 | } |
|
3663 | 3644 | } |
3664 | 3645 |
|
3665 | 3646 | if (series.shapes === null || series.shapes === undefined) { |
3666 | | - theseShapes = series._group.selectAll("." + classes.join(".")).data(chartData); |
| 3647 | + theseShapes = chart._group.selectAll("." + classes.join(".")).data(chartData); |
3667 | 3648 | } else { |
3668 | 3649 | theseShapes = series.shapes.data(chartData, function (d) { |
3669 | 3650 | return d.key; |
|
3877 | 3858 | } |
3878 | 3859 | } |
3879 | 3860 |
|
3880 | | - // Special case when a line contains a single point - duplicate the point |
3881 | | - // If we don't do this a path will be created with 0,0 coordinates |
3882 | | - if (lineData && lineData[i] && lineData[i].points && lineData[i].points.length === 1) { |
3883 | | - lineData[i].points.push( |
3884 | | - { |
3885 | | - x : lineData[i].points[0].x, |
3886 | | - y : lineData[i].points[0].y |
3887 | | - } |
3888 | | - ); |
3889 | | - } |
3890 | | - |
3891 | 3861 | // Get the points that this line will appear |
3892 | 3862 | lineData[i].entry = getLine(interpolation, "_previousOrigin")(lineData[i].points); |
3893 | 3863 | lineData[i].update = getLine(interpolation)(lineData[i].points); |
|
3904 | 3874 | } |
3905 | 3875 |
|
3906 | 3876 | if (series.shapes === null || series.shapes === undefined) { |
3907 | | - theseShapes = series._group.selectAll("." + className).data(lineData); |
| 3877 | + theseShapes = chart._group.selectAll("." + className).data(lineData); |
3908 | 3878 | } else { |
3909 | 3879 | theseShapes = series.shapes.data(lineData, function (d) { return d.key; }); |
3910 | 3880 | } |
|
4058 | 4028 | } |
4059 | 4029 |
|
4060 | 4030 | if (series.shapes === null || series.shapes === undefined) { |
4061 | | - theseShapes = series._group.selectAll("." + classes.join(".")).data(chartData); |
| 4031 | + theseShapes = chart._group.selectAll("." + classes.join(".")).data(chartData); |
4062 | 4032 | } else { |
4063 | 4033 | theseShapes = series.shapes.data(chartData, function (d) { return d.key; }); |
4064 | 4034 | } |
|
4252 | 4222 | shapes; |
4253 | 4223 | if (series.lineMarkers) { |
4254 | 4224 | if (series._markerBacks === null || series._markerBacks === undefined || series._markerBacks[lineDataRow.keyString] === undefined) { |
4255 | | - markerBacks = series._group.selectAll("." + markerBackClasses.join(".")).data(lineDataRow.markerData); |
| 4225 | + markerBacks = chart._group.selectAll("." + markerBackClasses.join(".")).data(lineDataRow.markerData); |
4256 | 4226 | } else { |
4257 | 4227 | markerBacks = series._markerBacks[lineDataRow.keyString].data(lineDataRow.markerData, function (d) { return d.key; }); |
4258 | 4228 | } |
|
4320 | 4290 |
|
4321 | 4291 | // Deal with markers in the same way as main series to fix #28 |
4322 | 4292 | if (series._markers === null || series._markers === undefined || series._markers[lineDataRow.keyString] === undefined) { |
4323 | | - markers = series._group.selectAll("." + markerClasses.join(".")).data(lineDataRow.markerData); |
| 4293 | + markers = chart._group.selectAll("." + markerClasses.join(".")).data(lineDataRow.markerData); |
4324 | 4294 | } else { |
4325 | 4295 | markers = series._markers[lineDataRow.keyString].data(lineDataRow.markerData, function (d) { |
4326 | 4296 | return d.key; |
|
5247 | 5217 |
|
5248 | 5218 | // Add a ring around the data point |
5249 | 5219 | chart._tooltipGroup.append("circle") |
5250 | | - .attr("class", "dimple-line-marker-circle " + chart.customClassList.lineMarkerCircle) |
5251 | 5220 | .attr("cx", cx) |
5252 | 5221 | .attr("cy", cy) |
5253 | 5222 | .attr("r", r) |
|
0 commit comments