I have a store which always contains a single record. Lets say the record looks like this:
{'good': 5, 'bad': 2, 'neutral': 3}
How would I render that as a Pie chart? Ext.js normally uses each record in a store as one point of the series. In my case, I have only one record and want it to be used as three points in the series.
You have a couple options available to you. You can create a custom
Ext.data.reader.Readersubclass that will convert your raw data into your formatted records, you can override the store’sloadRawDatamethod to convert JSON data into anExt.data.ResultSet, or you can set a callback on the store’sloadmethod to get your record and manually convert it into your necessary record format. If you’re going for reusability, I suggest making a Reader.The
Reader#readRecordsmethod takes raw data and returns a ResultSet, which sounds exactly like what you’re after. Take a look at the source from the Sencha docs website and you should be able to figure out where to go from there. Once you have your custom reader, pass it to your store’s proxy during configuration and it should handle the work for you. If it doesn’t automatically, you may need to call the storeloadRawData, passing your JSON response.