Documentation Home
MySQL Shell for VS Code


MySQL Shell for VS Code  /  JavaScript  /  DB Notebook: Show Data in Visual Graph Format

Pre-General Availability: 2024-03-18

8.4 DB Notebook: Show Data in Visual Graph Format

DB Notebook: Display population in a bar chart using LIMIT

runSql("SELECT Name, Population FROM world.country LIMIT 10;", function (result) {
    var options = {
        series: [
            {
                id: "myFirstGraph",
                type: "bar",
                yLabel: "Country Population",
                data: result,
                marginLeft: 60,
                marginBottom: 30,
                yDomain: [0, 50000000]
            },
        ],
    };
    Graph.render(options);
});
Note

The previous code snippet includes some TypeScript options that can emit an informational type error. TypeScript and JavaScript share the same engine. You can ignore the error or switch to TypeScript mode and run a similar code example (see Section 9.4, “DB Notebook: Show Data in Visual Graph Format”).