jmchart 1.2.20 → 1.2.22
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/README.md +80 -1
- package/dist/jmchart.amd.js +5 -2
- package/dist/jmchart.cjs.js +5 -2
- package/dist/jmchart.esm.js +5 -2
- package/dist/jmchart.iife.js +5 -2
- package/dist/jmchart.system.js +5 -2
- package/miniprogram_dist/index.js +17961 -0
- package/package.json +7 -6
- package/pnpm-workspace.yaml +4 -0
- package/server.js +3 -0
- package/src/core/markLine/manager.js +1 -1
- package/src/jmChart.js +1 -1
- package/src/series/lineSeries.js +5 -4
package/README.md
CHANGED
|
@@ -703,6 +703,85 @@ chart.on('marklinemove', (args) => {
|
|
|
703
703
|
8. **数组副作用防护**:`Array.reverse()` 使用 `slice()` 先拷贝再反转,避免修改原数组
|
|
704
704
|
9. **浅拷贝优化**:对于不需要深拷贝的场景使用 `Object.assign` 替代深拷贝
|
|
705
705
|
|
|
706
|
+
## 最佳实践
|
|
707
|
+
|
|
708
|
+
### 1. 大数据量优化
|
|
709
|
+
当数据量较大时(>100条),建议:
|
|
710
|
+
- 禁用动画:`enableAnimate: false`
|
|
711
|
+
- 减少数据点显示:`showItem: false`
|
|
712
|
+
- 使用 `touchGraph: true` 提升交互性能
|
|
713
|
+
|
|
714
|
+
### 2. 响应式设计
|
|
715
|
+
```javascript
|
|
716
|
+
const chart = new jmChart(container, {
|
|
717
|
+
width: container.clientWidth,
|
|
718
|
+
height: container.clientHeight
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
// 监听窗口大小变化
|
|
722
|
+
window.addEventListener('resize', () => {
|
|
723
|
+
chart.width = container.clientWidth;
|
|
724
|
+
chart.height = container.clientHeight;
|
|
725
|
+
chart.refresh();
|
|
726
|
+
});
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
### 3. 动态数据更新
|
|
730
|
+
```javascript
|
|
731
|
+
// 更新数据后自动刷新
|
|
732
|
+
chart.data = newData;
|
|
733
|
+
chart.refresh();
|
|
734
|
+
|
|
735
|
+
// 或者使用自动刷新模式
|
|
736
|
+
const chart = new jmChart(container, {
|
|
737
|
+
autoRefresh: true
|
|
738
|
+
});
|
|
739
|
+
```
|
|
740
|
+
|
|
741
|
+
### 4. 自定义颜色
|
|
742
|
+
```javascript
|
|
743
|
+
// 使用自定义颜色数组
|
|
744
|
+
const chart = new jmChart(container, {
|
|
745
|
+
style: {
|
|
746
|
+
chartColors: ['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FFEAA7']
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
// 或者使用颜色函数
|
|
751
|
+
chart.createSeries('line', {
|
|
752
|
+
field: 'value',
|
|
753
|
+
style: {
|
|
754
|
+
color: function(point) {
|
|
755
|
+
return point.yValue > 100 ? '#FF0000' : '#00FF00';
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
## 故障排除
|
|
762
|
+
|
|
763
|
+
### 常见问题
|
|
764
|
+
|
|
765
|
+
1. **图表不显示**
|
|
766
|
+
- 检查容器元素是否存在且有宽高
|
|
767
|
+
- 确认数据格式正确
|
|
768
|
+
- 检查浏览器控制台是否有错误
|
|
769
|
+
|
|
770
|
+
2. **动画卡顿**
|
|
771
|
+
- 减少数据量或禁用动画
|
|
772
|
+
- 使用 `touchGraph: true` 优化交互性能
|
|
773
|
+
- 检查是否有内存泄漏
|
|
774
|
+
|
|
775
|
+
3. **触摸事件不响应**
|
|
776
|
+
- 确认容器元素有正确的 CSS 定位
|
|
777
|
+
- 检查是否有其他元素遮挡
|
|
778
|
+
- 尝试启用 `touchGraph: true`
|
|
779
|
+
|
|
780
|
+
4. **图表尺寸异常**
|
|
781
|
+
- 确保容器有明确的宽度和高度
|
|
782
|
+
- 检查 CSS 是否影响容器尺寸
|
|
783
|
+
- 使用 `chart.width` 和 `chart.height` 手动设置
|
|
784
|
+
|
|
706
785
|
## 开发
|
|
707
786
|
|
|
708
787
|
### 构建项目
|
|
@@ -772,4 +851,4 @@ MIT
|
|
|
772
851
|
- 完善文档
|
|
773
852
|
|
|
774
853
|
[npm-badge]: https://img.shields.io/npm/v/jmchart.svg
|
|
775
|
-
[npm-badge-url]: https://www.npmjs.com/package/jmchart
|
|
854
|
+
[npm-badge-url]: https://www.npmjs.com/package/jmchart
|
package/dist/jmchart.amd.js
CHANGED
|
@@ -14853,6 +14853,7 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
14853
14853
|
const len = points.length;
|
|
14854
14854
|
if (!len) return;
|
|
14855
14855
|
this.style.stroke = this.style.color;
|
|
14856
|
+
this.style.fill = null;
|
|
14856
14857
|
this.style.item.stroke = this.style.color;
|
|
14857
14858
|
const isRunningAni = this.enableAnimate && (dataChanged || this.___animateCounter > 0) && len < ANIMATION_DATA_THRESHOLD;
|
|
14858
14859
|
let shapePoints = [];
|
|
@@ -14994,8 +14995,8 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
14994
14995
|
// 有指定绘制区域效果才展示
|
|
14995
14996
|
if (!this.style.area || points.length < 2) return;
|
|
14996
14997
|
|
|
14997
|
-
//
|
|
14998
|
-
const axisY = this.
|
|
14998
|
+
// 基线:使用数据基准线(baseY),在 createPoints 中已根据 minY/baseYValue 正确计算
|
|
14999
|
+
const axisY = this.baseY;
|
|
14999
15000
|
|
|
15000
15001
|
// 过滤有效点
|
|
15001
15002
|
const validPoints = points.filter(p => p.y != null && typeof p.y !== 'undefined');
|
|
@@ -15030,6 +15031,8 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
15030
15031
|
const style = this.graph.utils.clone(this.style.area, {}, true);
|
|
15031
15032
|
// 连框颜色如果没指定,就透明
|
|
15032
15033
|
style.stroke = style.stroke || 'transparent';
|
|
15034
|
+
// 闭合路径,确保 fill/stroke 正确封闭多边形
|
|
15035
|
+
style.close = true;
|
|
15033
15036
|
if (!style.fill) {
|
|
15034
15037
|
const color = this.graph.utils.hexToRGBA(this.style.stroke);
|
|
15035
15038
|
if (isAbove) {
|
package/dist/jmchart.cjs.js
CHANGED
|
@@ -14855,6 +14855,7 @@ class jmLineSeries extends jmSeries {
|
|
|
14855
14855
|
const len = points.length;
|
|
14856
14856
|
if (!len) return;
|
|
14857
14857
|
this.style.stroke = this.style.color;
|
|
14858
|
+
this.style.fill = null;
|
|
14858
14859
|
this.style.item.stroke = this.style.color;
|
|
14859
14860
|
const isRunningAni = this.enableAnimate && (dataChanged || this.___animateCounter > 0) && len < ANIMATION_DATA_THRESHOLD;
|
|
14860
14861
|
let shapePoints = [];
|
|
@@ -14996,8 +14997,8 @@ class jmLineSeries extends jmSeries {
|
|
|
14996
14997
|
// 有指定绘制区域效果才展示
|
|
14997
14998
|
if (!this.style.area || points.length < 2) return;
|
|
14998
14999
|
|
|
14999
|
-
//
|
|
15000
|
-
const axisY = this.
|
|
15000
|
+
// 基线:使用数据基准线(baseY),在 createPoints 中已根据 minY/baseYValue 正确计算
|
|
15001
|
+
const axisY = this.baseY;
|
|
15001
15002
|
|
|
15002
15003
|
// 过滤有效点
|
|
15003
15004
|
const validPoints = points.filter(p => p.y != null && typeof p.y !== 'undefined');
|
|
@@ -15032,6 +15033,8 @@ class jmLineSeries extends jmSeries {
|
|
|
15032
15033
|
const style = this.graph.utils.clone(this.style.area, {}, true);
|
|
15033
15034
|
// 连框颜色如果没指定,就透明
|
|
15034
15035
|
style.stroke = style.stroke || 'transparent';
|
|
15036
|
+
// 闭合路径,确保 fill/stroke 正确封闭多边形
|
|
15037
|
+
style.close = true;
|
|
15035
15038
|
if (!style.fill) {
|
|
15036
15039
|
const color = this.graph.utils.hexToRGBA(this.style.stroke);
|
|
15037
15040
|
if (isAbove) {
|
package/dist/jmchart.esm.js
CHANGED
|
@@ -14851,6 +14851,7 @@ class jmLineSeries extends jmSeries {
|
|
|
14851
14851
|
const len = points.length;
|
|
14852
14852
|
if (!len) return;
|
|
14853
14853
|
this.style.stroke = this.style.color;
|
|
14854
|
+
this.style.fill = null;
|
|
14854
14855
|
this.style.item.stroke = this.style.color;
|
|
14855
14856
|
const isRunningAni = this.enableAnimate && (dataChanged || this.___animateCounter > 0) && len < ANIMATION_DATA_THRESHOLD;
|
|
14856
14857
|
let shapePoints = [];
|
|
@@ -14992,8 +14993,8 @@ class jmLineSeries extends jmSeries {
|
|
|
14992
14993
|
// 有指定绘制区域效果才展示
|
|
14993
14994
|
if (!this.style.area || points.length < 2) return;
|
|
14994
14995
|
|
|
14995
|
-
//
|
|
14996
|
-
const axisY = this.
|
|
14996
|
+
// 基线:使用数据基准线(baseY),在 createPoints 中已根据 minY/baseYValue 正确计算
|
|
14997
|
+
const axisY = this.baseY;
|
|
14997
14998
|
|
|
14998
14999
|
// 过滤有效点
|
|
14999
15000
|
const validPoints = points.filter(p => p.y != null && typeof p.y !== 'undefined');
|
|
@@ -15028,6 +15029,8 @@ class jmLineSeries extends jmSeries {
|
|
|
15028
15029
|
const style = this.graph.utils.clone(this.style.area, {}, true);
|
|
15029
15030
|
// 连框颜色如果没指定,就透明
|
|
15030
15031
|
style.stroke = style.stroke || 'transparent';
|
|
15032
|
+
// 闭合路径,确保 fill/stroke 正确封闭多边形
|
|
15033
|
+
style.close = true;
|
|
15031
15034
|
if (!style.fill) {
|
|
15032
15035
|
const color = this.graph.utils.hexToRGBA(this.style.stroke);
|
|
15033
15036
|
if (isAbove) {
|
package/dist/jmchart.iife.js
CHANGED
|
@@ -14854,6 +14854,7 @@ var jmChart = (function (exports) {
|
|
|
14854
14854
|
const len = points.length;
|
|
14855
14855
|
if (!len) return;
|
|
14856
14856
|
this.style.stroke = this.style.color;
|
|
14857
|
+
this.style.fill = null;
|
|
14857
14858
|
this.style.item.stroke = this.style.color;
|
|
14858
14859
|
const isRunningAni = this.enableAnimate && (dataChanged || this.___animateCounter > 0) && len < ANIMATION_DATA_THRESHOLD;
|
|
14859
14860
|
let shapePoints = [];
|
|
@@ -14995,8 +14996,8 @@ var jmChart = (function (exports) {
|
|
|
14995
14996
|
// 有指定绘制区域效果才展示
|
|
14996
14997
|
if (!this.style.area || points.length < 2) return;
|
|
14997
14998
|
|
|
14998
|
-
//
|
|
14999
|
-
const axisY = this.
|
|
14999
|
+
// 基线:使用数据基准线(baseY),在 createPoints 中已根据 minY/baseYValue 正确计算
|
|
15000
|
+
const axisY = this.baseY;
|
|
15000
15001
|
|
|
15001
15002
|
// 过滤有效点
|
|
15002
15003
|
const validPoints = points.filter(p => p.y != null && typeof p.y !== 'undefined');
|
|
@@ -15031,6 +15032,8 @@ var jmChart = (function (exports) {
|
|
|
15031
15032
|
const style = this.graph.utils.clone(this.style.area, {}, true);
|
|
15032
15033
|
// 连框颜色如果没指定,就透明
|
|
15033
15034
|
style.stroke = style.stroke || 'transparent';
|
|
15035
|
+
// 闭合路径,确保 fill/stroke 正确封闭多边形
|
|
15036
|
+
style.close = true;
|
|
15034
15037
|
if (!style.fill) {
|
|
15035
15038
|
const color = this.graph.utils.hexToRGBA(this.style.stroke);
|
|
15036
15039
|
if (isAbove) {
|
package/dist/jmchart.system.js
CHANGED
|
@@ -14856,6 +14856,7 @@ System.register([], (function (exports) {
|
|
|
14856
14856
|
const len = points.length;
|
|
14857
14857
|
if (!len) return;
|
|
14858
14858
|
this.style.stroke = this.style.color;
|
|
14859
|
+
this.style.fill = null;
|
|
14859
14860
|
this.style.item.stroke = this.style.color;
|
|
14860
14861
|
const isRunningAni = this.enableAnimate && (dataChanged || this.___animateCounter > 0) && len < ANIMATION_DATA_THRESHOLD;
|
|
14861
14862
|
let shapePoints = [];
|
|
@@ -14997,8 +14998,8 @@ System.register([], (function (exports) {
|
|
|
14997
14998
|
// 有指定绘制区域效果才展示
|
|
14998
14999
|
if (!this.style.area || points.length < 2) return;
|
|
14999
15000
|
|
|
15000
|
-
//
|
|
15001
|
-
const axisY = this.
|
|
15001
|
+
// 基线:使用数据基准线(baseY),在 createPoints 中已根据 minY/baseYValue 正确计算
|
|
15002
|
+
const axisY = this.baseY;
|
|
15002
15003
|
|
|
15003
15004
|
// 过滤有效点
|
|
15004
15005
|
const validPoints = points.filter(p => p.y != null && typeof p.y !== 'undefined');
|
|
@@ -15033,6 +15034,8 @@ System.register([], (function (exports) {
|
|
|
15033
15034
|
const style = this.graph.utils.clone(this.style.area, {}, true);
|
|
15034
15035
|
// 连框颜色如果没指定,就透明
|
|
15035
15036
|
style.stroke = style.stroke || 'transparent';
|
|
15037
|
+
// 闭合路径,确保 fill/stroke 正确封闭多边形
|
|
15038
|
+
style.close = true;
|
|
15036
15039
|
if (!style.fill) {
|
|
15037
15040
|
const color = this.graph.utils.hexToRGBA(this.style.stroke);
|
|
15038
15041
|
if (isAbove) {
|