Skip to the content.

Introduction

NPM License: MIT

This is a React Component that serves as a fully fledged visual programming interface, ideal for simulation.
It can additionally be customized to a certain degree with user-defined functions on top of the host of base components provided for general use cases.

Have a look at the tool in the playground :)


Table of Contents


Installation and Setup

For users with an existing React-based project

npm install --save vizpro
import Canvas from 'vizpro';

For users with no existing project

npx create-react-app my-app
cd my-app
npm start
npm install --save vizpro
import React from 'react';

import { Canvas } from 'vizpro';

function App() {
    return <Canvas />;
}

export default App;

Definitions

A definition refers to the current project workspace you have created on the canvas. It includes the state of the canvas (inputs, components, connections).

Creating a new definition

Saving a definition

Clearing a definition

Downloading a definition

Opening a downloaded definition


General Usage

The tool consists of 4 major sections:

drawing

A look at the rendered tool

Creating a new component

A new component can be added onto the canvas by simply clicking on the relevant icon in the Components Tab.

drawing

Canvas state after adding a Panel and double clicking it

Setting inputs and outputs

drawing

Slider output connected to a panel as input


The Main Inputs

These are integral components that help with the input, selection and flow of data. They don’t process input data according to a preset function like Shallow or Deep components.

Slider

drawing

Slider Component and its Properties Tab

Panel

drawing

Panel Component and its Properties Tab

Toggle

drawing

Toggle Component

Option List

drawing

The Option List Component and its Properties Tab

List View

drawing

The List View Component

File Upload

drawing

The File Upload Component

Deep

drawing

The Deep Component and its Properties Tab


Shallow Components

Shallow components refer to functions that will be run in real-time when inputs are provided.

drawing

The Average Component in use


Provided component Usage
Average Calculate the average of an input list of numbers
Add Calculate the sum of an input list of numbers
Min Calculate the minimum of an input list of numbers
Max Calculate the maximum of an input list of numbers
Difference 2 Calculate the difference between 2 numbers
JSON Navigator Traverse a JSON according to a given path
3D Visualizer Visualize a relevant 3D object in iframe given a valid url
Image Display Visualize an image given a valid link
YouTube Display Watch an embedded YouTube video given a valid link
Plot Panel Plot the provided data given valid formatting
String to List Converts a string-like list to a list
Replace Replaces all occurences of a string in a text with a new one

Deep Components

Deep Components run functions by sending GET requests to the provided url, which in turn would process the given input parameters and return the result. After connecting all the inputs and outputs to a deep component, users need to click the Play button to start the asynchronous request and set the value to the output components.

Setting up a deep component

drawing

The Deep Component after setting inputs and url

Connecting to the cloud

drawing

A Google Cloud Function using node.js runtime

Connecting to local files

npm install --save express
npm install --save child_process
"proxy": "http://localhost:8080",
node server.js

Creating Custom Components

Besides using pre-defined components, you can add new components to the tool by passing the required information of all the components you want to include as an array of JSON objects as props of the Canvas.

The Component JSON

Required Parameters

{
  type:  [],
  value: []
}

Format of function return value

Optional Parameters

To use these new components, pass it as the udo property to the Canvas component as follows, where newComps is the array of JSON objects.

<Canvas udo={newComps} />

drawing

New user-defined components