Skip to content

Commit a482c70

Browse files
Fixed Tooltips where noFormats = true
1 parent 300269d commit a482c70

119 files changed

Lines changed: 5752 additions & 201 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"dependencies": {
1010
"d3": ">=3.5.2"
1111
},
12-
"version": "2.1.5",
12+
"version": "2.1.6",
1313
"homepage": "dimplejs.org",
1414
"authors": [
1515
"johnkiernander <[email protected]>"

dist/dimple.latest.js

Lines changed: 96 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
// Create the stub object
4040
var dimple = {
41-
version: "2.1.5",
41+
version: "2.1.6",
4242
plot: {},
4343
aggregateMethod: {}
4444
};
@@ -1600,6 +1600,7 @@
16001600
axisTitle: 'dimple-custom-axis-title',
16011601
tooltipBox: 'dimple-custom-tooltip-box',
16021602
tooltipLabel: 'dimple-custom-tooltip-label',
1603+
tooltipDropLine: 'dimple-custom-tooltip-dropline',
16031604
lineMarker: 'dimple-custom-line-marker',
16041605
legendLabel: 'dimple-custom-legend-label',
16051606
legendKey: 'dimple-custom-legend-key',
@@ -3446,8 +3447,8 @@
34463447
// Apply formats optionally
34473448
if (!chart.noFormats) {
34483449
this.attr("opacity", function (d) { return (graded ? 1 : d.color.opacity); })
3449-
.style("fill", function (d) { return (graded ? "url(#fill-area-gradient-" + d.keyString + ")" : d.color.fill); })
3450-
.style("stroke", function (d) { return (graded ? "url(#stroke-area-gradient-" + d.keyString + ")" : d.color.stroke); })
3450+
.style("fill", function (d) { return (graded ? "url(#" + dimple._createClass(["fill-area-gradient-" + d.keyString]) + ")" : d.color.fill); })
3451+
.style("stroke", function (d) { return (graded ? "url(#" + dimple._createClass(["stroke-area-gradient-" + d.keyString]) + ")" : d.color.stroke); })
34513452
.style("stroke-width", series.lineWeight);
34523453
}
34533454
})
@@ -3894,7 +3895,7 @@
38943895
if (!chart.noFormats) {
38953896
this.attr("opacity", function (d) { return (graded ? 1 : d.color.opacity); })
38963897
.style("fill", "none")
3897-
.style("stroke", function (d) { return (graded ? "url(#fill-line-gradient-" + d.keyString + ")" : d.color.stroke); })
3898+
.style("stroke", function (d) { return (graded ? "url(#" + dimple._createClass(["fill-line-gradient-" + d.keyString]) + ")" : d.color.stroke); })
38983899
.style("stroke-width", series.lineWeight);
38993900
}
39003901
})
@@ -4092,7 +4093,7 @@
40924093
dimple._addGradient = function (seriesValue, id, categoryAxis, data, chart, duration, colorProperty) {
40934094

40944095
var sArray = [].concat(seriesValue),
4095-
grad = chart._group.select("#" + id),
4096+
grad = chart.svg.select("#" + dimple._createClass([id])),
40964097
cats = [],
40974098
field = categoryAxis.position + "Field",
40984099
transition = true,
@@ -4108,7 +4109,7 @@
41084109

41094110
if (grad.node() === null) {
41104111
transition = false;
4111-
grad = chart._group.append("linearGradient")
4112+
grad = chart.svg.append("defs").append("linearGradient")
41124113
.attr("id", dimple._createClass([id]))
41134114
.attr("gradientUnits", "userSpaceOnUse")
41144115
.attr("x1", (categoryAxis.position === "x" ? categoryAxis._scale(cats[0]) + ((chart._widthPixels() / cats.length) / 2) : 0))
@@ -5031,15 +5032,21 @@
50315032
// Add a drop line to the x axis
50325033
if (!series.x._hasCategories() && dropDest.y !== null) {
50335034
chart._tooltipGroup.append("line")
5035+
.attr("class", "dimple-tooltip-dropline " + chart.customClassList.tooltipDropLine)
50345036
.attr("x1", (x < series.x._origin ? x + offset : x + width - offset))
50355037
.attr("y1", (y < dropDest.y ? y + height : y))
50365038
.attr("x2", (x < series.x._origin ? x + offset : x + width - offset))
50375039
.attr("y2", (y < dropDest.y ? y + height : y))
5038-
.style("fill", "none")
5039-
.style("stroke", fill)
5040-
.style("stroke-width", 2)
5041-
.style("stroke-dasharray", ("3, 3"))
5042-
.style("opacity", opacity)
5040+
.call(function () {
5041+
// Apply formats optionally
5042+
if (!chart.noFormats) {
5043+
this.style("fill", "none")
5044+
.style("stroke", fill)
5045+
.style("stroke-width", 2)
5046+
.style("stroke-dasharray", ("3, 3"))
5047+
.style("opacity", opacity);
5048+
}
5049+
})
50435050
.transition()
50445051
.delay(animDuration / 2)
50455052
.duration(animDuration / 2)
@@ -5055,15 +5062,21 @@
50555062
// Add a drop line to the y axis
50565063
if (!series.y._hasCategories() && dropDest.x !== null) {
50575064
chart._tooltipGroup.append("line")
5065+
.attr("class", "dimple-tooltip-dropline " + chart.customClassList.tooltipDropLine)
50585066
.attr("x1", (x < dropDest.x ? x + width : x))
50595067
.attr("y1", (y < series.y._origin ? y + offset : y + height - offset))
50605068
.attr("x2", (x < dropDest.x ? x + width : x))
50615069
.attr("y2", (y < series.y._origin ? y + offset : y + height - offset))
5062-
.style("fill", "none")
5063-
.style("stroke", fill)
5064-
.style("stroke-width", 2)
5065-
.style("stroke-dasharray", ("3, 3"))
5066-
.style("opacity", opacity)
5070+
.call(function () {
5071+
// Apply formats optionally
5072+
if (!chart.noFormats) {
5073+
this.style("fill", "none")
5074+
.style("stroke", fill)
5075+
.style("stroke-width", 2)
5076+
.style("stroke-dasharray", ("3, 3"))
5077+
.style("opacity", opacity);
5078+
}
5079+
})
50675080
.transition()
50685081
.delay(animDuration / 2)
50695082
.duration(animDuration / 2)
@@ -5087,8 +5100,13 @@
50875100
.append("text")
50885101
.attr("class", "dimple-tooltip " + chart.customClassList.tooltipLabel)
50895102
.text(function (d) { return d; })
5090-
.style("font-family", series.tooltipFontFamily)
5091-
.style("font-size", series._getTooltipFontSize());
5103+
.call(function () {
5104+
// Apply formats optionally
5105+
if (!chart.noFormats) {
5106+
this.style("font-family", series.tooltipFontFamily)
5107+
.style("font-size", series._getTooltipFontSize());
5108+
}
5109+
});
50925110

50935111
// Get the max height and width of the text items
50945112
t.each(function () {
@@ -5114,10 +5132,16 @@
51145132
.attr("width", w + 2 * textMargin)
51155133
.attr("rx", 5)
51165134
.attr("ry", 5)
5117-
.style("fill", popupFillColor)
5118-
.style("stroke", popupStrokeColor)
5119-
.style("stroke-width", 2)
5120-
.style("opacity", 0.95);
5135+
.call(function () {
5136+
// Apply formats optionally
5137+
if (!chart.noFormats) {
5138+
this.style("fill", popupFillColor)
5139+
.style("stroke", popupStrokeColor)
5140+
.style("stroke-width", 2)
5141+
.style("opacity", 0.95);
5142+
}
5143+
});
5144+
51215145

51225146
// Shift the popup around to avoid overlapping the svg edge
51235147
if (transformPoint(x + width + textMargin + popupMargin + w).x < parseFloat(chart.svg.node().getBBox().width)) {
@@ -5196,29 +5220,42 @@
51965220
.attr("cx", cx)
51975221
.attr("cy", cy)
51985222
.attr("r", r)
5199-
.attr("opacity", 0)
5200-
.style("fill", "none")
5201-
.style("stroke", fill)
5202-
.style("stroke-width", 1)
5223+
.call(function () {
5224+
if (!chart.noFormats) {
5225+
this.attr("opacity", 0)
5226+
.style("fill", "none")
5227+
.style("stroke", fill)
5228+
.style("stroke-width", 1);
5229+
}
5230+
})
52035231
.transition()
52045232
.duration(animDuration / 2)
52055233
.ease("linear")
5206-
.attr("opacity", 1)
52075234
.attr("r", r + series.lineWeight + 2)
5208-
.style("stroke-width", 2);
5235+
.call(function () {
5236+
if (!chart.noFormats) {
5237+
this.attr("opacity", 1)
5238+
.style("stroke-width", 2);
5239+
}
5240+
});
52095241

52105242
// Add a drop line to the x axis
52115243
if (dropDest.y !== null) {
52125244
chart._tooltipGroup.append("line")
5245+
.attr("class", "dimple-tooltip-dropline " + chart.customClassList.tooltipDropLine)
52135246
.attr("x1", cx)
52145247
.attr("y1", (cy < dropDest.y ? cy + r + series.lineWeight + 2 : cy - r - series.lineWeight - 2))
52155248
.attr("x2", cx)
52165249
.attr("y2", (cy < dropDest.y ? cy + r + series.lineWeight + 2 : cy - r - series.lineWeight - 2))
5217-
.style("fill", "none")
5218-
.style("stroke", fill)
5219-
.style("stroke-width", 2)
5220-
.style("stroke-dasharray", ("3, 3"))
5221-
.style("opacity", opacity)
5250+
.call(function () {
5251+
if (!chart.noFormats) {
5252+
this.style("fill", "none")
5253+
.style("stroke", fill)
5254+
.style("stroke-width", 2)
5255+
.style("stroke-dasharray", ("3, 3"))
5256+
.style("opacity", opacity);
5257+
}
5258+
})
52225259
.transition()
52235260
.delay(animDuration / 2)
52245261
.duration(animDuration / 2)
@@ -5232,15 +5269,20 @@
52325269
// Add a drop line to the y axis
52335270
if (dropDest.x !== null) {
52345271
chart._tooltipGroup.append("line")
5272+
.attr("class", "dimple-tooltip-dropline " + chart.customClassList.tooltipDropLine)
52355273
.attr("x1", (cx < dropDest.x ? cx + r + series.lineWeight + 2 : cx - r - series.lineWeight - 2))
52365274
.attr("y1", cy)
52375275
.attr("x2", (cx < dropDest.x ? cx + r + series.lineWeight + 2 : cx - r - series.lineWeight - 2))
52385276
.attr("y2", cy)
5239-
.style("fill", "none")
5240-
.style("stroke", fill)
5241-
.style("stroke-width", 2)
5242-
.style("stroke-dasharray", ("3, 3"))
5243-
.style("opacity", opacity)
5277+
.call(function () {
5278+
if (!chart.noFormats) {
5279+
this.style("fill", "none")
5280+
.style("stroke", fill)
5281+
.style("stroke-width", 2)
5282+
.style("stroke-dasharray", ("3, 3"))
5283+
.style("opacity", opacity);
5284+
}
5285+
})
52445286
.transition()
52455287
.delay(animDuration / 2)
52465288
.duration(animDuration / 2)
@@ -5255,15 +5297,19 @@
52555297
t = chart._tooltipGroup.append("g");
52565298
// Create a box for the popup in the text group
52575299
box = t.append("rect")
5258-
.attr("class", "dimple-tooltip");
5300+
.attr("class", "dimple-tooltip " + chart.customClassList.tooltipBox);
52595301

52605302
// Create a text object for every row in the popup
52615303
t.selectAll(".dont-select-any").data(tipText).enter()
52625304
.append("text")
5263-
.attr("class", "dimple-tooltip")
5305+
.attr("class", "dimple-tooltip " + chart.customClassList.tooltipLabel)
52645306
.text(function (d) { return d; })
5265-
.style("font-family", series.tooltipFontFamily)
5266-
.style("font-size", series._getTooltipFontSize());
5307+
.call(function () {
5308+
if (!chart.noFormats) {
5309+
this.style("font-family", series.tooltipFontFamily)
5310+
.style("font-size", series._getTooltipFontSize());
5311+
}
5312+
});
52675313

52685314
// Get the max height and width of the text items
52695315
t.each(function () {
@@ -5289,10 +5335,14 @@
52895335
.attr("width", w + 2 * textMargin)
52905336
.attr("rx", 5)
52915337
.attr("ry", 5)
5292-
.style("fill", popupFillColor)
5293-
.style("stroke", popupStrokeColor)
5294-
.style("stroke-width", 2)
5295-
.style("opacity", 0.95);
5338+
.call(function () {
5339+
if (!chart.noFormats) {
5340+
this.style("fill", popupFillColor)
5341+
.style("stroke", popupStrokeColor)
5342+
.style("stroke-width", 2)
5343+
.style("opacity", 0.95);
5344+
}
5345+
});
52965346

52975347
// Shift the popup around to avoid overlapping the svg edge
52985348
if (cx + r + textMargin + popupMargin + w < parseFloat(chart.svg.node().getBBox().width)) {

dist/dimple.latest.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)