From V1 to V2
Compared with version 1.0, 2.0 has fully supported and upgraded the capabilities of G6: registration mechanism, layout mechanism, element styles, etc... It also integrates consistently with G6 to support tree diagrams, and has better componentize solutions.
//v1<Graphin data={data} layout={{ name:'grid', options: options }} />//v2<Graphin data={data} layout={{ name:'grid', ...options }} />
const data = {nodes: [{id: 'node-1',// style fieldstyle: {label: {value: 'node-1-label',},},// status fieldstatus: {selected: true,},},],};<Graphin data={data} />;
Interactive behavours and component's attribute configuration previously required to be added using G6 modes. After upgrades to the version 2.0, there is no need to import these configurations with modes.
The extend interface has been removed from Graphin. Graphin.register
can be used to implement custom changes to nodeShape, icon or layout. The extend
props has been completely removed in version 2.0.
// v1<Graphin extend={{ nodeShape: renderNodeShape }} />;// v2Graphin.registerNode(renderNodeShape);
// layout<Graphin extend={{ nodeShape: customLayout }} />;// v2Graphin.registerLayout(customLayout);
// layout<Graphin extend={{ icon: customIconFunction }} />;// v2Graphin.registerFontFamily(iconloader); // View Custom Icon for more information
Fully consistent with G6 registration mechanism
// Register the node, refer to https://g6.antv.vision/en/docs/api/registerItem#g6registernodenodename-options-extendednodename for detailsGraphin.registerNode();// Register edge, refer to https://g6.antv.vision/en/docs/api/registerItem#g6registeredgeedgename-options-extendededgename for detailsGraphin.registerEdge();// Register Combo, refer to https://g6.antv.vision/en/docs/api/registerItem#g6registercombocomboname-options-extendedcomboname for detailsGraphin.registerCombo();// Register layout, please refer to https://g6.antv.vision/en/docs/api/registerLayout#g6registerlayoutlayoutname-layoutGraphin.registerLayout();// Registration behavior, refer to https://g6.antv.vision/en/docs/api/Behavior for detailsGraphin.registerBehavior();