Skip to content

Latest commit

 

History

History
60 lines (46 loc) · 1.75 KB

readme.md

File metadata and controls

60 lines (46 loc) · 1.75 KB

Echarts TS Describer

Helps convert huge echarts documentation to typescript definitions.


It was developed to generate doc for echarts.series but it can be used for any other options field. As echarts is huge it is preferred to use this tool for specific options field (otherwise compilation time could be too big and review will too painful).

How to retrieve echarts doc data (for Chrome):

  1. Go to echarts options documentation
  2. Go to dev tools and open main.js?<some hash>
  3. Press "Pretty print" and look for a line like this:
f.isFrozen() || f._toggleSingleItem(f._findItemEl(i(this)))

, it should be placed inside of _initMouse function.

  1. Set debugger on this line
  2. Click expand button on UI options sidebar (debugger should stop on this line)
  3. Enter to console (to observe whole data):
f._dataItemMap.root
  1. Execute something like this (to be able copy this data to clipboard):
f._dataItemMap.root.clean = function(item) {
    const itemForClean = item || this;

    delete itemForClean.parent;

    if (!itemForClean.children) {
        return;
    }

    itemForClean.children.forEach(item => {
        delete item.parent;

        if (item.children) {
            this.clean(item);
        }
    });
};
f._dataItemMap.root.clean();

Note: you can remove any redundant fields (as most of them are auxiliary)

  1. Now you can copy any child from root.children, e.g.:
copy(f._dataItemMap.root.children[24]);

Now Chrome should copy this object to clipboard and you can put it into json file.

Review generated doc and contribute to DefinitelyTyped


Licence

MIT