DEV Community

KateMLady
KateMLady

Posted on

Why is visual important?

Starting with OOP, client-server applications and ML, it's often unclear how important it is to visualize data. For example, receiving a response from the server prints the console and the functionality is obvious, but how to display this data to the client?

  • React is a JavaScript framework for connecting frontend and backend parts
  • Together, JS and React provide the ability to organize data transfer and its correct display on the visual
  • Databases and React interact via scripts: JS makes an SQL request to the DB (e.g. PostgreSQL/Oracle)
var image;

function upload() {
  var canvas=document.getElementById("can");
  var fileinput=document.getElementById("finput");
  image=new SimpleImage(fileinput);
  image.drawTo(canvas);
}

function makeGrey() {
    for (var pixel of image.values()){
        var avg =(pixel.getRed()+pixel.getGreen()+pixel.getBlue())/3;
        pixel.setRed(avg);
        pixel.setGreen(avg);
        pixel.setBlue(avg);
    }
  var canvas=document.getElementById("can2");
  image.drawTo(canvas);
}
Enter fullscreen mode Exit fullscreen mode
  • When working with data transfer files, explicitly specify the locations and methods for saving/processing in JS scripts
  • React will help you make API and back-system service calls. When writing screen form functions, consider the methods

Image description

The simplest visual forms can be learned to make and connected to the server part for processing data and displaying it on the screen. Note that variable declarations at system boundaries are done in a scoped (local/global) manner.
Don't be lazy to explicitly indicate which file is saved to which variable, this will help avoid collisions when saving data. Especially if there're many services and asynchronous stream processing is in progress.

function docolor() {
  var dd1=document.getElementById("d1");
  var colorinput=document.getElementById("clr");
  var color = colorinput.value;
  dd1.style.backgroundColor=color;
}

function dosquare() {
  var dd1=document.getElementById("d1");
  var sizeinput=document.getElementById("slr");
  var size = sizeinput.value;
  var ctx=dd1.getContext("2d");
  ctx.clearRect(0,0, dd1.width, dd1.height);
  ctx.fillStyle="#8B0000";
  ctx.fillRect(10,10,size,size);
  ctx.fillRect(parseInt(size)+20,10,size,size);
  //ctx.fillRect(size*3,10,size,size);
}
Enter fullscreen mode Exit fullscreen mode

Use React to match the master system file image sizes with the image on the screen (slave). Unfortunately, it won't work the other way around, because the handler will only work when receiving/transmitting data on the master device.

Top comments (0)