0

Cytoscape.js JSON format is something like this :

var cy = cytoscape({
    style: [
    {
      selector: 'node',
      style: {
        shape: 'hexagon',
        'background-color': 'red',
        label: 'data(id)'
      }
    }],
  container: document.getElementById('cy'),
  elements: [
    { data: { id: 'a' }     },
    { data: { id: 'b' } },
    {
      data: {
        id: 'ab',
        source: 'a',
        target: 'b',
      }
    }]

});

I have been able to generate elements part myself, but I don't know how to generate other parts using C#. Should I do some kind of concatenation because other parts are not dynamic? If yes, how should I do that? Thanks.

2
  • You shouldn't be using string concatenation. Create an object structure, then serialize that to JSON. See, for example stackoverflow.com/questions/1056121/…. Commented May 1, 2017 at 16:25
  • 3
    That's a JS object, not JSON. JSON element keys must be in quotes, and doesn't support things like document.getElementById(...) Commented May 1, 2017 at 16:53

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.