|
15 | 15 | graded = false, |
16 | 16 | line, |
17 | 17 | catPoints = {}, |
18 | | - markers; |
| 18 | + markers, |
| 19 | + markerBacks; |
19 | 20 |
|
20 | 21 | if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { |
21 | 22 | chart._tooltipGroup.remove(); |
|
65 | 66 | .data(uniqueValues) |
66 | 67 | .transition() |
67 | 68 | .duration(duration) |
68 | | - .attr("class", function (d) { return "series area " + d.replace(" ", ""); }) |
| 69 | + .attr("class", function (d) { return "series area " + d.split(" ").join("_"); }) |
69 | 70 | .attr("d", function (d) { |
70 | 71 | var seriesData, |
71 | 72 | baseline = [], |
|
147 | 148 | } |
148 | 149 | }); |
149 | 150 |
|
150 | | - // Add line markers. |
151 | | - markers = chart._group.selectAll(".markers") |
152 | | - .data(data) |
153 | | - .enter(); |
154 | | - |
155 | | - // Add a fully opaque white circle first so we don't see a ghost of the line |
156 | 151 | if (series.lineMarkers) { |
157 | | - markers.append("circle") |
| 152 | + if (series._markerBacks === null || series._markerBacks === undefined) { |
| 153 | + markerBacks = chart._group.selectAll(".markerBacks").data(data); |
| 154 | + } else { |
| 155 | + markerBacks = series._markerBacks.data(data, function (d) { return d.key; }); |
| 156 | + } |
| 157 | + // Add |
| 158 | + markerBacks |
| 159 | + .enter() |
| 160 | + .append("circle") |
| 161 | + .attr("id", function (d) { return d.key; }) |
| 162 | + .attr("class", "markerBacks") |
| 163 | + .attr("cx", function (d) { return dimple._helpers.cx(d, chart, series); }) |
| 164 | + .attr("cy", function (d) { return dimple._helpers.cy(d, chart, series); }) |
| 165 | + .attr("r", 0) |
| 166 | + .attr("fill", "white") |
| 167 | + .attr("stroke", "none"); |
| 168 | + |
| 169 | + // Update |
| 170 | + markerBacks |
158 | 171 | .transition().duration(duration) |
159 | | - .attr("cx", function (d) { return dimple._helpers.cx(d, chart, series); }) |
160 | | - .attr("cy", function (d) { return dimple._helpers.cy(d, chart, series); }) |
161 | | - .attr("r", 2 + series.lineWeight) |
162 | | - .attr("fill", "white") |
163 | | - .attr("stroke", "none"); |
| 172 | + .attr("cx", function (d) { return dimple._helpers.cx(d, chart, series); }) |
| 173 | + .attr("cy", function (d) { return dimple._helpers.cy(d, chart, series); }) |
| 174 | + .attr("r", 2 + series.lineWeight); |
| 175 | + // Remove |
| 176 | + markerBacks |
| 177 | + .exit() |
| 178 | + .transition().duration(duration) |
| 179 | + .attr("r", 0) |
| 180 | + .each("end", function () { |
| 181 | + d3.select(this).remove(); |
| 182 | + }); |
| 183 | + series._markerBacks = markerBacks; |
| 184 | + } |
| 185 | + |
| 186 | + // Deal with markers in the same way as main series to fix #28 |
| 187 | + if (series._markers === null || series._markers === undefined) { |
| 188 | + markers = chart._group.selectAll(".markers").data(data); |
| 189 | + } else { |
| 190 | + markers = series._markers.data(data, function (d) { return d.key; }); |
164 | 191 | } |
165 | 192 |
|
| 193 | + |
166 | 194 | // Add the actual marker. We need to do this even if we aren't displaying them because they |
167 | 195 | // catch hover events |
168 | | - markers.append("circle") |
| 196 | + markers |
| 197 | + .enter() |
| 198 | + .append("circle") |
| 199 | + .attr("id", function (d) { return d.key; }) |
| 200 | + .attr("class", "markers") |
169 | 201 | .on("mouseover", function (e) { |
170 | 202 | self.enterEventHandler(e, this, chart, series); |
171 | 203 | }) |
172 | 204 | .on("mouseleave", function (e) { |
173 | 205 | self.leaveEventHandler(e, this, chart, series); |
174 | 206 | }) |
| 207 | + .attr("cx", function (d) { return dimple._helpers.cx(d, chart, series); }) |
| 208 | + .attr("cy", function (d) { return dimple._helpers.cy(d, chart, series); }) |
| 209 | + .attr("r", 0) |
| 210 | + .attr("opacity", function (d) { return (series.lineMarkers ? chart.getColor(d).opacity : 0); }) |
| 211 | + .call(function () { |
| 212 | + if (!chart.noFormats) { |
| 213 | + this.attr("fill", "white") |
| 214 | + .style("stroke-width", series.lineWeight) |
| 215 | + .attr("stroke", function (d) { |
| 216 | + return (graded ? dimple._helpers.fill(d, chart, series) : chart.getColor(d.aggField[d.aggField.length - 1]).stroke); |
| 217 | + }); |
| 218 | + } |
| 219 | + }); |
| 220 | + |
| 221 | + markers |
175 | 222 | .transition().duration(duration) |
176 | 223 | .attr("cx", function (d) { return dimple._helpers.cx(d, chart, series); }) |
177 | 224 | .attr("cy", function (d) { return dimple._helpers.cy(d, chart, series); }) |
178 | 225 | .attr("r", 2 + series.lineWeight) |
179 | | - .attr("opacity", function (d) { return (series.lineMarkers ? chart.getColor(d).opacity : 0); }) |
180 | 226 | .call(function () { |
181 | 227 | if (!chart.noFormats) { |
182 | 228 | this.attr("fill", "white") |
183 | 229 | .style("stroke-width", series.lineWeight) |
184 | | - .attr("stroke", function (d) { return dimple._helpers.stroke(d, chart, series); }); |
| 230 | + .attr("stroke", function (d) { |
| 231 | + return (graded ? dimple._helpers.fill(d, chart, series) : chart.getColor(d.aggField[d.aggField.length - 1]).stroke); |
| 232 | + }); |
185 | 233 | } |
186 | 234 | }); |
| 235 | + |
| 236 | + markers |
| 237 | + .exit() |
| 238 | + .transition().duration(duration) |
| 239 | + .attr("r", 0) |
| 240 | + .each("end", function () { |
| 241 | + d3.select(this).remove(); |
| 242 | + }); |
| 243 | + |
| 244 | + // Save the shapes to the series array |
| 245 | + series._markers = markers; |
187 | 246 | }, |
188 | 247 |
|
189 | 248 | // Handle the mouse enter event |
|
293 | 352 | // Add a group for text |
294 | 353 | t = chart._tooltipGroup.append("g"); |
295 | 354 | // Create a box for the popup in the text group |
296 | | - box = t.append("rect"); |
| 355 | + box = t.append("rect") |
| 356 | + .attr("class", "tooltip"); |
297 | 357 |
|
298 | 358 | // Add the series categories |
299 | 359 | if (series.categoryFields !== null && series.categoryFields !== undefined && series.categoryFields.length > 0) { |
|
346 | 406 | // Create a text object for every row in the popup |
347 | 407 | t.selectAll(".textHoverShapes").data(rows).enter() |
348 | 408 | .append("text") |
| 409 | + .attr("class", "tooltip") |
349 | 410 | .text(function (d) { return d; }) |
350 | 411 | .style("font-family", "sans-serif") |
351 | 412 | .style("font-size", "10px"); |
|
0 commit comments