EXTJS 5 Chart Legend Problema
-
21-12-2019 - |
Domanda
Sto cercando di aggiungere un legend
ai miei grafici di Extjs 5 e non sembra funzionare.È un bug o sto facendo qualcosa di sbagliato?
legend: {
docked: 'top',
style: {
borderColor: 'red',
borderStyle: 'solid'
}
}
. Soluzione
Ho lavorato su questo stesso problema per un po '- e alla fine ha presentato un rapporto di bug Sencha:
http://www.sencha.com / forum / showthread.php? 289279-Sencha-5-Charts-Brokend-Legend
Long Story Breve, c'è "presumibilmente" una correzione nel prossimo rollout Extjs.Sfortunatamente, questo non ci aiuta ora ...
Puoi tuttavia creare un TPL per la legenda - ma il mio TPL non è così robusto come la leggenda nativa Extjs.Mostrerà ancora / nascondere la serie, ma non maschera la serie nella leggenda.Sto ancora perfezionando il TPL e posterò un aggiornamento mentre ottengo un lavoro.
legend: {
docked: 'top',
border: 0,
style: { borderColor: 'red' },
tpl: [
'<tpl for=".">',
'<div class="myLegendItem" style="float:left;margin:5px;padding:0px;cursor:pointer;">',
'<div class="" style="float:left;margin:2px;width:10px;height: 10px; background:{mark};opacity:.6"></div><div style="float:left;">{name}</div>',
'</div>',
'</tpl>'
],
itemSelector: '.myLegendItem'
},
. Altri suggerimenti
Per mascherare la serie inattiva nella legenda, utilizzare un operatore ternario da verificare per i valori.Disabled
<div class="x-legend-container">
<tpl for=".">
<div class="x-legend-item {[ values.disabled ? Ext.baseCSSPrefix + 'legend-inactive' : '' ]}">
<span class="x-legend-item-marker" style="background:{mark};float:left;width:10px;height:10px;"></span>
<span style="float:left;margin-left:4px;">{name}</span>
</div>
</tpl>
</div>
.
Anche se necessario aggiungere una classe CSS per
x-legend-inactive{
opacity: 0.5;
}
.