@geoblocks/d3-helper
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -119,3 +119,3 @@ import { min as d3Min, max as d3Max } from 'd3-array'; | ||
} | ||
const axisType = this.getDataType_(data, axisColumn); | ||
const axisType = this.getDataType_(data, axisConfig.tickLabelColumn || axisColumn); | ||
this.xData_ = data.map(value => value[axisColumn]); | ||
@@ -138,3 +138,3 @@ this.xScale_ = this.getScale_(this.xData_, axisType, [0, drawableWidth]); | ||
} | ||
const axisType = this.getDataType_(data, axisColumn); | ||
const axisType = this.getDataType_(data, axisConfig.tickLabelColumn || axisColumn); | ||
this.yData_ = data.map(value => value[axisColumn]); | ||
@@ -157,6 +157,6 @@ this.yScale_ = this.getScale_(this.yData_, axisType, [drawableHeight, 0]); | ||
} | ||
const axisType = this.getDataType_(data, axisColumn); | ||
const axisType = this.getDataType_(data, axisConfig.tickLabelColumn || axisColumn); | ||
this.oppositeYData_ = data.map(value => value[axisColumn]); | ||
this.oppositeYScale_ = this.getScale_(this.oppositeYData_, axisType, [drawableHeight, 0]); | ||
this.drawOppositeYAxis_(this.color_); | ||
this.drawOppositeYAxis_(this.color_, data); | ||
} | ||
@@ -301,3 +301,10 @@ /** | ||
const axisColumn = this.getAxisColumnName_(axisConfig, data); | ||
const axisType = this.getDataType_(data, axisColumn); | ||
const axisType = this.getDataType_(data, axisConfig.tickLabelColumn || axisColumn); | ||
const compareFn = (d) => { | ||
const dataRow = data.find(dataRow => this.compareData_(dataRow[axisColumn], d)); | ||
return dataRow[axisConfig.tickLabelColumn || axisColumn]; | ||
}; | ||
if (axisType === AxisType.TEXT) { | ||
return baseAxis.ticks(ticks).tickFormat(compareFn); | ||
} | ||
if (axisConfig.tickformat) { | ||
@@ -307,3 +314,3 @@ // Return ticks with nicely formatted Date values. | ||
const dateFormat = d3TimeFormat(axisConfig.tickformat); | ||
return baseAxis.ticks(ticks).tickFormat(dateFormat); | ||
return baseAxis.ticks(ticks).tickFormat(compareFn).tickFormat(dateFormat); | ||
} | ||
@@ -313,15 +320,5 @@ // Return ticks with formatted number values. | ||
const numberFormat = d3Format(axisConfig.tickformat); | ||
return baseAxis.ticks(ticks).tickFormat(numberFormat); | ||
return baseAxis.ticks(ticks).tickFormat(compareFn).tickFormat(numberFormat); | ||
} | ||
} | ||
// Return special text ticks with values that are taken from | ||
// another column than what was used for plotting. | ||
if (axisType === AxisType.TEXT && axisConfig.tickLabelColumn && data) { | ||
const tickLabelName = axisConfig.tickLabelColumn; | ||
return baseAxis.ticks(ticks) | ||
.tickFormat((d) => { | ||
const dataRow = data.find(dataRow => this.compareData_(dataRow[axisColumn], d)); | ||
return dataRow[tickLabelName]; | ||
}); | ||
} | ||
// Return ticks in a standard way with out any formatting. | ||
@@ -328,0 +325,0 @@ return baseAxis.ticks(ticks); |
{ | ||
"name": "@geoblocks/d3-helper", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "d3 helper classes", | ||
@@ -33,3 +33,3 @@ "license": "bsd", | ||
"lint": "tslint src/*.ts", | ||
"start": "parcel serve --port 8080 examples/**/*.html" | ||
"start": "parcel serve --port 8080 examples/*.html --public-url /" | ||
}, | ||
@@ -46,2 +46,3 @@ "dependencies": { | ||
"d3-shape": "^1.3.7", | ||
"d3-transition": "^1.3.2", | ||
"parcel-bundler": "^1.12.4", | ||
@@ -48,0 +49,0 @@ "tslib": "^1.10.0", |
@@ -24,2 +24,3 @@ # d3-helper | ||
Especially manage the axis of cartesian charts. | ||
Supported axis data types are: Date, number and text. | ||
@@ -26,0 +27,0 @@ ### Supported browsers |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44558
59
10
717