地址引导
因为需要查看完整功能,因此选择完整版代码
在开发过程中需额外增加的功能
import React from 'react';
import { withPropsAPI } from 'gg-editor';
import { Button } from 'antd';
import { connect } from 'react-redux';
import { RootState } from '../../../redux/rootReducer';
import { asyncActionsCreator } from '../../../pages/relationship_graph/action';
export interface EditorCommand {
relationResourceDatas: any;
relataBtn: any;
addGraphData: any;
editGraphData: any;
[key: string]: any;
editorTag: any;
}
class Save extends React.Component {
constructor(EditorCommand) {
super(EditorCommand);
}
handleClick = () => {
const { propsAPI } = this.props as any;
const { relationResourceDatas, editGraphData, inputval, editorTag, isFisrt } = this.props;
propsAPI.save();
const graphData = JSON.parse(JSON.stringify(propsAPI.save())); //保存下来的数据
};
render() {
return (
);
}
}
const mapStateToProps = (state: RootState) => {
const {redux方法 } = state.ReliationShipGraph;
return {
redux方法
};
};
const mapDispatchToProps = (dispatch: any) => {
return {
redux值: (val) => dispatch(asyncActionsCreator.addGraphRelation(val)),
};
};
export default connect(mapStateToProps, mapDispatchToProps)(withPropsAPI(Save as any));
方法来源:
2.下载图谱缩略图,png jpg 透明以及白底
function downloadImg(type: string, state?: boolean) {
//绘制画布
const divCanvas: Element | any = document.getElementsByClassName('graph-container')[0];
//缩略画布
const minicanvas = divCanvas.getElementsByTagName('canvas')[0];
if (minicanvas) {
let src = '';
const ctx = minicanvas.getContext('2d');
const imgW = minicanvas.width;
const imgH = minicanvas.height;
const imageData = ctx.getImageData(0, 0, imgW, imgH);