Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// for better presentation, we order datasets so that the ones with units information to
// display first, so that Yaxis with unit shows up outside yaxis without
// unit
if (defined(chartData) && chartData.length > 1) {
chartData = chartData
.slice()
.sort((data1, data2) => defined(data1.units) - defined(data2.units));
}
return {
data: chartData,
domain: this.props.domain,
width: "100%",
height: defaultValue(this.props.height, defaultHeight),
axisLabel: this.props.axisLabel,
mini: this.props.styling === "feature-info",
transitionDuration: this.props.transitionDuration,
margin: margin,
tooltipSettings: tooltipSettings,
titleSettings: titleSettings,
grid: grid,
highlightX: this.props.highlightX
};
},
state.data.filter(data => data.type !== "moment").map(data => data.units)
);
const size = Size.calculate(
container,
margin,
state,
state.mini ? 1 : units.length
);
const scales = Scales.calculate(
size,
state.domain,
state.data,
this.getXpadding(state)
);
const transitionDuration = defaultValue(
state.transitionDuration,
defaultTransitionDuration
);
// The last condition in hasData checks that at least one y-value of one chart is defined.
const hasData =
data.length > 0 &&
data[0].points.length > 0 &&
data.some(d => d.points.some(p => defined(p.y)));
const d3Container = d3Select(container);
// Update SVG
const chartSVGContainer = d3Container
.select("svg")
.attr("width", state.width)
function prettifyCoordinates(longitude, latitude, options) {
var result = {};
const optionsDefaulted = defaultValue(options, {});
const digits = defaultValue(optionsDefaulted.digits, 5);
result.latitude =
Math.abs(latitude).toFixed(digits) + "Β°" + (latitude < 0.0 ? "S" : "N");
result.longitude =
Math.abs(longitude).toFixed(digits) + "Β°" + (longitude < 0.0 ? "W" : "E");
if (defined(optionsDefaulted.height)) {
result.elevation =
Math.round(optionsDefaulted.height) +
(defined(optionsDefaulted.errorBar)
? "Β±" + Math.round(optionsDefaulted.errorBar)
: "") +
"m";
} else {
result.elevation = undefined;
static render(container, state) {
if (!defined(state.data)) {
return;
}
initializeChartTypes(state);
const data = state.data;
const margin = defaultValue(state.margin, defaultMargin);
const units = uniq(
state.data.filter(data => data.type !== "moment").map(data => data.units)
);
const size = Size.calculate(
container,
margin,
state,
state.mini ? 1 : units.length
);
const scales = Scales.calculate(
size,
state.domain,
state.data,
this.getXpadding(state)
);
var ChartData = function(points, parameters) {
parameters = defaultValue(parameters, defaultValue.EMPTY_OBJECT);
/**
* The array of points. Each point should have the format {x: X, y: Y}.
* @type {Object[]}
*/
this.points = defaultValue(points, []);
/**
* A selected point from the array above. Used internally by charting functions for hover/clicking functionality.
* @type {Object}
*/
this.point = undefined;
/**
* Unique id for this set of points.
* @type {String}
*/
this.id = parameters.id;
/**
* Name of the category for this set of points., eg. the source catalog item.
* @type {String}
calculate(element, margin, state, numberOfYAxes) {
const xAxisHeight = defaultValue(state.xAxisHeight, defaultXAxisHeight);
const xAxisLabelHeight = defaultValue(
state.xAxisLabelHeight,
defaultXAxisLabelHeight
);
const yAxesWidth = numberOfYAxes * yAxisWidth;
const titleHeight = Title.getHeight(state.titleSettings);
const width = element.offsetWidth - margin.left - margin.right - yAxesWidth;
const height =
element.offsetHeight - margin.top - margin.bottom - titleHeight;
const heightMinusXAxisLabelHeight =
height -
(defined(state.axisLabel) && defined(state.axisLabel.x)
? xAxisLabelHeight
: 0);
const plotHeight =
heightMinusXAxisLabelHeight - (state.mini ? 0 : xAxisHeight);
constructor(options: ChartDataOptions) {
this.points = options.points;
this.point = undefined;
this.id = options.id;
this.categoryName = options.categoryName;
this.name = options.name;
this.units = options.units;
this.getColor = options.getColor;
this.yAxisMin = options.yAxisMin;
this.yAxisMax = options.yAxisMax;
this.type = options.type;
this.onClick = options.onClick;
this.showAll = defaultValue(options.showAll, true);
this.yAxisWidth = 40;
}
getFillStyle(concept) {
return {
fill: defaultValue(concept.color, '#ffffff')
};
},
constructor(options: SearchResultOptions) {
this.name = defaultValue(options.name, "Unknown");
this.tooltip = options.tooltip;
this.isImportant = defaultValue(options.isImportant, false);
this.clickAction = options.clickAction;
this.catalogItem = options.catalogItem;
this.location = options.location;
}
get opacity(): number {
return defaultValue(super.opacity, 0.8);
}
}