Browse Source

Merge pull request #288 from frappe/refactor-truncate-legends

tags/v1.5.0
Shivam Mishra 5 years ago
committed by GitHub
parent
commit
a35c765858
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 19 additions and 16 deletions
  1. +5
    -4
      dist/frappe-charts.esm.js
  2. +1
    -1
      dist/frappe-charts.min.cjs.js
  3. +1
    -1
      dist/frappe-charts.min.cjs.js.map
  4. +1
    -1
      dist/frappe-charts.min.esm.js
  5. +1
    -1
      dist/frappe-charts.min.esm.js.map
  6. +1
    -1
      dist/frappe-charts.min.iife.js
  7. +1
    -1
      dist/frappe-charts.min.iife.js.map
  8. +1
    -1
      docs/assets/js/frappe-charts.min.js
  9. +1
    -1
      docs/assets/js/frappe-charts.min.js.map
  10. +5
    -3
      src/js/charts/AggregationChart.js
  11. +1
    -1
      src/js/charts/BaseChart.js

+ 5
- 4
dist/frappe-charts.esm.js View File

@@ -1492,7 +1492,7 @@ class BaseChart {
showLegend: 1, // calculate showLegend: 1, // calculate
isNavigable: options.isNavigable || 0, isNavigable: options.isNavigable || 0,
animate: (typeof options.animate !== 'undefined') ? options.animate : 1, animate: (typeof options.animate !== 'undefined') ? options.animate : 1,
truncateLegends: options.truncateLegends || 0
truncateLegends: options.truncateLegends || 1
}; };


this.measures = JSON.parse(JSON.stringify(BASE_MEASURES)); this.measures = JSON.parse(JSON.stringify(BASE_MEASURES));
@@ -1830,7 +1830,7 @@ class AggregationChart extends BaseChart {
let count = 0; let count = 0;
let y = 0; let y = 0;
this.legendTotals.map((d, i) => { this.legendTotals.map((d, i) => {
let barWidth = 110;
let barWidth = 150;
let divisor = Math.floor( let divisor = Math.floor(
(this.width - getExtraWidth(this.measures))/barWidth (this.width - getExtraWidth(this.measures))/barWidth
); );
@@ -1842,13 +1842,14 @@ class AggregationChart extends BaseChart {
y += 20; y += 20;
} }
let x = barWidth * count + 5; let x = barWidth * count + 5;
let label = this.config.truncateLegends ? truncateString(s.labels[i], barWidth/10) : s.labels[i];
let dot = legendDot( let dot = legendDot(
x, x,
y, y,
5, 5,
this.colors[i], this.colors[i],
`${s.labels[i]}: ${d}`,
this.config.truncateLegends
`${label}: ${d}`,
false
); );
this.legendArea.appendChild(dot); this.legendArea.appendChild(dot);
count++; count++;


+ 1
- 1
dist/frappe-charts.min.cjs.js
File diff suppressed because it is too large
View File


+ 1
- 1
dist/frappe-charts.min.cjs.js.map
File diff suppressed because it is too large
View File


+ 1
- 1
dist/frappe-charts.min.esm.js
File diff suppressed because it is too large
View File


+ 1
- 1
dist/frappe-charts.min.esm.js.map
File diff suppressed because it is too large
View File


+ 1
- 1
dist/frappe-charts.min.iife.js
File diff suppressed because it is too large
View File


+ 1
- 1
dist/frappe-charts.min.iife.js.map
File diff suppressed because it is too large
View File


+ 1
- 1
docs/assets/js/frappe-charts.min.js
File diff suppressed because it is too large
View File


+ 1
- 1
docs/assets/js/frappe-charts.min.js.map
File diff suppressed because it is too large
View File


+ 5
- 3
src/js/charts/AggregationChart.js View File

@@ -1,4 +1,5 @@
import BaseChart from './BaseChart'; import BaseChart from './BaseChart';
import { truncateString } from '../utils/draw-utils';
import { legendDot } from '../utils/draw'; import { legendDot } from '../utils/draw';
import { getExtraWidth } from '../utils/constants'; import { getExtraWidth } from '../utils/constants';


@@ -63,7 +64,7 @@ export default class AggregationChart extends BaseChart {
let count = 0; let count = 0;
let y = 0; let y = 0;
this.legendTotals.map((d, i) => { this.legendTotals.map((d, i) => {
let barWidth = 110;
let barWidth = 150;
let divisor = Math.floor( let divisor = Math.floor(
(this.width - getExtraWidth(this.measures))/barWidth (this.width - getExtraWidth(this.measures))/barWidth
); );
@@ -75,13 +76,14 @@ export default class AggregationChart extends BaseChart {
y += 20; y += 20;
} }
let x = barWidth * count + 5; let x = barWidth * count + 5;
let label = this.config.truncateLegends ? truncateString(s.labels[i], barWidth/10) : s.labels[i];
let dot = legendDot( let dot = legendDot(
x, x,
y, y,
5, 5,
this.colors[i], this.colors[i],
`${s.labels[i]}: ${d}`,
this.config.truncateLegends
`${label}: ${d}`,
false
); );
this.legendArea.appendChild(dot); this.legendArea.appendChild(dot);
count++; count++;


+ 1
- 1
src/js/charts/BaseChart.js View File

@@ -33,7 +33,7 @@ export default class BaseChart {
showLegend: 1, // calculate showLegend: 1, // calculate
isNavigable: options.isNavigable || 0, isNavigable: options.isNavigable || 0,
animate: (typeof options.animate !== 'undefined') ? options.animate : 1, animate: (typeof options.animate !== 'undefined') ? options.animate : 1,
truncateLegends: options.truncateLegends || 0
truncateLegends: options.truncateLegends || 1
}; };


this.measures = JSON.parse(JSON.stringify(BASE_MEASURES)); this.measures = JSON.parse(JSON.stringify(BASE_MEASURES));


Loading…
Cancel
Save