Skip to content

Commit

Permalink
en cours
Browse files Browse the repository at this point in the history
  • Loading branch information
apezel committed May 23, 2018
1 parent 186d6b5 commit 3901d9c
Show file tree
Hide file tree
Showing 36 changed files with 1,186 additions and 677 deletions.
1 change: 1 addition & 0 deletions app/locales/de/translations.js
Expand Up @@ -217,6 +217,7 @@ export default {
},
"title" : "Darstellungsoptionen",
"symbols": "Symbole",
"surfaces": "surfaces",
"thresholds": "thresholds",
"discretization": {
"title": "Diskretisierung",
Expand Down
1 change: 1 addition & 0 deletions app/locales/en/translations.js
Expand Up @@ -219,6 +219,7 @@ export default {
},
"title" : "settings",
"symbols": "symbols",
"surfaces": "surfaces",
"thresholds": "thresholds",
"discretization": {
"title": "discretization",
Expand Down
11 changes: 10 additions & 1 deletion app/locales/fr/translations.js
Expand Up @@ -220,6 +220,7 @@ export default {
},
"title" : "réglages",
"symbols": "symboles",
"surfaces": "surfaces",
"thresholds": "seuils",
"discretization": {
"title": "discrétisation",
Expand Down Expand Up @@ -280,7 +281,15 @@ export default {
},
"val_symboles": {
"name": "valeurs > symboles",
"description": "les symboles sont proportionnels aux valeurs"
"description": "les symboles sont proportionnels aux valeurs",
"combined": {
"quanti": {
"val_surfaces": {
"name": "valeurs > symboles + surfaces",
"description": "les symboles sont proportionnels et le dégradé de couleurs suit les valeurs"
}
}
}
}
},
"quali": {
Expand Down
12 changes: 7 additions & 5 deletions app/models/graph-layer.js
Expand Up @@ -2,7 +2,8 @@ import Ember from 'ember';
import Struct from './struct';
import {ColumnStruct} from './data';
import GraphLayout from './graph-layout';
import Mapping from './mapping/mapping';
import Mapping from "./mapping/mapping";
import { MappingFactory } from './mapping/factory';
/* global Em */

let GraphLayer = Struct.extend({
Expand All @@ -20,9 +21,10 @@ let GraphLayer = Struct.extend({

displayable: function() {
return this.get('visible') && this.get('mapping')
&& this.get('mapping.type') && this.get('mapping.varCol');
}.property('mapping', 'mapping.type', 'visible'),

&& this.get('mapping.type')
&& this.get('mapping.isFinalized');
}.property('mapping', 'mapping.isFinalized', 'visible'),

deferredChange: Ember.debouncedObserver(
'mapping', 'mapping._defferedChangeIndicator',
'visible', 'opacity', 'legendTitle', 'legendOrientation',
Expand All @@ -48,7 +50,7 @@ GraphLayer.reopenClass({
restore(json, refs = {}) {
return this._super(json, refs, {
visible: json.visible,
mapping: Mapping.restore(json.mapping, refs),
mapping: MappingFactory(json.mapping, refs),
opacity: json.opacity,
legendTitle: json.legendTitle,
legendOrientation: json.legendOrientation || "vertical"
Expand Down
76 changes: 76 additions & 0 deletions app/models/mapping/abstract-mapping.js
@@ -0,0 +1,76 @@
import Ember from 'ember';
import GeoDef from '../geo-def';
import Struct from '../struct';

let AbstractMapping = Struct.extend({

type: null,

visualization: null,

title: null,

geoDef: null,

canBeSurface: function() {
return this.get('geoDef.isGeoRef');
}.property('geoDef.isGeoRef'),

init() {
this._super();
},

titleComputed: function() {
return this.get('title');
}.property('title'),

isBoundToVar: function() {
return false;
}.property(),

isFinalized: function() {
return this.get('visualization') != null && this.get('isBoundToVar');
}.property('isBoundToVar', 'visualization'),

configure: function() {
throw new Error("not implemented.");
}.observes('type').on("init"),

getScaleOf(type) {
throw new Error("not implemented.");
},

postConfigure() { },

fn() {
throw new Error("not implemented");
},

ruleFn(rule, mode) {
throw new Error("not implemented");
},

export(props) {
return this._super(Object.assign({
type: this.get('type'),
title: this.get('title'),
geoDef: this.get('geoDef') ? this.get('geoDef').export() : null
}, props));
}

});

AbstractMapping.reopenClass({

restore(json, refs = {}, opts = {}) {
return this._super(json, refs, {
...opts,
type: json.type,
title: json.title,
geoDef: json.geoDef ? GeoDef.restore(json.geoDef, refs) : null
});
}

});

export default AbstractMapping;
10 changes: 10 additions & 0 deletions app/models/mapping/factory.js
@@ -0,0 +1,10 @@
import Mapping from "./mapping";
import MultiMapping from "./multi-mapping";

export const MappingFactory = (json, refs) => {
if (json.isMulti) {
return MultiMapping.restore(json, refs);
} else {
return Mapping.restore(json, refs);
}
}
77 changes: 40 additions & 37 deletions app/models/mapping/mapping.js
Expand Up @@ -12,16 +12,13 @@ import {RuleFactory} from './rule';
import FilterAbstract from './filter/abstract';
import FilterFactory from './filter/factory';
import PatternMaker from 'khartis/utils/pattern-maker';
import AbstractMapping from './abstract-mapping';

let Mapping = Struct.extend(LegendMixin, {

type: null,
let Mapping = AbstractMapping.extend(LegendMixin, {

scale: null,
visualization: null,

varCol: null,
geoDef: null,
filter: null,

rules: null,
Expand All @@ -32,21 +29,23 @@ let Mapping = Struct.extend(LegendMixin, {

ordered: false,

canBeSurface: function() {
return this.get('geoDef.isGeoRef');
}.property('geoDef.isGeoRef'),

canBeMappedAsValue: function() {
return this.get('varCol.meta.type') === "numeric";
}.property('varCol._defferedChangeIndicator'),


isBoundToVar: function() {
return this.get('varCol') != null;
}.property('varCol'),

init() {
this._super();
if (!this.get('scale')) {
this.set('scale', Scale.create());
}
!this.get('scale') && this.set('scale', Scale.create());
},

titleComputed: function() {
return this.get('title') || this.get('varCol.header.value');
}.property('title', 'varCol.header.value'),

filteredBody: function() {
let geoDef = this.get('geoDef'),
geoMapped = FilterAbstract.create({
Expand Down Expand Up @@ -91,27 +90,36 @@ let Mapping = Struct.extend(LegendMixin, {
this.set('visualization', null);
break;
}
this.generateVisualization();
this.generateRules();
this.configureScale();
this.postConfigure();

//check compatibility between type and variable
if (ValueMixins.Data.detect(this) && !this.get('canBeMappedAsValue')) {
this.set('varCol', null);
}

this.finalize();

}.observes('type').on("init"),

finalize() {
if (this.get('varCol')) {
this.configureScale();
this.generateVisualization();
this.generateRules();
this.postConfigure();
}
},

getScaleOf(type) {
throw new Error("not implemented. Should be overrided by mixin");
},

generateRules() {
},
generateRules() {},

generateVisualization() {
},
generateVisualization() {},

configureScale() {
},
configureScale() {},

postConfigure() {
},
postConfigure() {},

usePattern: Ember.computed('visualization.pattern', {
get() {
Expand All @@ -136,12 +144,11 @@ let Mapping = Struct.extend(LegendMixin, {

fn() {

let self = this,
rules = this.get('rules'),
let rules = this.get('rules'),
visualization = this.get('visualization'),
ruleForCell = new Map();

return function(cell, mode) {
return (cell, mode) => {

if (!ruleForCell.has(cell)) {
ruleForCell.set(cell, rules ? rules.find( r => r.get('cells').indexOf(cell) !== -1 ) : false);
Expand All @@ -150,15 +157,15 @@ let Mapping = Struct.extend(LegendMixin, {
let rule = ruleForCell.get(cell);

if (rule) {
return self.ruleFn(rule, mode);
return this.ruleFn(rule, mode);
} else {
switch (mode) {
case "texture":
return self.getScaleOf("texture")(cell.get('postProcessedValue'));
return this.getScaleOf("texture")(cell.get('postProcessedValue'));
case "fill":
return self.getScaleOf("color")(cell.get('postProcessedValue'));
return this.getScaleOf("color")(cell.get('postProcessedValue'));
case "size":
return self.getScaleOf("size")(cell.get('postProcessedValue'));
return this.getScaleOf("size")(cell.get('postProcessedValue'));
case "shape":
return visualization.get('shape');
case "strokeColor":
Expand Down Expand Up @@ -188,7 +195,7 @@ let Mapping = Struct.extend(LegendMixin, {
},

deferredChange: Ember.debouncedObserver(
'type',
'type', 'titleComputed', 'varCol',
'varCol._defferedChangeIndicator', 'geoDef._defferedChangeIndicator',
'scale._defferedChangeIndicator', 'visualization._defferedChangeIndicator',
'rules.@each._defferedChangeIndicator', 'colorSet', 'ordered',
Expand All @@ -200,11 +207,9 @@ let Mapping = Struct.extend(LegendMixin, {

export(props) {
return this._super(Object.assign({
type: this.get('type'),
scale: this.get('scale') ? this.get('scale').export() : null,
visualization: this.get('visualization') ? this.get('visualization').export() : null,
varCol: this.get('varCol') ? this.get('varCol._uuid') : null,
geoDef: this.get('geoDef') ? this.get('geoDef').export() : null,
filter: this.get('filter') ? this.get('filter').export() : null,
legendMaxValuePrecision : this.get('legendMaxValuePrecision'),
ordered: this.get('ordered'),
Expand All @@ -218,11 +223,9 @@ Mapping.reopenClass({

restore(json, refs = {}, opts = {}) {
return this._super(json, refs, {
type: json.type,
scale: json.scale != null ? Scale.restore(json.scale, refs) : null,
visualization: json.visualization != null ? VisualizationFactory.restoreInstance(json.visualization, refs) : null,
varCol: json.varCol ? refs[json.varCol] : null,
geoDef: json.geoDef ? GeoDef.restore(json.geoDef, refs) : null,
filter: json.filter ? FilterFactory.restoreInstance(json.filter, refs) : null,
legendMaxValuePrecision: json.legendMaxValuePrecision,
ordered: json.ordered,
Expand Down
26 changes: 26 additions & 0 deletions app/models/mapping/mixins/multi.js
@@ -0,0 +1,26 @@
import Ember from 'ember';


export const QuantiValSymQuantiValSurf = Ember.Mixin.create({

visualization: Ember.computed('master.visualization', function() {
return this.get('master.visualization');
}),

delegateStyleMode(cell, mode) {
let [master, slave] = this.get('mappings');
switch (mode) {
case "texture":
return master.getScaleOf("texture")(cell.get('postProcessedValue'));
case "fill":
return slave.getScaleOf("color")(cell.get('postProcessedValue'));
case "size":
return master.getScaleOf("size")(cell.get('postProcessedValue'));
case "shape":
return master.get('visualization.shape');
case "strokeColor":
return master.get('visualization.strokeColor');
}
}

});
2 changes: 1 addition & 1 deletion app/models/mapping/mixins/value.js
Expand Up @@ -312,7 +312,7 @@ let SurfaceMixin = Ember.Mixin.create({
d3Scale = d3.scaleLinear();
rangeLength = intervals.length; //2
};

if (this.get('visualization.pattern')) {

if (type === "texture") {
Expand Down

0 comments on commit 3901d9c

Please sign in to comment.