diff --git a/src/app/js/formats/vega-lite/component/bar-chart/BarChartView.js b/src/app/js/formats/vega-lite/component/bar-chart/BarChartView.js index dde456d5a..fd29597d5 100644 --- a/src/app/js/formats/vega-lite/component/bar-chart/BarChartView.js +++ b/src/app/js/formats/vega-lite/component/bar-chart/BarChartView.js @@ -16,7 +16,6 @@ import { } from '../../../chartsUtils'; import BarChart from '../../models/BarChart'; import { CustomActionVegaLite } from '../vega-lite-component'; -import deepClone from 'lodash.clonedeep'; import InvalidFormat from '../../../InvalidFormat'; import { VEGA_ACTIONS_WIDTH } from '../vega-lite-component/VegaLiteComponent'; @@ -33,7 +32,7 @@ class BarChartView extends Component { // Create a new bar chart instance - const barChartSpec = deepClone(new BarChart()); + const barChartSpec = new BarChart(); // Set all bar chart parameter the chosen by the administrator diff --git a/src/app/js/formats/vega-lite/component/bubble-plot/BubblePlotView.js b/src/app/js/formats/vega-lite/component/bubble-plot/BubblePlotView.js index 32921975e..648b68883 100644 --- a/src/app/js/formats/vega-lite/component/bubble-plot/BubblePlotView.js +++ b/src/app/js/formats/vega-lite/component/bubble-plot/BubblePlotView.js @@ -6,7 +6,6 @@ import compose from 'recompose/compose'; import { field as fieldPropTypes } from '../../../../propTypes'; import PropTypes from 'prop-types'; import ContainerDimensions from 'react-container-dimensions'; -import deepClone from 'lodash.clonedeep'; import { lodexOrderToIdOrder, VEGA_LITE_DATA_INJECT_TYPE_A, @@ -25,7 +24,7 @@ class BubblePlotView extends Component { // Create a new bubble plot instance - const bubblePlot = deepClone(new BubblePlot()); + const bubblePlot = new BubblePlot(); // Set all bubble plot parameter the chosen by the administrator diff --git a/src/app/js/formats/vega-lite/component/cartography/CartographyView.js b/src/app/js/formats/vega-lite/component/cartography/CartographyView.js index 56b9597ef..9148294ef 100644 --- a/src/app/js/formats/vega-lite/component/cartography/CartographyView.js +++ b/src/app/js/formats/vega-lite/component/cartography/CartographyView.js @@ -2,7 +2,6 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import compose from 'recompose/compose'; -import deepClone from 'lodash.clonedeep'; import ContainerDimensions from 'react-container-dimensions'; import { CustomActionVegaLite } from '../vega-lite-component'; import { @@ -27,7 +26,7 @@ class CartographyView extends Component { // Create a new cartography instance - const cartography = deepClone(new Cartography()); + const cartography = new Cartography(); // Set all cartography parameter the chosen by the administrator diff --git a/src/app/js/formats/vega-lite/component/heatmap/HeatMapView.js b/src/app/js/formats/vega-lite/component/heatmap/HeatMapView.js index 945a64521..56b2d7de9 100644 --- a/src/app/js/formats/vega-lite/component/heatmap/HeatMapView.js +++ b/src/app/js/formats/vega-lite/component/heatmap/HeatMapView.js @@ -7,7 +7,6 @@ import HeatMap from '../../models/HeatMap'; import { field as fieldPropTypes } from '../../../../propTypes'; import PropTypes from 'prop-types'; import ContainerDimensions from 'react-container-dimensions'; -import deepClone from 'lodash.clonedeep'; import { lodexOrderToIdOrder, VEGA_LITE_DATA_INJECT_TYPE_A, @@ -25,7 +24,7 @@ class HeatMapView extends Component { // Create a new heat map instance - const heatMap = deepClone(new HeatMap()); + const heatMap = new HeatMap(); // Set all heat map parameter the chosen by the administrator diff --git a/src/app/js/formats/vega-lite/component/pie-chart/PieChartView.js b/src/app/js/formats/vega-lite/component/pie-chart/PieChartView.js index e61edd99f..af3878ee2 100644 --- a/src/app/js/formats/vega-lite/component/pie-chart/PieChartView.js +++ b/src/app/js/formats/vega-lite/component/pie-chart/PieChartView.js @@ -8,7 +8,6 @@ import ContainerDimensions from 'react-container-dimensions'; import PieChart from '../../models/PieChart'; import { CustomActionVegaLite } from '../vega-lite-component'; import { VEGA_LITE_DATA_INJECT_TYPE_A } from '../../../chartsUtils'; -import deepClone from 'lodash.clonedeep'; const styles = { container: { @@ -22,7 +21,7 @@ class PieChartView extends Component { // Create a new pie chart instance - const pieChart = deepClone(new PieChart()); + const pieChart = new PieChart(); // enable the orderBy in vega-lite diff --git a/src/app/js/formats/vega-lite/models/BarChart.js b/src/app/js/formats/vega-lite/models/BarChart.js index 3351096e7..139b3ffd7 100644 --- a/src/app/js/formats/vega-lite/models/BarChart.js +++ b/src/app/js/formats/vega-lite/models/BarChart.js @@ -14,9 +14,12 @@ import { } from '../../chartsUtils'; import { VEGA_ACTIONS_WIDTH } from '../component/vega-lite-component/VegaLiteComponent'; import BasicChart from './BasicChart'; +import barChartVL from './json/bar_chart.vl.json'; +import barChartLabelsVL from './json/bar_chart_labels.vl.json'; +import deepClone from 'lodash.clonedeep'; /** - * Class use for create bar chart spec + * Class used to create bar chart spec */ class BarChart extends BasicChart { /** @@ -30,8 +33,8 @@ class BarChart extends BasicChart { top: 10, bottom: 0, }; - this.model = require('./json/bar_chart.vl.json'); - this.labelsModel = require('./json/bar_chart_labels.vl.json'); + this.model = deepClone(barChartVL); + this.labelsModel = deepClone(barChartLabelsVL); this.scale = 'linear'; this.labelAngle = { x: 0, diff --git a/src/app/js/formats/vega-lite/models/BubblePlot.js b/src/app/js/formats/vega-lite/models/BubblePlot.js index 2400e9beb..05c779d0a 100644 --- a/src/app/js/formats/vega-lite/models/BubblePlot.js +++ b/src/app/js/formats/vega-lite/models/BubblePlot.js @@ -1,9 +1,11 @@ import HeatMap from './HeatMap'; +import bubblePlotVL from './json/bubble_plot.vl.json'; +import deepClone from 'lodash.clonedeep'; class BubblePlot extends HeatMap { constructor() { super(); - this.model = require('./json/bubble_plot.vl.json'); + this.model = deepClone(bubblePlotVL); } /** diff --git a/src/app/js/formats/vega-lite/models/Cartography.js b/src/app/js/formats/vega-lite/models/Cartography.js index cb31b28e8..df5100fc8 100644 --- a/src/app/js/formats/vega-lite/models/Cartography.js +++ b/src/app/js/formats/vega-lite/models/Cartography.js @@ -1,9 +1,11 @@ import BasicChart from './BasicChart'; import { MAP_EUROPE, MAP_FRANCE, MAP_WORLD } from '../../chartsUtils'; import { VEGA_ACTIONS_WIDTH } from '../component/vega-lite-component/VegaLiteComponent'; +import cartographyVL from './json/cartography.vl.json'; +import deepClone from 'lodash.clonedeep'; /** - * Class use for create cartography spec + * Class used to create cartography spec */ class Cartography extends BasicChart { /** @@ -11,7 +13,7 @@ class Cartography extends BasicChart { */ constructor() { super(); - this.model = require('./json/cartography.vl.json'); + this.model = deepClone(cartographyVL); this.tooltip.category.field = 'properties.name'; this.worldPosition = 'world'; this.autosize = { diff --git a/src/app/js/formats/vega-lite/models/HeatMap.js b/src/app/js/formats/vega-lite/models/HeatMap.js index 5a204fe30..0382b4ea3 100644 --- a/src/app/js/formats/vega-lite/models/HeatMap.js +++ b/src/app/js/formats/vega-lite/models/HeatMap.js @@ -1,8 +1,10 @@ import BasicChart from './BasicChart'; import { LABEL_ASC, LABEL_DESC } from '../../chartsUtils'; +import heatmapVL from './json/heatmap.vl.json'; +import deepClone from 'lodash.clonedeep'; /** - * Class use for create heatmap spec + * Class used to create heatmap spec */ class HeatMap extends BasicChart { /** @@ -10,7 +12,7 @@ class HeatMap extends BasicChart { */ constructor() { super(); - this.model = require('./json/heatmap.vl.json'); + this.model = deepClone(heatmapVL); this.flip = false; this.padding = { left: 10, diff --git a/src/app/js/formats/vega-lite/models/PieChart.js b/src/app/js/formats/vega-lite/models/PieChart.js index c2fc54e3d..5d4f2a888 100644 --- a/src/app/js/formats/vega-lite/models/PieChart.js +++ b/src/app/js/formats/vega-lite/models/PieChart.js @@ -1,7 +1,10 @@ import BasicChart from './BasicChart'; +import pieChartVL from './json/pie_chart.vl.json'; +import pieChartLabelsVL from './json/pie_chart_labels.vl.json'; +import deepClone from 'lodash.clonedeep'; /** - * Class use for create pie chart spec + * Class used to create pie chart spec */ class PieChart extends BasicChart { /** @@ -9,8 +12,8 @@ class PieChart extends BasicChart { */ constructor() { super(); - this.model = require('./json/pie_chart.vl.json'); - this.modelLabels = require('./json/pie_chart_labels.vl.json'); + this.model = deepClone(pieChartVL); + this.modelLabels = deepClone(pieChartLabelsVL); this.labels = false; }