How to use DAGIcon method in tracetest

Best JavaScript code snippet using tracetest

index.ts

Source:index.ts Github

copy

Full Screen

1/*2jupyterlab-dagitty3Copyright (C) 2022 Michal Krassowski4This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.5This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.6You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA7*/8import { IRenderMime } from '@jupyterlab/rendermime-interfaces';9import { Widget } from '@lumino/widgets';10import type { Message } from '@lumino/messaging';11import { DAGittyController, GraphParser } from './_dagitty';12import type { Graph } from './_dagitty';13import { dagIcon } from './icons';14/**15 * The default mime type for the extension.16 */17const MIME_TYPE = 'application/x.dagitty.dag';18/**19 * The class name added to the extension.20 */21const CLASS_NAME = 'mimerenderer-dagitty-dag';22/**23 * A widget for rendering Dagitty DAG.24 */25export class OutputWidget extends Widget implements IRenderMime.IRenderer {26 dagController?: DAGittyController;27 private _arePositionsOutdated: boolean;28 private _resizeObserver: ResizeObserver;29 private _offsetLeft: number;30 private _offsetTop: number;31 private _offsetWidth: number;32 private _offsetHeight: number;33 private _inDrag: boolean;34 /**35 * Construct a new output widget.36 */37 constructor(options: IRenderMime.IRendererOptions) {38 super();39 this._mimeType = options.mimeType;40 this.addClass(CLASS_NAME);41 this._updatePositions();42 this._resizeObserver = new ResizeObserver((entries: any) => {43 this._resize();44 });45 this._resizeObserver.observe(this.node);46 this._inDrag = false;47 }48 /**49 * Render Dagitty DAG into this widget's node.50 */51 renderModel(model: IRenderMime.IMimeModel): Promise<void> {52 const data = model.data[this._mimeType] as string;53 const metadata = model.metadata as any;54 for (const argument of ['width', 'height']) {55 const value = metadata[argument] as string | undefined;56 if (value) {57 this.node.style.setProperty(argument, value);58 }59 }60 const isMutable = (metadata['mutable'] as boolean | undefined) || false;61 const graph = GraphParser.parseGuess(data);62 this.dagController = new DAGittyController({63 canvas: this.node,64 graph: graph,65 autofocus: true,66 interactive: true,67 // we set mutable=false to prevent adding new nodes68 // but we still alllow view mutations, see setListeners()69 mutable: isMutable,70 });71 this.adjustPointerPositioning();72 if (!isMutable) {73 this.setDragListeners();74 }75 return Promise.resolve();76 }77 private _maybeUpdatePositions() {78 if (this._arePositionsOutdated) {79 this._updatePositions();80 }81 }82 private _updatePositions() {83 this._offsetLeft = this.node.offsetLeft;84 this._offsetTop = this.node.offsetTop;85 this._offsetWidth = this.node.offsetWidth;86 this._offsetHeight = this.node.offsetHeight;87 this._arePositionsOutdated = false;88 }89 protected adjustPointerPositioning(): void {90 const view = this.dagController.getView();91 const impl = view.impl;92 // dagitty uses offsetLeft and offsetTop to calculate mouse position,93 // which is only correct if the container is a direct descendant of body94 // (or nested in elements which do not have paddings/border/position)95 // so here we override position getters to return correct values.96 const offsetX = (e: MouseEvent) => {97 this._maybeUpdatePositions();98 return e.offsetX + this._offsetLeft;99 };100 const offsetY = (e: MouseEvent) => {101 this._maybeUpdatePositions();102 return e.offsetY + this._offsetTop;103 };104 view.pointerX = offsetX;105 view.pointerY = offsetY;106 impl.pointerX = offsetX;107 impl.pointerY = offsetY;108 }109 onUpdateRequest(message: Message): void {110 this._arePositionsOutdated = true;111 }112 /**113 * Preserve the information about moved edges in vertices,114 * so that they remain in place when we resize the view.115 */116 setDragListeners(): void {117 const view = this.dagController.getView();118 const impl = view.impl;119 impl.setEventListener('vertex_drag', (vs: any) => {120 const [x, y] = view.toGraphCoordinate(vs.x, vs.y);121 vs.v.layout_pos_x = x;122 vs.v.layout_pos_y = y;123 if (view.getViewMode() !== 'normal') {124 const v = view.getGraph().getVertex(vs.v.id);125 v.layout_pos_x = x;126 v.layout_pos_y = y;127 }128 });129 impl.setEventListener('edge_drag', (es: any) => {130 const [x, y] = view.toGraphCoordinate(es.cx, es.cy);131 es.e.layout_pos_x = x;132 es.e.layout_pos_y = y;133 });134 impl.setEventListener('drag_end', () =>135 this.dagController.graphLayoutChanged()136 );137 }138 private _resize(): void {139 this._arePositionsOutdated = true;140 if (this.dagController) {141 this.dagController.getView().resize();142 }143 }144 protected onResize(msg: Widget.ResizeMessage): void {145 this._resize();146 this.update();147 }148 /**149 * #### Notes150 * This method implements the DOM `EventListener` interface and is151 * called in response to events on the widgets's DOM node.152 *153 * This should not be called directly by user code.154 */155 handleEvent(event: Event): void {156 switch (event.type) {157 case 'wheel':158 this._evtMouseWheel(event as WheelEvent);159 break;160 case 'pointerdown':161 this._evtMouseDown(event as MouseEvent);162 break;163 case 'pointermove':164 this._evtMouseMove(event as MouseEvent);165 break;166 case 'pointerleave':167 this._evtMouseLeave(event as MouseEvent);168 break;169 case 'pointerup':170 this._evtMouseUp(event as MouseEvent);171 break;172 }173 }174 private _evtMouseDown(event: MouseEvent): void {175 this._inDrag = true;176 }177 private _getBoundingBox(graph: Graph): number[] {178 let box = graph.getBoundingBox();179 if (box === null) {180 const box2 = this.dagController.getView().bounds;181 box = [box2[0], box2[2], box2[1], box2[3]];182 }183 return box;184 }185 private _evtMouseMove(event: MouseEvent): void {186 if (!(this._inDrag && event.ctrlKey)) {187 return;188 }189 this._maybeUpdatePositions();190 const graph = this.dagController.getGraph();191 const box = this._getBoundingBox(graph);192 const w = box[2] - box[0];193 const h = box[3] - box[1];194 const dx = (event.movementX / this._offsetWidth) * w;195 const dy = (event.movementY / this._offsetHeight) * h;196 box[0] -= dx;197 box[1] -= dy;198 box[2] -= dx;199 box[3] -= dy;200 graph.setBoundingBox(box);201 this.dagController.getView().drawGraph();202 this.update();203 }204 private _evtMouseUp(event: MouseEvent): void {205 this._inDrag = false;206 }207 private _evtMouseLeave(event: MouseEvent): void {208 this._inDrag = false;209 }210 private _evtMouseWheel(event: WheelEvent): void {211 if (!(this.dagController && event.ctrlKey)) {212 return;213 }214 const graph = this.dagController.getGraph();215 let box = this._getBoundingBox(graph);216 const scale = 1 + event.deltaY / window.screen.height;217 this._maybeUpdatePositions();218 let w = box[2] - box[0];219 let h = box[3] - box[1];220 const xmin = box[0];221 const ymin = box[1];222 box[0] -= xmin;223 box[1] -= ymin;224 box[2] -= xmin;225 box[3] -= ymin;226 box[0] -= w / 2;227 box[1] -= h / 2;228 box[2] -= w / 2;229 box[3] -= h / 2;230 box = box.map((x) => x * scale);231 const dx = (event.offsetX / this._offsetWidth) * (1 - scale) * w;232 const dy = (event.offsetY / this._offsetHeight) * (1 - scale) * h;233 box[0] += dx;234 box[1] += dy;235 box[2] += dx;236 box[3] += dy;237 w = box[2] - box[0];238 h = box[3] - box[1];239 box[0] += w / 2;240 box[1] += h / 2;241 box[2] += w / 2;242 box[3] += h / 2;243 box[0] += xmin;244 box[1] += ymin;245 box[2] += xmin;246 box[3] += ymin;247 graph.setBoundingBox(box);248 this.dagController.getView().drawGraph();249 this.update();250 event.preventDefault();251 }252 /**253 * A message handler invoked on a `'before-attach'` message.254 */255 protected onBeforeAttach(msg: Message): void {256 this.node.addEventListener('pointerdown', this);257 this.node.addEventListener('pointerup', this);258 this.node.addEventListener('pointermove', this);259 this.node.addEventListener('pointerleave', this);260 this.node.addEventListener('wheel', this);261 }262 /**263 * A message handler invoked on an `'after-detach'` message.264 */265 protected onAfterDetach(msg: Message): void {266 this.node.removeEventListener('pointerdown', this);267 this.node.removeEventListener('pointerup', this);268 this.node.removeEventListener('pointermove', this);269 this.node.removeEventListener('pointerleave', this);270 this.node.removeEventListener('wheel', this);271 }272 dispose(): void {273 if (this._resizeObserver) {274 this._resizeObserver.unobserve(this.node);275 this._resizeObserver = null;276 }277 super.dispose();278 }279 private _mimeType: string;280}281/**282 * A mime renderer factory for Dagitty DAG data.283 */284export const rendererFactory: IRenderMime.IRendererFactory = {285 safe: true,286 mimeTypes: [MIME_TYPE],287 createRenderer: (options) => new OutputWidget(options),288};289/**290 * Extension definition.291 */292const extension: IRenderMime.IExtension = {293 id: 'jupyterlab-dagitty:plugin',294 rendererFactory,295 rank: 100,296 dataType: 'string',297 fileTypes: [298 {299 name: 'dag',300 mimeTypes: [MIME_TYPE],301 extensions: ['.dag'],302 icon: dagIcon.name,303 },304 {305 name: 'dagitty',306 mimeTypes: [MIME_TYPE],307 extensions: ['.dagitty'],308 icon: dagIcon.name,309 },310 ],311 documentWidgetFactoryOptions: {312 name: 'Dagitty DAG',313 primaryFileType: 'dag',314 fileTypes: ['dag'],315 defaultFor: ['dag'],316 },317};...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

1import Vue from "vue";2import store from './store'3import Antd from 'ant-design-vue'4import "ant-design-vue/dist/antd.less";5import App from "./App";6import router from './router';7import 'codemirror/lib/codemirror.css';8import VueCodemirror from 'vue-codemirror';9import MonacoEditor from 'vue-monaco';10import Clipboard from 'v-clipboard';11import TopCoatLogo from './assets/topcoat-dark-logo.svg';12import TopCoatLogoLight from './assets/topcoat-light-logo.svg';13import Folder from './assets/folder.svg';14import Schema from './assets/schema.svg';15import PlayIcon from './assets/play.svg';16import DagIcon from './assets/dag.svg';17import GitIcon from './assets/git.svg';18import MagnifyIcon from './assets/magnifying-glass-search.svg';19import BrickSQLLogo from './assets/bright_color.png';20import DbtIcon from './assets/dbt-icon.png';21import TopcoatIcon from './assets/topcoat-icon-tp.png';22import axios from 'axios';23import '@mdi/font/css/materialdesignicons.css';24import vuetify from './vuetify';25import helpers from './helpers';26Vue.use(Clipboard)27Vue.config.productionTip = false;28Vue.use(Antd);29export const eventBus = new Vue();30axios.defaults.xsrfCookieName = 'csrftoken';31axios.defaults.xsrfHeaderName = "X-CSRFTOKEN";32axios.interceptors.request.use(function (config) {33 // Do something before request is sent34 eventBus.$emit("check_session");35 return config;36 }, function (error) {37 // Do something with request error38 return Promise.reject(error);39 });40axios.interceptors.response.use(function (response) {41 // Any status code that lie within the range of 2xx cause this function to trigger42 // Do something with response data43 return response;44 }, function (error) {45 // Any status codes that falls outside the range of 2xx cause this function to trigger46 // Do something with response error47 if (error.response.status == 401) {48 console.log("Redirect to login (axios)");49 window.location.href = "/login/auth0?next=" + window.location.href;50 }51 return Promise.reject(error);52 });53// you can set default global options and events when use54Vue.use(VueCodemirror, /* { 55 options: { theme: 'base16-dark', ... },56 events: ['scroll', ...]57} */)58const app = new Vue({59 router,60 store,61 vuetify,62 components: { App },63 template: '<App/>',64 icons: {65 iconfont: 'mdi',66 },...

Full Screen

Full Screen

icons.ts

Source:icons.ts Github

copy

Full Screen

1import { LabIcon } from '@jupyterlab/ui-components';2import dag from '../style/icons/dag.svg';3export const dagIcon = new LabIcon({4 name: 'dag:icon',5 svgstr: dag,...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var trace = require('./tracetest.js');2var icon = trace.DAGIcon();3console.log(icon);4var trace = require('./tracedag.js');5var DAGIcon = function() {6 return trace.DAGIcon();7};8module.exports.DAGIcon = DAGIcon;9var DAGIcon = function() {10 return 'DAG Icon';11};12module.exports.DAGIcon = DAGIcon;

Full Screen

Using AI Code Generation

copy

Full Screen

1var tracetest = require('./tracetest.js');2console.log(dagIcon);3module.exports = {4 DAGIcon: function (url) {5 return url;6 }7}

Full Screen

Using AI Code Generation

copy

Full Screen

1var tracetest = require('tracetest');2var DAGIcon = tracetest.DAGIcon;3var icon = new DAGIcon();4icon.setDAGIcon('test');5icon.setDAGIcon('test');6icon.setDAGIcon('test');7icon.setDAGIcon('test');8icon.setDAGIcon('test');9var tracetest = require('tracetest');10var DAGIcon = tracetest.DAGIcon;

Full Screen

Using AI Code Generation

copy

Full Screen

1var trace = require('tracetest.js');2dag.icon();3exports.DAGIcon = function(url) {4 return {5 icon: function() {6 console.log('icon');7 }8 }9}10var trace = require('tracetest.js');11dag.icon();12exports.DAGIcon = function(url) {13 return {14 icon: function() {15 console.log('icon');16 }17 }18}19var trace = require('tracetest.js');20dag.icon();21exports.DAGIcon = function(url) {22 return {23 icon: function() {24 console.log('icon');25 }26 }27}28var trace = require('tracetest.js');29dag.icon();30exports.DAGIcon = function(url) {31 return {32 icon: function() {33 console.log('icon');34 }35 }36}37var trace = require('tracetest.js');38dag.icon();39exports.DAGIcon = function(url) {40 return {41 icon: function() {42 console.log('icon');43 }44 }45}46var trace = require('tracetest.js');47dag.icon();

Full Screen

Using AI Code Generation

copy

Full Screen

1var DAGIcon = require('tracetest.js').DAGIcon;2var dagIcon = new DAGIcon();3dagIcon.setIcon('0x0');4var DAGIcon = function() {5 this.setIcon = function(icon) {6 console.log('icon is ' + icon);7 }8};9exports.DAGIcon = DAGIcon;

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tracetest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful