microsoft / quantum-viz.js

quantum-viz.js is a configurable tool for rendering quantum circuits using pure HTML.
Other
44 stars 14 forks source link

Improve API #19

Open theRoughCode opened 3 years ago

theRoughCode commented 3 years ago

Our current API for the package looks like this:

const sampleCircuit = {
    qubits: [
        // ...
    ],
    operations: [
        // ...
    ],
};
const sampleDiv = document.getElementById('sample');
qviz.draw(sampleCircuit, sampleDiv, qviz.STYLES['Default']);

A few things that would make for a good interface are:

  1. Easy to use
  2. Customizable (i.e. style, interactivity, custom augmentations)
  3. Easy to read

A good example of an interface that we can draw inspiration from is d3.js:

d3.select("body")
  .selectAll("p")
  .data([4, 8, 15, 16, 23, 42])
  .enter().append("p")
    .text(function(d) { return "I’m number " + d + "!"; });

We can select a DOM element, add data to it, and customize it. A similar API for Sqore would work really well.

anpaz commented 3 years ago

A couple more things the API should allow: