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).
- Go to echarts options documentation
- Go to dev tools and open
main.js?<some hash>
- 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.
- Set debugger on this line
- Click expand button on UI options sidebar (debugger should stop on this line)
- Enter to console (to observe whole data):
f._dataItemMap.root
- 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)
- 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
MIT