@fc-plot/ts-graph 0.22.18 → 0.22.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fc-plot/ts-graph",
3
- "version": "0.22.18",
3
+ "version": "0.22.20",
4
4
  "scripts": {
5
5
  "commit": "npx git-cz",
6
6
  "compile": "fetk run compile",
package/src/index.ts CHANGED
@@ -493,7 +493,7 @@ export default class TsGraph {
493
493
  }
494
494
  this.options.onZoomWithoutDefult(times);
495
495
  } else {
496
- const { ykey, yAxis, ykeyFormatter } = this.options;
496
+ const { ykey, ykey2, yAxis, ykeyFormatter } = this.options;
497
497
  let { series } = this.options;
498
498
  if (transform) {
499
499
  this.transform = transform;
@@ -513,6 +513,7 @@ export default class TsGraph {
513
513
  for (dataIdx = 0; dataIdx < data.length; dataIdx++) {
514
514
  const item = data[dataIdx];
515
515
  const y = getYkeyValue(item[ykey], ykeyFormatter);
516
+
516
517
  if (y === null) continue;
517
518
  // get axis domain
518
519
  if (ymin < y) {
@@ -521,6 +522,16 @@ export default class TsGraph {
521
522
  if (ymax > y) {
522
523
  ymax = y;
523
524
  }
525
+ if (ykey2) {
526
+ const y2 = getYkeyValue(item[ykey2], ykeyFormatter);
527
+ if (y2 === null) continue;
528
+ if (ymin < y2) {
529
+ ymin = y2;
530
+ }
531
+ if (ymax > y2) {
532
+ ymax = y2;
533
+ }
534
+ }
524
535
  }
525
536
  }
526
537
  // 如果缩放至没有数据点(无法计算出 ymin 和 ymax),则不更新 domain
package/src/yAxis.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as d3 from "d3";
2
+ import { map, floor } from "lodash";
2
3
  import { Options, YScales } from "./interface";
3
4
  import { shortUint, getMaxWidthByYAxisTicks } from "./utils";
4
5
 
@@ -135,7 +136,9 @@ export default class YAxis {
135
136
  ticks = [yAxis.max];
136
137
  } else {
137
138
  const step = d3.tickStep(realMin, realMax, realTickLength);
138
- ticks = d3.range(realMin, realMax, step);
139
+ ticks = map(d3.range(realMin, realMax, step), (d: number) => {
140
+ return floor(d, 2);
141
+ });
139
142
  }
140
143
  } else {
141
144
  yScales.domain([ymin, ymax]);