Coder Social home page Coder Social logo

northwoodssoftware / gojs-angular-basic Goto Github PK

View Code? Open in Web Editor NEW
39.0 7.0 46.0 1.33 MB

Simple project demonstrating usage of our GoJS/Angular components

License: Other

CSS 5.48% HTML 12.92% TypeScript 76.23% JavaScript 5.37%
gojs diagram angular gojs-angular

gojs-angular-basic's Introduction

gojs-angular-basic

By Northwoods Software for GoJS

This project provides a basic example of using GoJS in an Angular app. Check out the Intro page on using GoJS with Angular for more information.

It makes use of the gojs-angular package to handle setting up Diagram, Palette and Overview components.

When running the sample, try moving / adding / deleting nodes, editing text in the inspector, relinking nodes via ports, undoing (Ctrl-Z), and re-doing (Ctrl-Y) within the diagram. You'll notice the changes are reflected in app-level data. You'll also notice that changes made in the inspector are reflected in the diagram.

Installation

Start by running npm install to install all necessary dependencies.

If you do not have Angular already globally installed, you may do so by running:

npm i -g @angular/cli

Running the project

In the project directory, run:

ng serve

Alternatively, if you do not have Angular installed globally, you may run:

npm run start

Runs the app in the development mode.
Open http://localhost:4200 to view it in the browser.

The page will reload if you make edits.

Learn More

To learn Angular, check out Angular's official site. To learn GoJS, check out gojs.net.

gojs-angular-basic's People

Contributors

dependabot[bot] avatar rjohnson465 avatar simonsarris avatar walternorthwoods avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gojs-angular-basic's Issues

`npm install` giving ''Unexpected end of JSON input''

I was trying to use the boilerplate to get better understanding of go-js in Angular
Post cloning the repo when I run 'npm install' for the repo to install its dependencies it produces the error
I am using Angular 9+ on my windows 10.
How can I resolve it?
Thanks a lot !!

Cannot find module 'gojs'.

How can i get rid of that error am current getting running exactly codes as from from this repo?

It happens on this line "import * as go from 'gojs';" in app.component.ts and inspector.component.ts

Access this variable inside diagram init

export class AppComponent {
@ViewChild('myDiagram', { static: true }) public myDiagramComponent: DiagramComponent;
public parentGrpColor = '#FFDD33';

public initDiagram(){
console.log(this.parentGrpColor);

When i try the above code to access variable or function it throws not defined error. I need to set the colors dynamically, and also need to retrieve data from service.

using context menu with angular component

I'm running the sample just fine. Now I have added a context menu on shape (taken from he tutorial : https://gojs.net/latest/samples/blockEditor.html)

So inside the InitDiagram function, I have added the following below code. The context menu shows up just fine and the clickfunction gets fired when clicking on a menu item. The model is updated with the new shape, however the UI is not updated. The shape remains a rectangle. I believe there is some extra steps to take because of Angular. What am I missing ?

`  dia.nodeTemplate.contextMenu =
  $("ContextMenu",
    $("ContextMenuButton",
      $(go.Panel, "Horizontal",
        FigureButton("Rectangle"), FigureButton("RoundedRectangle"), FigureButton("Ellipse"), FigureButton("Diamond")
      )
    ));

function FigureButton(fig, propname = 'figure') {

  return $(go.Shape,
    {
      width: 32, height: 32, scale: 0.5, fill: "lightgray", figure: fig,
      margin: 1, background: "transparent",
      mouseEnter: (e, shape) => { shape.fill = "dodgerblue"; },
      mouseLeave: (e, shape) => { shape.fill = "lightgray"; },
      click: ClickFunction(propname, fig), contextClick: ClickFunction(propname, fig)
    });
}


// PROPNAME is the name of the data property that should be set to the given VALUE.
function ClickFunction(propname, value) {
  return (e, obj) => {
    e.handled = true;  // don't let the click bubble up
    e.diagram.model.commit((m) => {
      m.set(obj.part.adornedPart.data, propname, value);
    });
  };
`}``

ng serve cannot run the project

E:\AngularProject\gojs-angular-basic>ng serve
No projects support the 'serve' target.
Error: No projects support the 'serve' target.
at ServeCommand.initialize (E:\AngularProject\gojs-angular-basic\node_modules@angular\cli\models\architect-command.js:50:19)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.