billboard.js 3.6.0-next.2 → 3.6.0
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/dist/billboard.css +1 -1
- package/dist/billboard.js +424 -237
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +538 -351
- package/dist/billboard.pkgd.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +116 -116
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +116 -116
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +116 -116
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +116 -116
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +116 -116
- package/dist/theme/datalab.css +1 -1
- package/dist/theme/datalab.min.css +1 -1
- package/dist/theme/graph.css +1 -1
- package/dist/theme/graph.min.css +1 -1
- package/dist/theme/insight.css +1 -1
- package/dist/theme/insight.min.css +1 -1
- package/dist-esm/billboard.js +342 -168
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +5 -5
- package/src/ChartInternal/internals/color.ts +50 -0
- package/src/ChartInternal/internals/legend.ts +246 -145
- package/src/ChartInternal/shape/area.ts +9 -38
- package/src/ChartInternal/shape/bar.ts +20 -3
- package/src/config/Options/common/legend.ts +18 -3
- package/src/config/Options/shape/bar.ts +32 -0
- package/types/options.d.ts +23 -4
package/dist-esm/billboard.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 3.6.0
|
|
8
|
+
* @version 3.6.0
|
|
9
9
|
*/
|
|
10
10
|
import { timeParse, utcParse, timeFormat, utcFormat } from 'd3-time-format';
|
|
11
11
|
import { pointer, select, namespaces, selectAll } from 'd3-selection';
|
|
@@ -2672,9 +2672,15 @@ var legend$2 = {
|
|
|
2672
2672
|
* @property {Function} [legend.item.onclick=undefined] Set click event handler to the legend item.
|
|
2673
2673
|
* @property {Function} [legend.item.onover=undefined] Set mouse/touch over event handler to the legend item.
|
|
2674
2674
|
* @property {Function} [legend.item.onout=undefined] Set mouse/touch out event handler to the legend item.
|
|
2675
|
-
* @property {number} [legend.item.tile.width=10] Set width
|
|
2676
|
-
* @property {number} [legend.item.tile.height=10]
|
|
2675
|
+
* @property {number} [legend.item.tile.width=10] Set width for 'rectangle' legend item tile element.
|
|
2676
|
+
* @property {number} [legend.item.tile.height=10] ㄹ
|
|
2677
|
+
* @property {number} [legend.item.tile.r=5] Set the radius for 'circle' legend item tile type.
|
|
2678
|
+
* @property {string} [legend.item.tile.type="rectangle"] Set legend item shape type.<br>
|
|
2679
|
+
* - **Available Values:**
|
|
2680
|
+
* - circle
|
|
2681
|
+
* - rectangle
|
|
2677
2682
|
* @property {boolean} [legend.usePoint=false] Whether to use custom points in legend.
|
|
2683
|
+
* @see [Demo: item.tile.type](https://naver.github.io/billboard.js/demo/#Legend.LegendItemTileType)
|
|
2678
2684
|
* @see [Demo: position](https://naver.github.io/billboard.js/demo/#Legend.LegendPosition)
|
|
2679
2685
|
* @see [Demo: contents.template](https://naver.github.io/billboard.js/demo/#Legend.LegendTemplate1)
|
|
2680
2686
|
* @see [Demo: usePoint](https://naver.github.io/billboard.js/demo/#Legend.usePoint)
|
|
@@ -2714,8 +2720,15 @@ var legend$2 = {
|
|
|
2714
2720
|
*
|
|
2715
2721
|
* // set tile's size
|
|
2716
2722
|
* tile: {
|
|
2717
|
-
*
|
|
2723
|
+
* // set tile type
|
|
2724
|
+
* type: "circle" // or "rectangle" (default)
|
|
2725
|
+
*
|
|
2726
|
+
* // width & height, are only applicable for 'rectangle' legend type
|
|
2727
|
+
* width: 15,
|
|
2718
2728
|
* height: 15
|
|
2729
|
+
*
|
|
2730
|
+
* // radis is only applicable for 'circle' legend type
|
|
2731
|
+
* r: 10
|
|
2719
2732
|
* }
|
|
2720
2733
|
* },
|
|
2721
2734
|
* usePoint: true
|
|
@@ -2737,6 +2750,8 @@ var legend$2 = {
|
|
|
2737
2750
|
legend_padding: 0,
|
|
2738
2751
|
legend_item_tile_width: 10,
|
|
2739
2752
|
legend_item_tile_height: 10,
|
|
2753
|
+
legend_item_tile_r: 5,
|
|
2754
|
+
legend_item_tile_type: "rectangle",
|
|
2740
2755
|
legend_usePoint: false
|
|
2741
2756
|
};
|
|
2742
2757
|
|
|
@@ -5082,6 +5097,45 @@ var color = {
|
|
|
5082
5097
|
});
|
|
5083
5098
|
}
|
|
5084
5099
|
},
|
|
5100
|
+
/**
|
|
5101
|
+
* Get data gradient color url
|
|
5102
|
+
* @param {string} id Data id
|
|
5103
|
+
* @returns {string}
|
|
5104
|
+
* @private
|
|
5105
|
+
*/
|
|
5106
|
+
getGradienColortUrl: function (id) {
|
|
5107
|
+
return "url(#".concat(this.state.datetimeId, "-gradient").concat(this.getTargetSelectorSuffix(id), ")");
|
|
5108
|
+
},
|
|
5109
|
+
/**
|
|
5110
|
+
* Update linear gradient definition (for area & bar only)
|
|
5111
|
+
* @private
|
|
5112
|
+
*/
|
|
5113
|
+
updateLinearGradient: function () {
|
|
5114
|
+
var $$ = this;
|
|
5115
|
+
var config = $$.config, targets = $$.data.targets, datetimeId = $$.state.datetimeId, defs = $$.$el.defs;
|
|
5116
|
+
targets.forEach(function (d) {
|
|
5117
|
+
var id = "".concat(datetimeId, "-gradient").concat($$.getTargetSelectorSuffix(d.id));
|
|
5118
|
+
var supportedType = ($$.isAreaType(d) && "area") || ($$.isBarType(d) && "bar");
|
|
5119
|
+
var isRotated = config.axis_rotated;
|
|
5120
|
+
if (supportedType && defs.select("#".concat(id)).empty()) {
|
|
5121
|
+
var color_1 = $$.color(d);
|
|
5122
|
+
var _a = config["".concat(supportedType, "_linearGradient")], _b = _a.x, x = _b === void 0 ? isRotated ? [1, 0] : [0, 0] : _b, _c = _a.y, y = _c === void 0 ? isRotated ? [0, 0] : [0, 1] : _c, _d = _a.stops, stops = _d === void 0 ? [[0, color_1, 1], [1, color_1, 0]] : _d;
|
|
5123
|
+
var linearGradient_1 = defs.append("linearGradient")
|
|
5124
|
+
.attr("id", "".concat(id))
|
|
5125
|
+
.attr("x1", x[0])
|
|
5126
|
+
.attr("x2", x[1])
|
|
5127
|
+
.attr("y1", y[0])
|
|
5128
|
+
.attr("y2", y[1]);
|
|
5129
|
+
stops.forEach(function (v) {
|
|
5130
|
+
var stopColor = isFunction(v[1]) ? v[1].bind($$.api)(d.id) : v[1];
|
|
5131
|
+
linearGradient_1.append("stop")
|
|
5132
|
+
.attr("offset", v[0])
|
|
5133
|
+
.attr("stop-color", stopColor || color_1)
|
|
5134
|
+
.attr("stop-opacity", v[2]);
|
|
5135
|
+
});
|
|
5136
|
+
}
|
|
5137
|
+
});
|
|
5138
|
+
},
|
|
5085
5139
|
/**
|
|
5086
5140
|
* Set the data over color.
|
|
5087
5141
|
* When is out, will restate in its previous color value
|
|
@@ -5508,6 +5562,20 @@ var format = {
|
|
|
5508
5562
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
5509
5563
|
* billboard.js project is licensed under the MIT license
|
|
5510
5564
|
*/
|
|
5565
|
+
/**
|
|
5566
|
+
* Get color string for given data id
|
|
5567
|
+
* @param {string} id Data id
|
|
5568
|
+
* @returns {string} Color string
|
|
5569
|
+
* @private
|
|
5570
|
+
*/
|
|
5571
|
+
function getLegendColor(id) {
|
|
5572
|
+
var $$ = this;
|
|
5573
|
+
var data = $$.getDataById(id);
|
|
5574
|
+
var color = $$.levelColor ?
|
|
5575
|
+
$$.levelColor(data.values[0].value) :
|
|
5576
|
+
$$.color(data);
|
|
5577
|
+
return color;
|
|
5578
|
+
}
|
|
5511
5579
|
var legend$1 = {
|
|
5512
5580
|
/**
|
|
5513
5581
|
* Initialize the legend.
|
|
@@ -5875,81 +5943,169 @@ var legend$1 = {
|
|
|
5875
5943
|
updateLegendElement: function (targetIds, options) {
|
|
5876
5944
|
var $$ = this;
|
|
5877
5945
|
var config = $$.config, state = $$.state, legend = $$.$el.legend, $T = $$.$T;
|
|
5878
|
-
var
|
|
5879
|
-
var
|
|
5880
|
-
var
|
|
5881
|
-
var
|
|
5882
|
-
|
|
5883
|
-
|
|
5946
|
+
var legendType = config.legend_item_tile_type;
|
|
5947
|
+
var isRectangle = legendType !== "circle";
|
|
5948
|
+
var legendItemR = config.legend_item_tile_r;
|
|
5949
|
+
var itemTileSize = {
|
|
5950
|
+
width: isRectangle ? config.legend_item_tile_width : legendItemR * 2,
|
|
5951
|
+
height: isRectangle ? config.legend_item_tile_height : legendItemR * 2
|
|
5952
|
+
};
|
|
5953
|
+
var dimension = {
|
|
5954
|
+
padding: {
|
|
5955
|
+
top: 4,
|
|
5956
|
+
right: 10
|
|
5957
|
+
},
|
|
5958
|
+
max: {
|
|
5959
|
+
width: 0,
|
|
5960
|
+
height: 0
|
|
5961
|
+
},
|
|
5962
|
+
posMin: 10,
|
|
5963
|
+
step: 0,
|
|
5964
|
+
tileWidth: itemTileSize.width + 5,
|
|
5965
|
+
totalLength: 0
|
|
5966
|
+
};
|
|
5967
|
+
var sizes = {
|
|
5968
|
+
offsets: {},
|
|
5969
|
+
widths: {},
|
|
5970
|
+
heights: {},
|
|
5971
|
+
margins: [0],
|
|
5972
|
+
steps: {}
|
|
5973
|
+
};
|
|
5884
5974
|
var xForLegend;
|
|
5885
5975
|
var yForLegend;
|
|
5886
|
-
var totalLength = 0;
|
|
5887
|
-
var offsets = {};
|
|
5888
|
-
var widths = {};
|
|
5889
|
-
var heights = {};
|
|
5890
|
-
var margins = [0];
|
|
5891
|
-
var steps = {};
|
|
5892
|
-
var step = 0;
|
|
5893
5976
|
var background;
|
|
5894
|
-
var isLegendRightOrInset = state.isLegendRight || state.isLegendInset;
|
|
5895
5977
|
// Skip elements when their name is set to null
|
|
5896
5978
|
var targetIdz = targetIds
|
|
5897
5979
|
.filter(function (id) { return !isDefined(config.data_names[id]) || config.data_names[id] !== null; });
|
|
5898
5980
|
var withTransition = options.withTransition;
|
|
5899
|
-
var updatePositions =
|
|
5981
|
+
var updatePositions = $$.getUpdateLegendPositions(targetIdz, dimension, sizes);
|
|
5982
|
+
if (state.isLegendInset) {
|
|
5983
|
+
dimension.step = config.legend_inset_step ? config.legend_inset_step : targetIdz.length;
|
|
5984
|
+
$$.updateLegendStep(dimension.step);
|
|
5985
|
+
}
|
|
5986
|
+
if (state.isLegendRight) {
|
|
5987
|
+
xForLegend = function (id) { return dimension.max.width * sizes.steps[id]; };
|
|
5988
|
+
yForLegend = function (id) { return sizes.margins[sizes.steps[id]] + sizes.offsets[id]; };
|
|
5989
|
+
}
|
|
5990
|
+
else if (state.isLegendInset) {
|
|
5991
|
+
xForLegend = function (id) { return dimension.max.width * sizes.steps[id] + 10; };
|
|
5992
|
+
yForLegend = function (id) { return sizes.margins[sizes.steps[id]] + sizes.offsets[id]; };
|
|
5993
|
+
}
|
|
5994
|
+
else {
|
|
5995
|
+
xForLegend = function (id) { return sizes.margins[sizes.steps[id]] + sizes.offsets[id]; };
|
|
5996
|
+
yForLegend = function (id) { return dimension.max.height * sizes.steps[id]; };
|
|
5997
|
+
}
|
|
5998
|
+
var posFn = {
|
|
5999
|
+
xText: function (id, i) { return xForLegend(id, i) + 4 + itemTileSize.width; },
|
|
6000
|
+
xRect: function (id, i) { return xForLegend(id, i); },
|
|
6001
|
+
x1Tile: function (id, i) { return xForLegend(id, i) - 2; },
|
|
6002
|
+
x2Tile: function (id, i) { return xForLegend(id, i) - 2 + itemTileSize.width; },
|
|
6003
|
+
yText: function (id, i) { return yForLegend(id, i) + 9; },
|
|
6004
|
+
yRect: function (id, i) { return yForLegend(id, i) - 5; },
|
|
6005
|
+
yTile: function (id, i) { return yForLegend(id, i) + 4; }
|
|
6006
|
+
};
|
|
6007
|
+
$$.generateLegendItem(targetIdz, itemTileSize, updatePositions, posFn);
|
|
6008
|
+
// Set background for inset legend
|
|
6009
|
+
background = legend.select(".".concat($LEGEND.legendBackground, " rect"));
|
|
6010
|
+
if (state.isLegendInset && dimension.max.width > 0 && background.size() === 0) {
|
|
6011
|
+
background = legend.insert("g", ".".concat($LEGEND.legendItem))
|
|
6012
|
+
.attr("class", $LEGEND.legendBackground)
|
|
6013
|
+
.append("rect");
|
|
6014
|
+
}
|
|
6015
|
+
var texts = legend.selectAll("text")
|
|
6016
|
+
.data(targetIdz)
|
|
6017
|
+
.text(function (id) { return (isDefined(config.data_names[id]) ? config.data_names[id] : id); }) // MEMO: needed for update
|
|
6018
|
+
.each(function (id, i) {
|
|
6019
|
+
updatePositions(this, id, i);
|
|
6020
|
+
});
|
|
6021
|
+
$T(texts, withTransition)
|
|
6022
|
+
.attr("x", posFn.xText)
|
|
6023
|
+
.attr("y", posFn.yText);
|
|
6024
|
+
var rects = legend.selectAll("rect.".concat($LEGEND.legendItemEvent))
|
|
6025
|
+
.data(targetIdz);
|
|
6026
|
+
$T(rects, withTransition)
|
|
6027
|
+
.attr("width", function (id) { return sizes.widths[id]; })
|
|
6028
|
+
.attr("height", function (id) { return sizes.heights[id]; })
|
|
6029
|
+
.attr("x", posFn.xRect)
|
|
6030
|
+
.attr("y", posFn.yRect);
|
|
6031
|
+
// update legend items position
|
|
6032
|
+
$$.updateLegendItemPos(targetIdz, withTransition, posFn);
|
|
6033
|
+
if (background) {
|
|
6034
|
+
$T(background, withTransition)
|
|
6035
|
+
.attr("height", $$.getLegendHeight() - 12)
|
|
6036
|
+
.attr("width", dimension.max.width * (dimension.step + 1) + 10);
|
|
6037
|
+
}
|
|
6038
|
+
// Update all to reflect change of legend
|
|
6039
|
+
$$.updateLegendItemWidth(dimension.max.width);
|
|
6040
|
+
$$.updateLegendItemHeight(dimension.max.height);
|
|
6041
|
+
$$.updateLegendStep(dimension.step);
|
|
6042
|
+
},
|
|
6043
|
+
/**
|
|
6044
|
+
* Get position update function
|
|
6045
|
+
* @param {Array} targetIdz Data ids
|
|
6046
|
+
* @param {object} dimension Dimension object
|
|
6047
|
+
* @param {object} sizes Size object
|
|
6048
|
+
* @returns {Function} Update position function
|
|
6049
|
+
* @private
|
|
6050
|
+
*/
|
|
6051
|
+
getUpdateLegendPositions: function (targetIdz, dimension, sizes) {
|
|
6052
|
+
var $$ = this;
|
|
6053
|
+
var config = $$.config, state = $$.state;
|
|
6054
|
+
var isLegendRightOrInset = state.isLegendRight || state.isLegendInset;
|
|
6055
|
+
return function (textElement, id, index) {
|
|
5900
6056
|
var reset = index === 0;
|
|
5901
6057
|
var isLast = index === targetIdz.length - 1;
|
|
5902
6058
|
var box = $$.getLegendItemTextBox(id, textElement);
|
|
5903
|
-
var itemWidth = box.width + tileWidth +
|
|
5904
|
-
(isLast && !isLegendRightOrInset ? 0 :
|
|
5905
|
-
var itemHeight = box.height +
|
|
6059
|
+
var itemWidth = box.width + dimension.tileWidth +
|
|
6060
|
+
(isLast && !isLegendRightOrInset ? 0 : dimension.padding.right) + config.legend_padding;
|
|
6061
|
+
var itemHeight = box.height + dimension.padding.top;
|
|
5906
6062
|
var itemLength = isLegendRightOrInset ? itemHeight : itemWidth;
|
|
5907
6063
|
var areaLength = isLegendRightOrInset ? $$.getLegendHeight() : $$.getLegendWidth();
|
|
5908
6064
|
var margin;
|
|
5909
6065
|
// MEMO: care about condifion of step, totalLength
|
|
5910
6066
|
var updateValues = function (id2, withoutStep) {
|
|
5911
6067
|
if (!withoutStep) {
|
|
5912
|
-
margin = (areaLength - totalLength - itemLength) / 2;
|
|
5913
|
-
if (margin < posMin) {
|
|
6068
|
+
margin = (areaLength - dimension.totalLength - itemLength) / 2;
|
|
6069
|
+
if (margin < dimension.posMin) {
|
|
5914
6070
|
margin = (areaLength - itemLength) / 2;
|
|
5915
|
-
totalLength = 0;
|
|
5916
|
-
step++;
|
|
6071
|
+
dimension.totalLength = 0;
|
|
6072
|
+
dimension.step++;
|
|
5917
6073
|
}
|
|
5918
6074
|
}
|
|
5919
|
-
steps[id2] = step;
|
|
5920
|
-
margins[step] = state.isLegendInset ? 10 : margin;
|
|
5921
|
-
offsets[id2] = totalLength;
|
|
5922
|
-
totalLength += itemLength;
|
|
6075
|
+
sizes.steps[id2] = dimension.step;
|
|
6076
|
+
sizes.margins[dimension.step] = state.isLegendInset ? 10 : margin;
|
|
6077
|
+
sizes.offsets[id2] = dimension.totalLength;
|
|
6078
|
+
dimension.totalLength += itemLength;
|
|
5923
6079
|
};
|
|
5924
6080
|
if (reset) {
|
|
5925
|
-
totalLength = 0;
|
|
5926
|
-
step = 0;
|
|
5927
|
-
|
|
5928
|
-
|
|
6081
|
+
dimension.totalLength = 0;
|
|
6082
|
+
dimension.step = 0;
|
|
6083
|
+
dimension.max.width = 0;
|
|
6084
|
+
dimension.max.height = 0;
|
|
5929
6085
|
}
|
|
5930
6086
|
if (config.legend_show && !$$.isLegendToShow(id)) {
|
|
5931
|
-
widths[id] = 0;
|
|
5932
|
-
heights[id] = 0;
|
|
5933
|
-
steps[id] = 0;
|
|
5934
|
-
offsets[id] = 0;
|
|
6087
|
+
sizes.widths[id] = 0;
|
|
6088
|
+
sizes.heights[id] = 0;
|
|
6089
|
+
sizes.steps[id] = 0;
|
|
6090
|
+
sizes.offsets[id] = 0;
|
|
5935
6091
|
return;
|
|
5936
6092
|
}
|
|
5937
|
-
widths[id] = itemWidth;
|
|
5938
|
-
heights[id] = itemHeight;
|
|
5939
|
-
if (!
|
|
5940
|
-
|
|
6093
|
+
sizes.widths[id] = itemWidth;
|
|
6094
|
+
sizes.heights[id] = itemHeight;
|
|
6095
|
+
if (!dimension.max.width || itemWidth >= dimension.max.width) {
|
|
6096
|
+
dimension.max.width = itemWidth;
|
|
5941
6097
|
}
|
|
5942
|
-
if (!
|
|
5943
|
-
|
|
6098
|
+
if (!dimension.max.height || itemHeight >= dimension.max.height) {
|
|
6099
|
+
dimension.max.height = itemHeight;
|
|
5944
6100
|
}
|
|
5945
|
-
var maxLength = isLegendRightOrInset ?
|
|
6101
|
+
var maxLength = isLegendRightOrInset ? dimension.max.height : dimension.max.width;
|
|
5946
6102
|
if (config.legend_equally) {
|
|
5947
|
-
Object.keys(widths).forEach(function (id2) { return (widths[id2] =
|
|
5948
|
-
Object.keys(heights).forEach(function (id2) { return (heights[id2] =
|
|
6103
|
+
Object.keys(sizes.widths).forEach(function (id2) { return (sizes.widths[id2] = dimension.max.width); });
|
|
6104
|
+
Object.keys(sizes.heights).forEach(function (id2) { return (sizes.heights[id2] = dimension.max.height); });
|
|
5949
6105
|
margin = (areaLength - maxLength * targetIdz.length) / 2;
|
|
5950
|
-
if (margin < posMin) {
|
|
5951
|
-
totalLength = 0;
|
|
5952
|
-
step = 0;
|
|
6106
|
+
if (margin < dimension.posMin) {
|
|
6107
|
+
dimension.totalLength = 0;
|
|
6108
|
+
dimension.step = 0;
|
|
5953
6109
|
targetIdz.forEach(function (id2) { return updateValues(id2); });
|
|
5954
6110
|
}
|
|
5955
6111
|
else {
|
|
@@ -5960,29 +6116,23 @@ var legend$1 = {
|
|
|
5960
6116
|
updateValues(id);
|
|
5961
6117
|
}
|
|
5962
6118
|
};
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
var
|
|
5980
|
-
var xForLegendRect = function (id, i) { return xForLegend(id, i); };
|
|
5981
|
-
var x1ForLegendTile = function (id, i) { return xForLegend(id, i) - 2; };
|
|
5982
|
-
var x2ForLegendTile = function (id, i) { return xForLegend(id, i) - 2 + config.legend_item_tile_width; };
|
|
5983
|
-
var yForLegendText = function (id, i) { return yForLegend(id, i) + 9; };
|
|
5984
|
-
var yForLegendRect = function (id, i) { return yForLegend(id, i) - 5; };
|
|
5985
|
-
var yForLegendTile = function (id, i) { return yForLegend(id, i) + 4; };
|
|
6119
|
+
},
|
|
6120
|
+
/**
|
|
6121
|
+
* Generate legend item elements
|
|
6122
|
+
* @param {Array} targetIdz Data ids
|
|
6123
|
+
* @param {object} itemTileSize Item tile size {width, height}
|
|
6124
|
+
* @param {Function} updatePositions Update position function
|
|
6125
|
+
* @param {object} posFn Position functions
|
|
6126
|
+
* @private
|
|
6127
|
+
*/
|
|
6128
|
+
generateLegendItem: function (targetIdz, itemTileSize, updatePositions, posFn) {
|
|
6129
|
+
var $$ = this;
|
|
6130
|
+
var config = $$.config, state = $$.state, legend = $$.$el.legend;
|
|
6131
|
+
var usePoint = config.legend_usePoint;
|
|
6132
|
+
var legendItemR = config.legend_item_tile_r;
|
|
6133
|
+
var legendType = config.legend_item_tile_type;
|
|
6134
|
+
var isRectangle = legendType !== "circle";
|
|
6135
|
+
var isLegendRightOrInset = state.isLegendRight || state.isLegendInset;
|
|
5986
6136
|
var pos = -200;
|
|
5987
6137
|
// Define g for legend area
|
|
5988
6138
|
var l = legend.selectAll(".".concat($LEGEND.legendItem))
|
|
@@ -5996,21 +6146,13 @@ var legend$1 = {
|
|
|
5996
6146
|
updatePositions(this, id, i);
|
|
5997
6147
|
})
|
|
5998
6148
|
.style("pointer-events", $$.getStylePropValue("none"))
|
|
5999
|
-
.attr("x", isLegendRightOrInset ?
|
|
6000
|
-
.attr("y", isLegendRightOrInset ? pos :
|
|
6149
|
+
.attr("x", isLegendRightOrInset ? posFn.xText : pos)
|
|
6150
|
+
.attr("y", isLegendRightOrInset ? pos : posFn.yText);
|
|
6001
6151
|
l.append("rect")
|
|
6002
6152
|
.attr("class", $LEGEND.legendItemEvent)
|
|
6003
6153
|
.style("fill-opacity", $$.getStylePropValue("0"))
|
|
6004
|
-
.attr("x", isLegendRightOrInset ?
|
|
6005
|
-
.attr("y", isLegendRightOrInset ? pos :
|
|
6006
|
-
var getColor = function (id) {
|
|
6007
|
-
var data = $$.getDataById(id);
|
|
6008
|
-
var color = $$.levelColor ?
|
|
6009
|
-
$$.levelColor(data.values[0].value) :
|
|
6010
|
-
$$.color(data);
|
|
6011
|
-
return color;
|
|
6012
|
-
};
|
|
6013
|
-
var usePoint = config.legend_usePoint;
|
|
6154
|
+
.attr("x", isLegendRightOrInset ? posFn.xRect : pos)
|
|
6155
|
+
.attr("y", isLegendRightOrInset ? pos : posFn.yRect);
|
|
6014
6156
|
if (usePoint) {
|
|
6015
6157
|
var ids_2 = [];
|
|
6016
6158
|
l.append(function (d) {
|
|
@@ -6024,7 +6166,7 @@ var legend$1 = {
|
|
|
6024
6166
|
return doc.createElementNS(namespaces.svg, ("hasValidPointType" in $$) && $$.hasValidPointType(point) ? point : "use");
|
|
6025
6167
|
})
|
|
6026
6168
|
.attr("class", $LEGEND.legendItemPoint)
|
|
6027
|
-
.style("fill",
|
|
6169
|
+
.style("fill", getLegendColor.bind($$))
|
|
6028
6170
|
.style("pointer-events", $$.getStylePropValue("none"))
|
|
6029
6171
|
.attr("href", function (data, idx, selection) {
|
|
6030
6172
|
var node = selection[idx];
|
|
@@ -6034,39 +6176,42 @@ var legend$1 = {
|
|
|
6034
6176
|
});
|
|
6035
6177
|
}
|
|
6036
6178
|
else {
|
|
6037
|
-
l.append("line")
|
|
6179
|
+
l.append(isRectangle ? "line" : legendType)
|
|
6038
6180
|
.attr("class", $LEGEND.legendItemTile)
|
|
6039
|
-
.style("stroke",
|
|
6181
|
+
.style("stroke", getLegendColor.bind($$))
|
|
6040
6182
|
.style("pointer-events", $$.getStylePropValue("none"))
|
|
6041
|
-
.
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6183
|
+
.call(function (selection) {
|
|
6184
|
+
if (legendType === "circle") {
|
|
6185
|
+
selection
|
|
6186
|
+
.attr("r", legendItemR)
|
|
6187
|
+
.style("fill", getLegendColor.bind($$))
|
|
6188
|
+
.attr("cx", isLegendRightOrInset ? posFn.x2Tile : pos)
|
|
6189
|
+
.attr("cy", isLegendRightOrInset ? pos : posFn.yTile);
|
|
6190
|
+
}
|
|
6191
|
+
else if (isRectangle) {
|
|
6192
|
+
selection
|
|
6193
|
+
.attr("stroke-width", itemTileSize.height)
|
|
6194
|
+
.attr("x1", isLegendRightOrInset ? posFn.x1Tile : pos)
|
|
6195
|
+
.attr("y1", isLegendRightOrInset ? pos : posFn.yTile)
|
|
6196
|
+
.attr("x2", isLegendRightOrInset ? posFn.x2Tile : pos)
|
|
6197
|
+
.attr("y2", isLegendRightOrInset ? pos : posFn.yTile);
|
|
6198
|
+
}
|
|
6199
|
+
});
|
|
6053
6200
|
}
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
var
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
.attr("x", xForLegendRect)
|
|
6069
|
-
.attr("y", yForLegendRect);
|
|
6201
|
+
},
|
|
6202
|
+
/**
|
|
6203
|
+
* Update legend item position
|
|
6204
|
+
* @param {Array} targetIdz Data ids
|
|
6205
|
+
* @param {boolean} withTransition Whether or not to apply transition
|
|
6206
|
+
* @param {object} posFn Position functions
|
|
6207
|
+
* @private
|
|
6208
|
+
*/
|
|
6209
|
+
updateLegendItemPos: function (targetIdz, withTransition, posFn) {
|
|
6210
|
+
var $$ = this;
|
|
6211
|
+
var config = $$.config, legend = $$.$el.legend, $T = $$.$T;
|
|
6212
|
+
var usePoint = config.legend_usePoint;
|
|
6213
|
+
var legendType = config.legend_item_tile_type;
|
|
6214
|
+
var isRectangle = legendType !== "circle";
|
|
6070
6215
|
if (usePoint) {
|
|
6071
6216
|
var tiles = legend.selectAll(".".concat($LEGEND.legendItemPoint))
|
|
6072
6217
|
.data(targetIdz);
|
|
@@ -6078,9 +6223,9 @@ var legend$1 = {
|
|
|
6078
6223
|
var y = "y";
|
|
6079
6224
|
var xOffset = 2;
|
|
6080
6225
|
var yOffset = 2.5;
|
|
6081
|
-
var radius;
|
|
6082
|
-
var width;
|
|
6083
|
-
var height;
|
|
6226
|
+
var radius = null;
|
|
6227
|
+
var width = null;
|
|
6228
|
+
var height = null;
|
|
6084
6229
|
if (nodeName === "circle") {
|
|
6085
6230
|
var size = pointR * 0.2;
|
|
6086
6231
|
x = "cx";
|
|
@@ -6096,32 +6241,36 @@ var legend$1 = {
|
|
|
6096
6241
|
yOffset = 3;
|
|
6097
6242
|
}
|
|
6098
6243
|
select(this)
|
|
6099
|
-
.attr(x, function (d) { return
|
|
6100
|
-
.attr(y, function (d) { return
|
|
6244
|
+
.attr(x, function (d) { return posFn.x1Tile(d) + xOffset; })
|
|
6245
|
+
.attr(y, function (d) { return posFn.yTile(d) - yOffset; })
|
|
6101
6246
|
.attr("r", radius)
|
|
6102
6247
|
.attr("width", width)
|
|
6103
6248
|
.attr("height", height);
|
|
6104
6249
|
});
|
|
6105
6250
|
}
|
|
6106
6251
|
else {
|
|
6107
|
-
var tiles = legend.selectAll("
|
|
6252
|
+
var tiles = legend.selectAll(".".concat($LEGEND.legendItemTile))
|
|
6108
6253
|
.data(targetIdz);
|
|
6109
6254
|
$T(tiles, withTransition)
|
|
6110
|
-
.style("stroke",
|
|
6111
|
-
.
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6255
|
+
.style("stroke", getLegendColor.bind($$))
|
|
6256
|
+
.call(function (selection) {
|
|
6257
|
+
if (legendType === "circle") {
|
|
6258
|
+
selection
|
|
6259
|
+
.attr("cx", function (d) {
|
|
6260
|
+
var x2 = posFn.x2Tile(d);
|
|
6261
|
+
return x2 - ((x2 - posFn.x1Tile(d)) / 2);
|
|
6262
|
+
})
|
|
6263
|
+
.attr("cy", posFn.yTile);
|
|
6264
|
+
}
|
|
6265
|
+
else if (isRectangle) {
|
|
6266
|
+
selection
|
|
6267
|
+
.attr("x1", posFn.x1Tile)
|
|
6268
|
+
.attr("y1", posFn.yTile)
|
|
6269
|
+
.attr("x2", posFn.x2Tile)
|
|
6270
|
+
.attr("y2", posFn.yTile);
|
|
6271
|
+
}
|
|
6272
|
+
});
|
|
6120
6273
|
}
|
|
6121
|
-
// Update all to reflect change of legend
|
|
6122
|
-
$$.updateLegendItemWidth(maxWidth);
|
|
6123
|
-
$$.updateLegendItemHeight(maxHeight);
|
|
6124
|
-
$$.updateLegendStep(step);
|
|
6125
6274
|
}
|
|
6126
6275
|
};
|
|
6127
6276
|
|
|
@@ -16684,35 +16833,16 @@ var shapeArea = {
|
|
|
16684
16833
|
.insert("g", ".".concat(config.area_front ? $CIRCLE.circles : $LINE.lines))
|
|
16685
16834
|
.attr("class", $$.getClass("areas", true));
|
|
16686
16835
|
},
|
|
16687
|
-
|
|
16688
|
-
|
|
16689
|
-
|
|
16690
|
-
|
|
16691
|
-
|
|
16692
|
-
|
|
16693
|
-
var color_1 = $$.color(d);
|
|
16694
|
-
var _a = config.area_linearGradient, _b = _a.x, x = _b === void 0 ? [0, 0] : _b, _c = _a.y, y = _c === void 0 ? [0, 1] : _c, _d = _a.stops, stops = _d === void 0 ? [[0, color_1, 1], [1, color_1, 0]] : _d;
|
|
16695
|
-
var linearGradient_1 = defs.append("linearGradient")
|
|
16696
|
-
.attr("id", "".concat(id))
|
|
16697
|
-
.attr("x1", x[0])
|
|
16698
|
-
.attr("x2", x[1])
|
|
16699
|
-
.attr("y1", y[0])
|
|
16700
|
-
.attr("y2", y[1]);
|
|
16701
|
-
stops.forEach(function (v) {
|
|
16702
|
-
var stopColor = isFunction(v[1]) ? v[1].bind($$.api)(d.id) : v[1];
|
|
16703
|
-
linearGradient_1.append("stop")
|
|
16704
|
-
.attr("offset", v[0])
|
|
16705
|
-
.attr("stop-color", stopColor || color_1)
|
|
16706
|
-
.attr("stop-opacity", v[2]);
|
|
16707
|
-
});
|
|
16708
|
-
}
|
|
16709
|
-
});
|
|
16710
|
-
},
|
|
16836
|
+
/**
|
|
16837
|
+
* Update area color
|
|
16838
|
+
* @param {object} d Data object
|
|
16839
|
+
* @returns {string} Color string
|
|
16840
|
+
* @private
|
|
16841
|
+
*/
|
|
16711
16842
|
updateAreaColor: function (d) {
|
|
16712
16843
|
var $$ = this;
|
|
16713
16844
|
return $$.config.area_linearGradient ?
|
|
16714
|
-
|
|
16715
|
-
$$.color(d);
|
|
16845
|
+
$$.getGradienColortUrl(d.id) : $$.color(d);
|
|
16716
16846
|
},
|
|
16717
16847
|
/**
|
|
16718
16848
|
* Generate/Update elements
|
|
@@ -16725,7 +16855,7 @@ var shapeArea = {
|
|
|
16725
16855
|
var $$ = this;
|
|
16726
16856
|
var config = $$.config, state = $$.state, $el = $$.$el, $T = $$.$T;
|
|
16727
16857
|
var $root = isSub ? $el.subchart : $el;
|
|
16728
|
-
config.area_linearGradient && $$.
|
|
16858
|
+
config.area_linearGradient && $$.updateLinearGradient();
|
|
16729
16859
|
var area = $root.main.selectAll(".".concat($AREA.areas))
|
|
16730
16860
|
.selectAll(".".concat($AREA.area))
|
|
16731
16861
|
.data($$.lineData.bind($$));
|
|
@@ -16894,10 +17024,11 @@ var shapeBar = {
|
|
|
16894
17024
|
updateBar: function (withTransition, isSub) {
|
|
16895
17025
|
if (isSub === void 0) { isSub = false; }
|
|
16896
17026
|
var $$ = this;
|
|
16897
|
-
var $el = $$.$el, $T = $$.$T;
|
|
17027
|
+
var config = $$.config, $el = $$.$el, $T = $$.$T;
|
|
16898
17028
|
var $root = isSub ? $el.subchart : $el;
|
|
16899
17029
|
var classBar = $$.getClass("bar", true);
|
|
16900
17030
|
var initialOpacity = $$.initialOpacity.bind($$);
|
|
17031
|
+
config.bar_linearGradient && $$.updateLinearGradient();
|
|
16901
17032
|
var bar = $root.main.selectAll(".".concat($BAR.bars))
|
|
16902
17033
|
.selectAll(".".concat($BAR.bar))
|
|
16903
17034
|
.data($$.labelishData.bind($$));
|
|
@@ -16906,16 +17037,29 @@ var shapeBar = {
|
|
|
16906
17037
|
.remove();
|
|
16907
17038
|
$root.bar = bar.enter().append("path")
|
|
16908
17039
|
.attr("class", classBar)
|
|
16909
|
-
.style("fill", $$.
|
|
17040
|
+
.style("fill", $$.updateBarColor.bind($$))
|
|
16910
17041
|
.merge(bar)
|
|
16911
17042
|
.style("opacity", initialOpacity);
|
|
16912
17043
|
},
|
|
17044
|
+
/**
|
|
17045
|
+
* Update bar color
|
|
17046
|
+
* @param {object} d Data object
|
|
17047
|
+
* @returns {string} Color string
|
|
17048
|
+
* @private
|
|
17049
|
+
*/
|
|
17050
|
+
updateBarColor: function (d) {
|
|
17051
|
+
var $$ = this;
|
|
17052
|
+
var fn = $$.getStylePropValue($$.color);
|
|
17053
|
+
return $$.config.bar_linearGradient ?
|
|
17054
|
+
$$.getGradienColortUrl(d.id) : (fn ? fn(d) : null);
|
|
17055
|
+
},
|
|
16913
17056
|
/**
|
|
16914
17057
|
* Redraw function
|
|
16915
17058
|
* @param {Function} drawFn Retuned function from .getDrawShape() => .generateDrawBar()
|
|
16916
17059
|
* @param {boolean} withTransition With or without transition
|
|
16917
17060
|
* @param {boolean} isSub Subchart draw
|
|
16918
17061
|
* @returns {Array}
|
|
17062
|
+
* @private
|
|
16919
17063
|
*/
|
|
16920
17064
|
redrawBar: function (drawFn, withTransition, isSub) {
|
|
16921
17065
|
if (isSub === void 0) { isSub = false; }
|
|
@@ -16924,7 +17068,7 @@ var shapeBar = {
|
|
|
16924
17068
|
return [
|
|
16925
17069
|
$$.$T(bar, withTransition, getRandom())
|
|
16926
17070
|
.attr("d", function (d) { return (isNumber(d.value) || $$.isBarRangeType(d)) && drawFn(d); })
|
|
16927
|
-
.style("fill", $$.
|
|
17071
|
+
.style("fill", $$.updateBarColor.bind($$))
|
|
16928
17072
|
.style("opacity", null)
|
|
16929
17073
|
];
|
|
16930
17074
|
},
|
|
@@ -18777,6 +18921,11 @@ var optBar = {
|
|
|
18777
18921
|
* @property {object} bar Bar object
|
|
18778
18922
|
* @property {number} [bar.indices.removeNull=false] Remove nullish data on bar indices positions.
|
|
18779
18923
|
* @property {number} [bar.label.threshold=0] Set threshold ratio to show/hide labels.
|
|
18924
|
+
* @property {boolean|object} [bar.linearGradient=false] Set the linear gradient on bar.<br><br>
|
|
18925
|
+
* Or customize by giving below object value:
|
|
18926
|
+
* - x {Array}: `x1`, `x2` value
|
|
18927
|
+
* - y {Array}: `y1`, `y2` value
|
|
18928
|
+
* - stops {Array}: Each item should be having `[offset, stop-color, stop-opacity]` values.
|
|
18780
18929
|
* @property {boolean} [bar.overlap=false] Bars will be rendered at same position, which will be overlapped each other. (for non-grouped bars only)
|
|
18781
18930
|
* @property {number} [bar.padding=0] The padding pixel value between each bar.
|
|
18782
18931
|
* @property {number} [bar.radius] Set the radius of bar edge in pixel.
|
|
@@ -18805,6 +18954,30 @@ var optBar = {
|
|
|
18805
18954
|
* removeNull: true
|
|
18806
18955
|
* },
|
|
18807
18956
|
*
|
|
18957
|
+
* // will generate follwing linearGradient:
|
|
18958
|
+
* // <linearGradient x1="0" x2="0" y1="0" y2="1">
|
|
18959
|
+
* // <stop offset="0" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
|
|
18960
|
+
* // <stop offset="1" stop-color="$DATA_COLOR" stop-opacity="0"></stop>
|
|
18961
|
+
* // </linearGradient>
|
|
18962
|
+
* linearGradient: true,
|
|
18963
|
+
*
|
|
18964
|
+
* // Or customized gradient
|
|
18965
|
+
* linearGradient: {
|
|
18966
|
+
* x: [0, 0], // x1, x2 attributes
|
|
18967
|
+
* y: [0, 0], // y1, y2 attributes
|
|
18968
|
+
* stops: [
|
|
18969
|
+
* // offset, stop-color, stop-opacity
|
|
18970
|
+
* [0, "#7cb5ec", 1],
|
|
18971
|
+
*
|
|
18972
|
+
* // setting 'null' for stop-color, will set its original data color
|
|
18973
|
+
* [0.5, null, 0],
|
|
18974
|
+
*
|
|
18975
|
+
* // setting 'function' for stop-color, will pass data id as argument.
|
|
18976
|
+
* // It should return color string or null value
|
|
18977
|
+
* [1, function(id) { return id === "data1" ? "red" : "blue"; }, 0],
|
|
18978
|
+
* ]
|
|
18979
|
+
* },
|
|
18980
|
+
*
|
|
18808
18981
|
* // remove nullish da
|
|
18809
18982
|
* overlap: true,
|
|
18810
18983
|
*
|
|
@@ -18847,6 +19020,7 @@ var optBar = {
|
|
|
18847
19020
|
* }
|
|
18848
19021
|
*/
|
|
18849
19022
|
bar_label_threshold: 0,
|
|
19023
|
+
bar_linearGradient: false,
|
|
18850
19024
|
bar_indices_removeNull: false,
|
|
18851
19025
|
bar_overlap: false,
|
|
18852
19026
|
bar_padding: 0,
|
|
@@ -21252,7 +21426,7 @@ var zoomModule = function () {
|
|
|
21252
21426
|
var defaults = {};
|
|
21253
21427
|
/**
|
|
21254
21428
|
* @namespace bb
|
|
21255
|
-
* @version 3.6.0
|
|
21429
|
+
* @version 3.6.0
|
|
21256
21430
|
*/
|
|
21257
21431
|
var bb = {
|
|
21258
21432
|
/**
|
|
@@ -21262,7 +21436,7 @@ var bb = {
|
|
|
21262
21436
|
* bb.version; // "1.0.0"
|
|
21263
21437
|
* @memberof bb
|
|
21264
21438
|
*/
|
|
21265
|
-
version: "3.6.0
|
|
21439
|
+
version: "3.6.0",
|
|
21266
21440
|
/**
|
|
21267
21441
|
* Generate chart
|
|
21268
21442
|
* - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
|