onesight-charts 0.2.6 → 0.2.8

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.
@@ -4,13 +4,21 @@ import React, { useEffect, useRef } from 'react';
4
4
  import { createCustomTooltip } from "./tooltipConfig";
5
5
  import "./style.scss";
6
6
  function WordCloud(props) {
7
- var data = props.data,
7
+ var _props$width = props.width,
8
+ width = _props$width === void 0 ? '100%' : _props$width,
9
+ _props$height = props.height,
10
+ height = _props$height === void 0 ? '312px' : _props$height,
11
+ data = props.data,
8
12
  _props$smallSize = props.smallSize,
9
13
  smallSize = _props$smallSize === void 0 ? false : _props$smallSize,
10
14
  _props$tooltipShow = props.tooltipShow,
11
15
  tooltipShow = _props$tooltipShow === void 0 ? true : _props$tooltipShow,
12
16
  _props$tooltipName = props.tooltipName,
13
- tooltipName = _props$tooltipName === void 0 ? '提及数' : _props$tooltipName;
17
+ tooltipName = _props$tooltipName === void 0 ? '提及数' : _props$tooltipName,
18
+ _props$color = props.color,
19
+ color = _props$color === void 0 ? '#1DA9A0' : _props$color,
20
+ _props$onClick = props.onClick,
21
+ onClick = _props$onClick === void 0 ? function () {} : _props$onClick;
14
22
  var chartRef = useRef();
15
23
  useEffect(function () {
16
24
  createChart();
@@ -31,7 +39,7 @@ function WordCloud(props) {
31
39
  left: 'center',
32
40
  top: 'center',
33
41
  width: smallSize ? '90%' : '100%',
34
- height: '100%',
42
+ height: '95%',
35
43
  right: null,
36
44
  bottom: null,
37
45
  sizeRange: smallSize ? [15, 40] : [18, 80],
@@ -43,7 +51,7 @@ function WordCloud(props) {
43
51
  textStyle: {
44
52
  fontFamily: 'Verdana',
45
53
  fontWeight: 500,
46
- color: '#1DA9A0'
54
+ color: color
47
55
  },
48
56
  emphasis: {
49
57
  focus: 'self'
@@ -57,12 +65,17 @@ function WordCloud(props) {
57
65
  }]
58
66
  };
59
67
  myChart.setOption(option);
68
+ // 取消监听点击事件,也可以防止重复绑定
69
+ myChart.off('click');
70
+ myChart.on('click', function (param) {
71
+ onClick(param);
72
+ });
60
73
  };
61
74
  return /*#__PURE__*/React.createElement("div", {
62
75
  ref: chartRef,
63
76
  style: {
64
- width: '100%',
65
- height: '312px'
77
+ width: width,
78
+ height: height
66
79
  }
67
80
  });
68
81
  }
@@ -39,17 +39,22 @@ var import_tooltipConfig = require("./tooltipConfig");
39
39
  var import_style = require("./style.scss");
40
40
  function WordCloud(props) {
41
41
  const {
42
+ width = "100%",
43
+ height = "312px",
42
44
  data,
43
45
  smallSize = false,
44
46
  tooltipShow = true,
45
- tooltipName = "提及数"
47
+ tooltipName = "提及数",
48
+ color = "#1DA9A0",
49
+ onClick = () => {
50
+ }
46
51
  } = props;
47
52
  const chartRef = (0, import_react.useRef)();
48
53
  (0, import_react.useEffect)(() => {
49
54
  createChart();
50
55
  }, [JSON.stringify(data)]);
51
56
  const createChart = () => {
52
- let myChart = echarts.init(chartRef.current);
57
+ const myChart = echarts.init(chartRef.current);
53
58
  const tooltipConfig = (0, import_tooltipConfig.createCustomTooltip)({
54
59
  tooltipShow,
55
60
  smallSize,
@@ -65,7 +70,7 @@ function WordCloud(props) {
65
70
  left: "center",
66
71
  top: "center",
67
72
  width: smallSize ? "90%" : "100%",
68
- height: "100%",
73
+ height: "95%",
69
74
  right: null,
70
75
  bottom: null,
71
76
  sizeRange: smallSize ? [15, 40] : [18, 80],
@@ -77,7 +82,7 @@ function WordCloud(props) {
77
82
  textStyle: {
78
83
  fontFamily: "Verdana",
79
84
  fontWeight: 500,
80
- color: "#1DA9A0"
85
+ color
81
86
  },
82
87
  emphasis: {
83
88
  focus: "self"
@@ -92,7 +97,11 @@ function WordCloud(props) {
92
97
  ]
93
98
  };
94
99
  myChart.setOption(option);
100
+ myChart.off("click");
101
+ myChart.on("click", function(param) {
102
+ onClick(param);
103
+ });
95
104
  };
96
- return /* @__PURE__ */ import_react.default.createElement("div", { ref: chartRef, style: { width: "100%", height: "312px" } });
105
+ return /* @__PURE__ */ import_react.default.createElement("div", { ref: chartRef, style: { width, height } });
97
106
  }
98
107
  var word_cloud_default = WordCloud;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onesight-charts",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "private": false,
5
5
  "description": "OneSight前端图表公共组件库",
6
6
  "license": "MIT",
@@ -75,6 +75,7 @@
75
75
  "stylelint": "^14.9.1"
76
76
  },
77
77
  "peerDependencies": {
78
+ "echarts-wordcloud": "^2.1.0",
78
79
  "react": ">=16.9.0",
79
80
  "react-dom": ">=16.9.0"
80
81
  },