Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {colorSets} from '@swimlane/ngx-charts/release/utils';
import * as shape from 'd3-shape';
import {DashboardChart} from '../../models/dashboard-chart';
import {dashboardChartTypes} from './dashboardChartTypes';
export const defaultOptions = {
view: [716, 337],
id: 0,
showCommon: true,
threshold: 0,
mostLoaded: 1,
// colorScheme: {
// domain: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA']
// },
colorScheme: {...colorSets.find(s => s.name === 'cool')},
schemeType: 'ordinal',
showLegend: true,
legendTitle: 'Legend',
gradient: false,
showXAxis: true,
showYAxis: true,
showXAxisLabel: true,
showYAxisLabel: true,
yAxisLabel: '',
xAxisLabel: '',
yScaleMax: 100,
yScaleMin: 0,
autoScale: true,
showGridLines: true,
rangeFillOpacity: 0.5,
roundDomains: false,
instantiateDashboardChartFromRequest(value: ChartRequest, chartId: number): DashboardChart {
const chart: Chart = {
id: chartId,
...value,
scheme: {...colorSets.find(s => s.name === value.schemeType)}
};
return this.instantiateDashboardChart(chart);
}
instantiateDashboardChartFromRequest(value: ChartRequest, chartId: number): DashboardChart {
const chart: Chart = {
id: chartId,
...value,
scheme: {...colorSets.find(s => s.name === value.schemeType)}
};
return this.instantiateDashboardChart(chart);
}
instantiateDashboardChart(value: Chart): DashboardChart {
const dataProps = this.convertStringToArrEnum(value.sources);
const dashChart: DashboardChart = {
view: [600, 300],
id: value.id,
showCommon: value.showCommon,
threshold: value.threshold,
mostLoaded: value.mostLoaded,
colorScheme: {...colorSets.find(s => s.name === value.schemeType)},
schemeType: defaultOptions.schemeType,
showLegend: value.showLegend,
legendTitle: value.legendTitle,
gradient: value.gradient,
showXAxis: value.showXAxis,
showYAxis: value.showYAxis,
showXAxisLabel: value.showXAxisLabel,
showYAxisLabel: value.showYAxisLabel,
yAxisLabel: value.yAxisLabel,
xAxisLabel: value.xAxisLabel,
yScaleMin: defaultOptions.yScaleMin,
yScaleMax: defaultOptions.yScaleMax,
autoScale: value.autoScale,
showGridLines: value.showGridLines,
rangeFillOpacity: value.rangeFillOpacity,
roundDomains: value.roundDomains,
instantiateDashboardChart(value: Chart): DashboardChart {
const dataProps = this.convertStringToArrEnum(value.sources);
const dashChart: DashboardChart = {
view: [600, 300],
id: value.id,
showCommon: value.showCommon,
threshold: value.threshold,
mostLoaded: value.mostLoaded,
historyTime: value.historyTime,
colorScheme: {...colorSets.find(s => s.name === value.schemeType)},
schemeType: defaultOptions.schemeType,
showLegend: value.showLegend,
legendTitle: value.legendTitle,
gradient: value.gradient,
showXAxis: value.showXAxis,
showYAxis: value.showYAxis,
showXAxisLabel: value.showXAxisLabel,
showYAxisLabel: value.showYAxisLabel,
yAxisLabel: value.yAxisLabel,
xAxisLabel: value.xAxisLabel,
yScaleMin: defaultOptions.yScaleMin,
yScaleMax: defaultOptions.yScaleMax,
autoScale: value.autoScale,
showGridLines: value.showGridLines,
rangeFillOpacity: value.rangeFillOpacity,
roundDomains: value.roundDomains,