sea-chart 2.0.25-alpha.1 → 2.0.25-alpha.3
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.
|
@@ -649,10 +649,11 @@ class ChartComponent extends _react.Component {
|
|
|
649
649
|
this.setContinuousLegend = _ref => {
|
|
650
650
|
var _this$chart$node2;
|
|
651
651
|
let {
|
|
652
|
+
previewType,
|
|
653
|
+
theme,
|
|
652
654
|
colorRange = [],
|
|
653
655
|
legendDirection,
|
|
654
656
|
legendSize,
|
|
655
|
-
legendTextColor,
|
|
656
657
|
legendTextRange,
|
|
657
658
|
bubbleColor,
|
|
658
659
|
type
|
|
@@ -669,7 +670,7 @@ class ChartComponent extends _react.Component {
|
|
|
669
670
|
if (type !== _constants.CHART_TYPE.MAP_BUBBLE) {
|
|
670
671
|
var _this$chart$node;
|
|
671
672
|
// add linearGradient
|
|
672
|
-
const gradient = this.chart.append('defs').attr('class', 'linear-gradient-wrapper').append('linearGradient').attr("id", "gradient-".concat((_this$chart$node = this.chart.node()) === null || _this$chart$node === void 0 ? void 0 : _this$chart$node.id)).attr("x1", '0%').attr("y1", '0%').attr("x2", legendDirection === 'vertical' ? '0%' : '100%').attr("y2", legendDirection === 'vertical' ? '100%' : '0%');
|
|
673
|
+
const gradient = this.chart.append('defs').attr('class', 'linear-gradient-wrapper').append('linearGradient').attr("id", "gradient-".concat((_this$chart$node = this.chart.node()) === null || _this$chart$node === void 0 ? void 0 : _this$chart$node.id, "-").concat(previewType)).attr("x1", '0%').attr("y1", '0%').attr("x2", legendDirection === 'vertical' ? '0%' : '100%').attr("y2", legendDirection === 'vertical' ? '100%' : '0%');
|
|
673
674
|
gradient.append('stop').attr('offset', '0%').attr('stop-color', "".concat(colorRange[0]));
|
|
674
675
|
gradient.append('stop').attr('offset', '50%').attr('stop-color', "".concat(colorRange[4]));
|
|
675
676
|
gradient.append('stop').attr('offset', '100%').attr('stop-color', "".concat(colorRange[8]));
|
|
@@ -677,19 +678,19 @@ class ChartComponent extends _react.Component {
|
|
|
677
678
|
|
|
678
679
|
// add legend
|
|
679
680
|
const continuousLegendWrapper = this.chart.append('g').attr('class', 'legend-continuous-wrapper').attr('transform', "translate(".concat(insertPadding, ", ").concat(chartHeight - legendRectHeight - legendTextHeightSpace, ")"));
|
|
680
|
-
continuousLegendWrapper.append('rect').attr('width', legendRectWidth).attr('height', legendRectHeight).attr('fill', type === _constants.CHART_TYPE.MAP_BUBBLE ? bubbleColor : "url(#gradient-".concat((_this$chart$node2 = this.chart.node()) === null || _this$chart$node2 === void 0 ? void 0 : _this$chart$node2.id, ")")).call(g => {
|
|
681
|
+
continuousLegendWrapper.append('rect').attr('width', legendRectWidth).attr('height', legendRectHeight).attr('fill', type === _constants.CHART_TYPE.MAP_BUBBLE ? bubbleColor : "url(#gradient-".concat((_this$chart$node2 = this.chart.node()) === null || _this$chart$node2 === void 0 ? void 0 : _this$chart$node2.id, ")-").concat(previewType)).call(g => {
|
|
681
682
|
if (type === _constants.CHART_TYPE.MAP_BUBBLE) {
|
|
682
683
|
continuousLegendWrapper.append('polygon').attr('points', "0,0 ".concat(legendRectWidth, ",0 0,").concat(legendRectHeight)).attr('fill', '#fff').attr('stroke', '#fff');
|
|
683
684
|
}
|
|
684
685
|
});
|
|
685
|
-
continuousLegendWrapper.append('text').attr('class', 'range-start').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill',
|
|
686
|
+
continuousLegendWrapper.append('text').attr('class', 'range-start').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).text(legendTextRange[0]).call(g => {
|
|
686
687
|
const {
|
|
687
688
|
height
|
|
688
689
|
} = g.node().getBoundingClientRect();
|
|
689
690
|
g.attr('x', legendDirection === 'vertical' ? legendRectWidth + legendTextOffset : legendTextOffset);
|
|
690
691
|
g.attr('y', legendDirection === 'vertical' ? height : height + legendRectHeight);
|
|
691
692
|
});
|
|
692
|
-
continuousLegendWrapper.append('text').attr('class', 'range-end').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill',
|
|
693
|
+
continuousLegendWrapper.append('text').attr('class', 'range-end').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).text(legendTextRange[1]).call(g => {
|
|
693
694
|
const {
|
|
694
695
|
width,
|
|
695
696
|
height
|
|
@@ -96,16 +96,18 @@ class MapBubble extends _chartComponent.default {
|
|
|
96
96
|
};
|
|
97
97
|
this.draw = (data, mapJson) => {
|
|
98
98
|
const {
|
|
99
|
-
chart
|
|
99
|
+
chart,
|
|
100
|
+
globalTheme,
|
|
101
|
+
canvasStyle
|
|
100
102
|
} = this.props;
|
|
103
|
+
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
101
104
|
const {
|
|
102
105
|
map_level = _constants.MAP_LEVEL.COUNTRY,
|
|
103
|
-
data_color,
|
|
104
106
|
legend_size,
|
|
105
107
|
legend_direction,
|
|
106
108
|
summary_method,
|
|
107
109
|
type,
|
|
108
|
-
bubble_color
|
|
110
|
+
bubble_color = '#2a67d1'
|
|
109
111
|
} = chart.config;
|
|
110
112
|
const {
|
|
111
113
|
width: chartWidth,
|
|
@@ -131,9 +133,10 @@ class MapBubble extends _chartComponent.default {
|
|
|
131
133
|
// draw legend
|
|
132
134
|
const columnData = this.getColumnData();
|
|
133
135
|
this.setContinuousLegend({
|
|
136
|
+
previewType: canvasStyle.previewType,
|
|
137
|
+
theme,
|
|
134
138
|
legendDirection: legend_direction,
|
|
135
139
|
legendSize: legend_size,
|
|
136
|
-
legendTextColor: data_color,
|
|
137
140
|
legendTextRange: [_utils.BaseUtils.getSummaryValueDisplayString(columnData, d3.min(data, d => d.value), summary_method), _utils.BaseUtils.getSummaryValueDisplayString(columnData, d3.max(data, d => d.value), summary_method)],
|
|
138
141
|
type,
|
|
139
142
|
bubbleColor: bubble_color
|
|
@@ -168,7 +171,7 @@ class MapBubble extends _chartComponent.default {
|
|
|
168
171
|
chart
|
|
169
172
|
} = this.props;
|
|
170
173
|
const {
|
|
171
|
-
bubble_color
|
|
174
|
+
bubble_color = '#2a67d1'
|
|
172
175
|
} = chart.config;
|
|
173
176
|
const circleData = [];
|
|
174
177
|
mapData.features.forEach(item => {
|
|
@@ -195,7 +198,7 @@ class MapBubble extends _chartComponent.default {
|
|
|
195
198
|
const percent = value / data.sum;
|
|
196
199
|
let size = percent * 100;
|
|
197
200
|
return size;
|
|
198
|
-
}).attr('fill', bubble_color
|
|
201
|
+
}).attr('fill', bubble_color).attr('fill-opacity', 0.6).attr('stroke', bubble_color).attr('stroke-opacity', 0.9).attr('data-value', value).attr('data-name', name).on('click', event => {
|
|
199
202
|
const name = event.target.getAttribute('data-name');
|
|
200
203
|
const newData = data.find(item => item.name.includes(name));
|
|
201
204
|
newData && this.props.toggleRecords(newData);
|
package/dist/view/wrapper/map.js
CHANGED
|
@@ -97,8 +97,11 @@ class Map extends _chartComponent.default {
|
|
|
97
97
|
};
|
|
98
98
|
this.draw = (data, mapJson) => {
|
|
99
99
|
const {
|
|
100
|
-
chart
|
|
100
|
+
chart,
|
|
101
|
+
globalTheme,
|
|
102
|
+
canvasStyle
|
|
101
103
|
} = this.props;
|
|
104
|
+
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
102
105
|
const {
|
|
103
106
|
map_level = _constants.MAP_LEVEL.COUNTRY,
|
|
104
107
|
data_color,
|
|
@@ -172,10 +175,11 @@ class Map extends _chartComponent.default {
|
|
|
172
175
|
});
|
|
173
176
|
const columnData = this.getColumnData();
|
|
174
177
|
this.setContinuousLegend({
|
|
178
|
+
previewType: canvasStyle.previewType,
|
|
179
|
+
theme,
|
|
175
180
|
colorRange: exampleColors,
|
|
176
181
|
legendDirection: legend_direction,
|
|
177
182
|
legendSize: legend_size,
|
|
178
|
-
legendTextColor: data_color,
|
|
179
183
|
legendTextRange: [_utils.BaseUtils.getSummaryValueDisplayString(columnData, minVal, summary_method), _utils.BaseUtils.getSummaryValueDisplayString(columnData, maxVal, summary_method)]
|
|
180
184
|
});
|
|
181
185
|
};
|