我々はmarker-source.fill
属性のランダムな値を取得します:
をこれがその一部であることになる特定の時間var optionsVariable
と例えば
KitchenSinkデモアプリケーション(http://resources.jointjs.com/demos/kitchensink)
createInspector: function(cell) {
var props = App.config.inspector[cell.get('type')];
if (cell.isLink()) {
var a = {
inputs: {
attrs: {
'.marker-source': {
transform: {
type: 'select',
options: [Math.round(Math.random() * 100), Math.round(Math.random() * 100), Math.round(Math.random() * 100)],
}
}
}
}
};
_.merge(props, a);
}
return joint.ui.Inspector.create('.inspector-container', _.extend({
cell: cell
}, props));
},
App.config.inspector
はインスペクタで別のファイルにインスペクタの定義
App.config.inspector = {
'app.Link': {
inputs: {
attrs: {
'.marker-source': {
transform: {
ty pe: 'select',
group: 'marker-source',
label: 'Source arrowhead',
index: 1
},
fill: {
type: 'color-palette',
options: options.colorPalette,
group: 'marker-source',
label: 'Color',
when: { ne: { 'attrs/.marker-source/transform': 'scale(0.001)'}},
index: 2
}
},
'.marker-target': {
transform: {
type: 'select',
options: options.arrowheadSize,
group: 'marker-target',
label: 'Target arrowhead',
// ...
おかげで、これは(_main.js_は、カスタマイズされたコードのほとんどを持っています)素敵なアプローチです。しかし、あなたが異なるタイプ(int)を追加しているので、[object Object]項目をリストに表示したくない場合は、_inspectorの 'transform'の' options:options.arrowheadSize 'プロパティをコメントアウトしてください.js_ ''.marker-source'。 – CPHPython