@datarailsshared/dr_renderer 1.3.17 → 1.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -338,8 +338,9 @@ function DrGaugeChart(pivotData, opts) {
|
|
338
338
|
};
|
339
339
|
|
340
340
|
this.setTicksStyles = function (chart, options) {
|
341
|
-
|
342
|
-
|
341
|
+
const ticks = chart.yAxis[0].ticks;
|
342
|
+
Object.keys(ticks).forEach((i) => {
|
343
|
+
const tick = ticks[i];
|
343
344
|
const isLeftQuarter = this.isLeftQuarter(tick.pos);
|
344
345
|
|
345
346
|
if (tick.pos === options.goal.value) {
|
@@ -357,8 +358,42 @@ function DrGaugeChart(pivotData, opts) {
|
|
357
358
|
transform: `translate(${isLeftQuarter ? "-100%" : 0}, 0)`,
|
358
359
|
});
|
359
360
|
});
|
361
|
+
|
362
|
+
// If goal is hidden, we need to always show goal and hide the closest visible label before it
|
363
|
+
this.updateLabelsWhenGoalIsHidden(ticks, options);
|
364
|
+
|
360
365
|
};
|
361
366
|
|
367
|
+
this.updateLabelsWhenGoalIsHidden = function (ticks, options) {
|
368
|
+
if (ticks[options.goal.value].label.opacity === 0) {
|
369
|
+
|
370
|
+
const ticksArray = Object.entries(ticks);
|
371
|
+
|
372
|
+
const goalTick = ticks[options.goal.value];
|
373
|
+
|
374
|
+
let firstVisibleLabelBeforeGoal = options.goal.value;
|
375
|
+
for (let i = ticksArray.findIndex(([key, _]) => Number(key) === options.goal.value) - 1; i >= 0; i--) {
|
376
|
+
const [key, tick] = ticksArray[i];
|
377
|
+
|
378
|
+
if (tick.label.opacity === 1) {
|
379
|
+
firstVisibleLabelBeforeGoal = Number(key);
|
380
|
+
break;
|
381
|
+
}
|
382
|
+
}
|
383
|
+
|
384
|
+
ticks[firstVisibleLabelBeforeGoal].label.css({
|
385
|
+
opacity: 0,
|
386
|
+
visibility: "hidden",
|
387
|
+
});
|
388
|
+
|
389
|
+
goalTick.label.css({
|
390
|
+
opacity: 1,
|
391
|
+
visibility: "visible",
|
392
|
+
});
|
393
|
+
|
394
|
+
}
|
395
|
+
}
|
396
|
+
|
362
397
|
this.addTooltips = function (chart, options) {
|
363
398
|
if (!options.tooltips.show) {
|
364
399
|
return false;
|
@@ -511,7 +546,7 @@ function DrGaugeChart(pivotData, opts) {
|
|
511
546
|
enabled: !!this.options.label.show,
|
512
547
|
distance: 0,
|
513
548
|
verticalAlign: "middle",
|
514
|
-
allowOverlap:
|
549
|
+
allowOverlap: false,
|
515
550
|
align: "left",
|
516
551
|
style: {
|
517
552
|
whiteSpace: "nowrap",
|
@@ -8286,6 +8286,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8286
8286
|
class: 'google-visualization-charteditor-thumbs-walkthrough',
|
8287
8287
|
render: highchartsRenderer.ptRenderWaterfallWalkthrough,
|
8288
8288
|
suboptions: [
|
8289
|
+
highchartsRenderer.suboptions["axisY"],
|
8289
8290
|
highchartsRenderer.suboptions["axisX"],
|
8290
8291
|
highchartsRenderer.suboptions["tooltips"],
|
8291
8292
|
highchartsRenderer.suboptions["label"],
|
@@ -1204,6 +1204,15 @@ describe("DrGaugeChart", () => {
|
|
1204
1204
|
css: jest.fn(),
|
1205
1205
|
},
|
1206
1206
|
},
|
1207
|
+
180: {
|
1208
|
+
pos: 180,
|
1209
|
+
label: {
|
1210
|
+
css: jest.fn(),
|
1211
|
+
},
|
1212
|
+
mark: {
|
1213
|
+
attr: jest.fn(),
|
1214
|
+
},
|
1215
|
+
},
|
1207
1216
|
},
|
1208
1217
|
},
|
1209
1218
|
],
|
@@ -1234,11 +1243,14 @@ describe("DrGaugeChart", () => {
|
|
1234
1243
|
yAxis: [
|
1235
1244
|
{
|
1236
1245
|
ticks: {
|
1237
|
-
|
1246
|
+
180: {
|
1238
1247
|
pos: 180,
|
1239
1248
|
mark: {
|
1240
1249
|
attr: jest.fn(),
|
1241
1250
|
},
|
1251
|
+
label: {
|
1252
|
+
css: jest.fn(),
|
1253
|
+
},
|
1242
1254
|
},
|
1243
1255
|
},
|
1244
1256
|
},
|
@@ -1256,7 +1268,7 @@ describe("DrGaugeChart", () => {
|
|
1256
1268
|
},
|
1257
1269
|
});
|
1258
1270
|
// add a goal tick styles
|
1259
|
-
expect(mockChart.yAxis[0].ticks[
|
1271
|
+
expect(mockChart.yAxis[0].ticks[180].mark.attr).toHaveBeenCalledWith({
|
1260
1272
|
"pointer-events": "none",
|
1261
1273
|
stroke: "blue",
|
1262
1274
|
"stroke-dasharray": 2,
|
@@ -1889,7 +1901,7 @@ describe("DrGaugeChart", () => {
|
|
1889
1901
|
expect(config.yAxis.labels.enabled).toBe(mockOptions.label.show);
|
1890
1902
|
expect(config.yAxis.labels.distance).toBe(0),
|
1891
1903
|
expect(config.yAxis.labels.verticalAlign).toBe("middle"),
|
1892
|
-
expect(config.yAxis.labels.allowOverlap).toBe(
|
1904
|
+
expect(config.yAxis.labels.allowOverlap).toBe(false),
|
1893
1905
|
expect(config.yAxis.labels.align).toBe("left");
|
1894
1906
|
expect(config.yAxis.labels.style).toEqual({
|
1895
1907
|
whiteSpace: "nowrap",
|