Create a chart from SQL

Re-create this chart example

Use the code below:

-- Declare variables
DECLARE @ChartData NVARCHAR(MAX);
DECLARE @ChartOptions NVARCHAR(MAX);
DECLARE @ChartTitle NVARCHAR(100) = 'Monthly Sales 2023';
DECLARE @ChartType NVARCHAR(20) = 'bar';
DECLARE @ChartName NVARCHAR(100) = 'MonthlySalesChart';
DECLARE @ChartHeight NVARCHAR(10) = '400px';
DECLARE @CloseButton NVARCHAR(100);

-- Create temporary table
IF OBJECT_ID('tempdb..#MonthlySales') IS NOT NULL DROP TABLE #MonthlySales;
CREATE TABLE #MonthlySales (
    dataset NVARCHAR(20),
    label NVARCHAR(20),
    number DECIMAL(10,2),
    [order] INT,
    color NVARCHAR(20)
);

-- Insert sample data
INSERT INTO #MonthlySales (dataset, label, number, [order], color)
VALUES 
('2023', 'January', 1000, 1, NULL),
('2023', 'February', 1200, 2, NULL),
('2023', 'March', 1500, 3, NULL),
('2023', 'April', 1300, 4, NULL),
('2023', 'May', 1700, 5, NULL),
('2023', 'June', 1600, 6, NULL);

-- Set chart options
SET @ChartOptions = '{"responsive": true, "maintainAspectRatio": false}';

-- Synchronize CloseButton value
EXEC sp_api_modal_get_value @name='@CloseButton', @value=@CloseButton OUT;

-- Create modal content
EXEC sp_api_modal_text @text='Monthly Sales Chart 2023', @class='h2';

-- Create the chart
EXEC sp_api_modal_chart
    @name = @ChartName,
    @tmptable = '#MonthlySales',
    @class = 'w-100',
    @type = @ChartType,
    @options = @ChartOptions,
    @title = @ChartTitle,
    @height = @ChartHeight;

-- Add explanatory text
EXEC sp_api_modal_text @text='This chart shows the monthly sales figures for 2023.';

-- Add close button
EXEC sp_api_modal_button 
    @name='close', 
    @value='Close Chart', 
    @valueout=@CloseButton OUT,
    @class='btn-primary';

-- Handle close button click
IF @CloseButton IS NOT NULL
BEGIN
    EXEC sp_api_modal_clear;
    EXEC sp_api_toast @text='Chart view closed.', @class='success';
    RETURN;
END

-- Clean up
DROP TABLE #MonthlySales;