Sencha Charts Essentials by Ajit Kumar

Sencha Charts Essentials by Ajit Kumar

Author:Ajit Kumar [Kumar, Ajit]
Language: eng
Format: epub
Tags: Web, Computers, Programming Languages, User Interfaces, JavaScript, Web Programming
ISBN: 9781785288487
Google: NaS_CQAAQBAJ
Publisher: Packt Publishing Ltd
Published: 2015-05-30T20:54:02+00:00


So, let's provide our own version of the provideLegendInfo method. Here is the implementation of the method which will be a member method of the SCE.series.MarketClock class:

provideLegendInfo: function (target) { var me = this, store = me.getStore(); if (store) { var items = store.getData().items, i, style; for (i = 0; i<items.length; i++) { style = me.getStyleByIndex(i); target.push({ name: items[i].get('market'), mark: style.fillStyle || 'black', disabled: false }); } } }

The AbstractChart class the preceding method by passing an empty array to it as an argument. We have used the formal parameter—target—for it. The method iterates the chart's store records and prepares the legend data for them. Legend data contains the name, mark, and disabled fields. The name field is set to the market name using the market field on the record. The mark field is set to the sector color. Once the legend data is created, it is added to the target array so that it is available to the AbstractChart logic, where it adds this data to its legendStore.

Refresh the application and you will see the neat legend displayed on the right-hand side of our market clock.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.