frappe-charts 2.1.0 → 2.1.2

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": "frappe-charts",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "main": "dist/frappe-charts.esm.js",
5
5
  "module": "dist/frappe-charts.esm.js",
6
6
  "browser": "dist/frappe-charts.umd.js",
@@ -100,7 +100,8 @@ export default class AxisChart extends BaseChart {
100
100
  this.calcXMarkers();
101
101
  if (!onlyWidthChange) {
102
102
  let hasBars = this.data.datasets.some(d => d.chartType === 'bar');
103
- this.calcYAxisParameters(this.getAllYValues(), this.type === 'line' && !hasBars);
103
+ let hasArea = this.data.datasets.some(d => Object.assign({}, this.lineOptions, d.lineOptions).regionFill);
104
+ this.calcYAxisParameters(this.getAllYValues(), this.type === 'line' && !hasBars && !hasArea);
104
105
  if (this.fitYAxisLabels()) {
105
106
  this.calcLegend();
106
107
  this.calcXPositions();
@@ -271,6 +272,12 @@ export default class AxisChart extends BaseChart {
271
272
  return [].concat(...allValueLists);
272
273
  }
273
274
 
275
+ formatValueLabel(value) {
276
+ return this.config.numberFormatter
277
+ ? this.config.numberFormatter(value)
278
+ : shortenLargeNumber(value);
279
+ }
280
+
274
281
  setupComponents() {
275
282
  let componentConfigs = [
276
283
  [
@@ -378,9 +385,9 @@ export default class AxisChart extends BaseChart {
378
385
  let labels = new Array(s.datasetLength).fill('');
379
386
  if (this.config.valuesOverPoints) {
380
387
  if (!stacked) {
381
- labels = d.values.map(v => shortenLargeNumber(v));
388
+ labels = d.values.map(v => this.formatValueLabel(v));
382
389
  } else if (d.index === s.datasets.length - 1) {
383
- labels = d.cumulativeYs.map(v => shortenLargeNumber(v));
390
+ labels = d.cumulativeYs.map(v => this.formatValueLabel(v));
384
391
  }
385
392
  }
386
393
 
@@ -416,6 +423,7 @@ export default class AxisChart extends BaseChart {
416
423
 
417
424
  // same for all datasets
418
425
  valuesOverPoints: this.config.valuesOverPoints,
426
+ numberFormatter: this.config.numberFormatter,
419
427
  },
420
428
  function () {
421
429
  let s = this.state;
@@ -6,6 +6,10 @@ import {
6
6
  animateDot, animatePath, animatePathStr
7
7
  } from '../utils/animate';
8
8
 
9
+ function formatPointValue(value, numberFormatter) {
10
+ return numberFormatter && value !== null && value !== undefined ? numberFormatter(value) : value;
11
+ }
12
+
9
13
  class ChartComponent {
10
14
  constructor({
11
15
  layerClass = '',
@@ -434,7 +438,7 @@ let componentConfigs = {
434
438
  y,
435
439
  visible ? data.radius : 0,
436
440
  c.color,
437
- (c.valuesOverPoints ? data.values[j] : ''),
441
+ (c.valuesOverPoints ? formatPointValue(data.values[j], c.numberFormatter) : ''),
438
442
  j,
439
443
  o.hideDotBorder
440
444
  );
@@ -449,7 +453,7 @@ let componentConfigs = {
449
453
  data.yPositions[lastIndex],
450
454
  data.radius,
451
455
  c.color,
452
- (c.valuesOverPoints ? data.values[lastIndex] : ''),
456
+ (c.valuesOverPoints ? formatPointValue(data.values[lastIndex], c.numberFormatter) : ''),
453
457
  lastIndex,
454
458
  o.hideDotBorder
455
459
  );