(Angular+ TS) Echarts Graph 关系图节点拖拽不反弹+自定义按钮实现缩放

本文介绍了如何在Angular项目中结合TypeScript使用Echarts创建关系图,并实现节点拖拽不反弹及自定义按钮进行缩放功能。关键点包括在TS文件中设置拖拽和缩放的逻辑,以及在HTML和less文件中进行相关配置。示例代码中详细展示了拖拽过程中position的更新方法,以及通过'graphRoam'行动类型实现缩放效果。参考官方文档和Echarts源码可以进一步了解和定制功能。
摘要由CSDN通过智能技术生成

 

前提:

1. 需要在module中引入NgxEchartsModule

2. ts文件中引入所需文件:

import { Component, OnInit, NgZone } from '@angular/core';

import { of } from 'rxjs';

import * as echarts from 'echarts';

const echart = echarts as any;


 代码:

1.  TS部分:

import { Component, OnInit, NgZone } from '@angular/core';
import { of } from 'rxjs';

import * as echarts from 'echarts';
import { map } from 'lodash-es';
const echart = echarts as any;

export class MeetingGraphServiceComponent implements OnInit {
  options;
  nodes;
  links;
  categories;
  echartsInstance;
  winWidth = document.body.clientWidth / 2;
  winHeight = document.body.clientHeight / 2;
  graph;
  data;

  constructor(private ngZone: NgZone) {
    of({
      nodes: [
        {
          categorieId: 0,
          id: '1',
          name: '111',
          symbolSize: 20
        },
        {
          category: 0,
          id: '2',
          name: '222',
          symbolSize: 20
        },
        {
          category: 1,
          id: '3',
          name: '333',
          symbolSize: 20
        },
        {
          category: 1,
          id: '4',
          name: '444',
          symbolSize: 20
        },
        {
          category: 0,
          id: '5',
          name: '555',
          symbolSize: 20
        },
        {
          ca
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值