onesight-charts 0.0.1

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.
Files changed (35) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +24 -0
  3. package/dist/components/line/demo.js +13 -0
  4. package/dist/components/line/index.js +294 -0
  5. package/dist/components/line/style.scss +110 -0
  6. package/dist/components/line/tooltipConfig.js +93 -0
  7. package/dist/components/one-table/demo/line-chart.js +908 -0
  8. package/dist/components/one-table/index.js +128 -0
  9. package/dist/components/one-table/index.scss +5 -0
  10. package/dist/components/pie/index.js +94 -0
  11. package/dist/components/pie/index.scss +5 -0
  12. package/dist/components/tooltip/demo/line-chart.js +908 -0
  13. package/dist/components/tooltip/index.js +128 -0
  14. package/dist/components/tooltip/index.scss +5 -0
  15. package/dist/index.js +1 -0
  16. package/dist/umd/onesight-charts.min.css +1 -0
  17. package/dist/umd/onesight-charts.min.js +1 -0
  18. package/dist/utils/chartUtils.js +215 -0
  19. package/dist/utils/colors.js +26 -0
  20. package/lib/components/line/demo.js +42 -0
  21. package/lib/components/line/index.js +307 -0
  22. package/lib/components/line/style.scss +110 -0
  23. package/lib/components/line/tooltipConfig.js +144 -0
  24. package/lib/components/one-table/demo/line-chart.js +1020 -0
  25. package/lib/components/one-table/index.js +156 -0
  26. package/lib/components/one-table/index.scss +5 -0
  27. package/lib/components/pie/index.js +131 -0
  28. package/lib/components/pie/index.scss +5 -0
  29. package/lib/components/tooltip/demo/line-chart.js +1020 -0
  30. package/lib/components/tooltip/index.js +156 -0
  31. package/lib/components/tooltip/index.scss +5 -0
  32. package/lib/index.js +39 -0
  33. package/lib/utils/chartUtils.js +226 -0
  34. package/lib/utils/colors.js +71 -0
  35. package/package.json +82 -0
@@ -0,0 +1,144 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/line/tooltipConfig.js
20
+ var tooltipConfig_exports = {};
21
+ __export(tooltipConfig_exports, {
22
+ createCustomTooltip: () => createCustomTooltip
23
+ });
24
+ module.exports = __toCommonJS(tooltipConfig_exports);
25
+ var import_chartUtils = require("../../utils/chartUtils");
26
+ var createCustomTooltip = ({
27
+ id,
28
+ tooltipClassName,
29
+ myChart,
30
+ seriesData,
31
+ tooltipTotalName,
32
+ showRate,
33
+ tooltipPosition
34
+ }) => ({
35
+ className: `onesight-line-tooltip ${tooltipClassName} ${id}`,
36
+ trigger: "axis",
37
+ enterable: true,
38
+ axisPointer: {
39
+ z: 1,
40
+ show: true,
41
+ type: "line",
42
+ lineStyle: {
43
+ color: "rgba(0, 0, 0, 0.24)",
44
+ type: "solid",
45
+ width: 2
46
+ }
47
+ },
48
+ padding: 0,
49
+ // showContent: true,
50
+ // alwaysShowContent: true,
51
+ // hideDelay: 1000000000,
52
+ position: tooltipPosition ? (point, params) => {
53
+ const pixelPoint = myChart.convertToPixel(
54
+ { seriesIndex: params[0].seriesIndex },
55
+ [params[0].dataIndex, params[0].value]
56
+ );
57
+ const element = document.querySelector(`.${id}`);
58
+ let yValue = 0;
59
+ let currentWidth = 0;
60
+ if (element) {
61
+ if (element.offsetHeight) {
62
+ yValue = -element.offsetHeight + 14;
63
+ }
64
+ if (element.offsetWidth) {
65
+ currentWidth = element.offsetWidth;
66
+ }
67
+ }
68
+ const x = (0, import_chartUtils.computePos)(pixelPoint[0], currentWidth);
69
+ return [x, yValue];
70
+ } : void 0,
71
+ formatter: (res) => {
72
+ if (!res.some((i) => i.value !== void 0 && i.value !== null)) {
73
+ return "";
74
+ }
75
+ let total = 0;
76
+ let dataArr = [...res];
77
+ res.forEach((v) => {
78
+ total += v.value || 0;
79
+ });
80
+ const resNameArr = res.map((item) => item.seriesName);
81
+ const resColorArr = res.map((item) => item.color);
82
+ const allName = Object.keys(seriesData);
83
+ const currentName = allName.filter((item) => resNameArr.includes(item));
84
+ dataArr = currentName.map((item, index) => {
85
+ let dataIndex = res[0].dataIndex;
86
+ let num = seriesData[item][dataIndex];
87
+ return {
88
+ color: resColorArr[index],
89
+ seriesName: item,
90
+ value: num,
91
+ proportion: num / total,
92
+ date: res[0].axisValue
93
+ };
94
+ });
95
+ let marginRight = 7;
96
+ if (dataArr.length > 4) {
97
+ marginRight = 3;
98
+ }
99
+ return `
100
+ <div class='tooltip-wrap'>
101
+ <div class='tooltip-head'>
102
+ ${res[0].axisValue}
103
+ </div>
104
+ <div class='tooltip-body' style="margin-right:${marginRight}px">
105
+ ${dataArr.length > 1 ? `
106
+ <div class='total'>
107
+ <div class='l'>
108
+ ${tooltipTotalName}
109
+ </div>
110
+ <div class='r'>
111
+ ${(0, import_chartUtils.changeDataTypeEn)(total)}
112
+ </div>
113
+ </div>
114
+ ` : ""}
115
+ ${dataArr.map(
116
+ (item) => `
117
+ <div class='item' key='${item.seriesName}'>
118
+ <div class='l'>
119
+ <span class='l-color' style="background-color:${item.color}"></span>
120
+ <span>
121
+ ${item.seriesName}
122
+ </span>
123
+ </div>
124
+ <div class='r'>
125
+ ${dataArr.length > 1 && showRate ? `<span class='rate'>(${(0, import_chartUtils.computeFloatNull)(
126
+ item.proportion
127
+ )})</span>` : ""}
128
+ <span class='num'>
129
+ ${(0, import_chartUtils.changeDataTypeEn)(item.value)}
130
+ </span>
131
+ </div>
132
+ </div>
133
+ `
134
+ ).join("")}
135
+ </div>
136
+ ${tooltipPosition ? '<div class="triangle-down"></div>' : ""}
137
+ </div>
138
+ `;
139
+ }
140
+ });
141
+ // Annotate the CommonJS export names for ESM import in node:
142
+ 0 && (module.exports = {
143
+ createCustomTooltip
144
+ });