SOS, I need to create a new visulized chart

hi everyone,
First of all, I apologize for the novice, but I really need your help.
In kibana-4.1, I need to create a function named compare, which is to get all the fields and values of an index in the Es. When I use this function, it will compare the data in the selected field before and after the comparison, by comparing the results to achieve the D3 chart display (higher than the show rise, lower than the show down). But I found that I made a mistake, I write this funtion in the metrics group of the page visulization, and it does not need to operate the data.
And I found that the data has loaded after the page loading. The fields and datas have diplayed on the left in discover page. I also found that the elements display the data is through the angular ng-repeat to loop of a unpopularfields variable, but I can not find this variable in directory.
I really need your help. The problem I need to solve now is:

    1.How to use D3 to create a new chart, describing in detail how to create a file, and the file reference and D3 drawing?
    2.Customize this feature, is written in the options to control the data, and then painted to show it?
    3.If the visualization page does not need data, just need the options operate, how to activate the fa-success button?
    4.Where is the unpopularfields variable?

Thx for your help.

The current visualizations are implemented as plugins within the Kibana core, I recommend referencing those: https://github.com/elastic/kibana/tree/4.1/src/kibana/plugins

The .kibana index contains the keys and their count, indicating if it's popular or not. This is done in field_chooser, and does appear to be exposed as an API https://github.com/elastic/kibana/blob/4.1/src/kibana/plugins/discover/components/field_chooser/field_chooser.js#L131