<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Asjad Khan</title>
    <description>The latest articles on Forem by Asjad Khan (@asjadkhan).</description>
    <link>https://forem.com/asjadkhan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1473438%2Fa99761a9-9d7e-471b-8912-1e71934d9e93.png</url>
      <title>Forem: Asjad Khan</title>
      <link>https://forem.com/asjadkhan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/asjadkhan"/>
    <language>en</language>
    <item>
      <title>Create a Code Explanation Tool using ToolJet and Gemini API</title>
      <dc:creator>Asjad Khan</dc:creator>
      <pubDate>Tue, 28 May 2024 13:01:51 +0000</pubDate>
      <link>https://forem.com/tooljet/create-a-code-explanation-tool-using-tooljet-and-gemini-api-7l3</link>
      <guid>https://forem.com/tooljet/create-a-code-explanation-tool-using-tooljet-and-gemini-api-7l3</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This tutorial will walk you through creating a code explanation tool using &lt;a href="https://github.com/ToolJet/ToolJet" rel="noopener noreferrer"&gt;ToolJet&lt;/a&gt;, a powerful low-code platform, and the &lt;a href="https://ai.google.dev/gemini-api/docs/api-overview" rel="noopener noreferrer"&gt;Gemini API&lt;/a&gt;, an advanced language model API. This tool will allow users to input code snippets and receive detailed explanations, enhancing their understanding of various programming concepts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;Before we begin, make sure you have the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ToolJet&lt;/strong&gt; (&lt;a href="https://github.com/ToolJet/ToolJet" rel="noopener noreferrer"&gt;https://github.com/ToolJet/ToolJet&lt;/a&gt;) : An open-source, low-code platform designed for quickly building and deploying internal tools. Sign up for a free ToolJet cloud account here.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gemini API&lt;/strong&gt; :  A cutting-edge artificial intelligence (AI) model created through a joint effort by various teams within Google. You can find more information and sign up at &lt;a href="https://ai.google.dev/gemini-api/docs/api-key" rel="noopener noreferrer"&gt;Gemini API&lt;/a&gt; to get an API Key, that will be used later in the tutorial.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s the preview of what we’re going to build.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjrz0oa59gupam09fw0ah.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjrz0oa59gupam09fw0ah.png" alt="Preview" width="800" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once we have an idea of what we will build, let’s follow the steps below to start building our app step by step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up the Gemini API
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Once you have set up your account on Gemini API, navigate here to get your API Key. This key will be used to authenticate your requests.&lt;/li&gt;
&lt;li&gt;The endpoint for the code explanation feature looks like this: POST '&lt;a href="https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=YOUR_API_KEY" rel="noopener noreferrer"&gt;https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=YOUR_API_KEY&lt;/a&gt;'.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fun6rd7avuw8jf0mrhece.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fun6rd7avuw8jf0mrhece.png" alt="API Key" width="800" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we have our API Key let’s dive straight into creating the UI as the next step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating the UI
&lt;/h2&gt;

&lt;p&gt;Before creating the UI, let’s create a new ToolJet App. On your ToolJet dashboard, click on the &lt;strong&gt;Create an app&lt;/strong&gt; button and name the app &lt;strong&gt;Code Explanation Tool&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Creating a custom UI is very simple with the help of ToolJet’s &lt;a href="https://docs.tooljet.com/docs/tooljet-concepts/what-are-components" rel="noopener noreferrer"&gt;built-in components&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let’s start by creating the app’s header.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Drag and drop the &lt;strong&gt;Icon&lt;/strong&gt; and a &lt;strong&gt;Text&lt;/strong&gt; Component from the components library on the right and rename them &lt;em&gt;headerIcon&lt;/em&gt; and &lt;em&gt;headerText&lt;/em&gt;, respectively.&lt;/li&gt;
&lt;li&gt;Choose an icon of your choice and customise it, under the &lt;strong&gt;Styles&lt;/strong&gt; section.&lt;/li&gt;
&lt;li&gt;To configure the Text component, click on it and see the &lt;strong&gt;Properties&lt;/strong&gt; Panel on the right.&lt;/li&gt;
&lt;li&gt;Set its &lt;strong&gt;Data&lt;/strong&gt; property to 'Code Explanation Tool', and under the &lt;strong&gt;Styles&lt;/strong&gt; section, change its colour to light blue (Hex code: #4a90e2ff), font-weight to bold and font size to 25.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fku1le8hduyepuubwt2x6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fku1le8hduyepuubwt2x6.png" alt="Header" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Renaming the components will help quickly access their data during development.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add a &lt;strong&gt;Container&lt;/strong&gt; component to the canvas. The Container component is used to group related components.&lt;/li&gt;
&lt;li&gt;Drag and drop a &lt;strong&gt;Text&lt;/strong&gt; component, and in the &lt;strong&gt;Properties&lt;/strong&gt; section, set its &lt;strong&gt;Data&lt;/strong&gt; property to 'Enter your code below'.&lt;/li&gt;
&lt;li&gt;Next, below the text component, add a &lt;strong&gt;Textarea&lt;/strong&gt; component, where we will add the code to get the explanation. Rename it to &lt;em&gt;codeInput&lt;/em&gt;. Adjust the height and width of the component. To make the &lt;em&gt;codeInput&lt;/em&gt; component look neat, adjust the &lt;strong&gt;Boxshadow&lt;/strong&gt; properties in the &lt;strong&gt;Styles&lt;/strong&gt; section.&lt;/li&gt;
&lt;li&gt;Under the &lt;strong&gt;Properties&lt;/strong&gt; section of the &lt;em&gt;codeInput&lt;/em&gt; component, add the following code as the &lt;strong&gt;Default value&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function fun_name (param1 , param2) {
  return param1 * param2 ;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5napix9fip2m96r1xkyt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5napix9fip2m96r1xkyt.png" alt="Code Input" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now that we have our &lt;em&gt;codeInput&lt;/em&gt; component in place, drag and drop a &lt;strong&gt;Button&lt;/strong&gt; component right below it and rename it to &lt;em&gt;getExplanation&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Under its &lt;strong&gt;Button text&lt;/strong&gt; property, add ‘Get Explanation’.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2cvfrsar3w4cb5wzbhrz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2cvfrsar3w4cb5wzbhrz.png" alt="Adding the button component" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s add the portion that will display the explanation for the code that we provide.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Below the &lt;em&gt;getExplanation&lt;/em&gt; button, add a Text component and under the &lt;strong&gt;Data&lt;/strong&gt; property, add the text, ‘Explanation’; under the &lt;strong&gt;Styles&lt;/strong&gt; section, change the &lt;strong&gt;Size&lt;/strong&gt; to 14 and &lt;strong&gt;Weight&lt;/strong&gt; to bold.&lt;/li&gt;
&lt;li&gt;Below the text component, drag and drop the &lt;strong&gt;Textarea&lt;/strong&gt; component; this is where the explanation of our provided code will be displayed. Rename it to &lt;em&gt;codeExplanation&lt;/em&gt;. For now, let’s remove the &lt;strong&gt;Default value&lt;/strong&gt; and keep it blank.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmmmng3q3wb8b1yjmhv9r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmmmng3q3wb8b1yjmhv9r.png" alt="codeExplanation component" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With that, our UI is now ready; it’s time to build the functionality of our application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating Query
&lt;/h2&gt;

&lt;p&gt;With ToolJet, we can create &lt;a href="https://docs.tooljet.com/docs/tooljet-concepts/what-are-queries" rel="noopener noreferrer"&gt;queries&lt;/a&gt;, allowing us to interact with the data stored in the data sources. In this tutorial, we will use ToolJet’s &lt;a href="https://docs.tooljet.com/docs/data-sources/restapi" rel="noopener noreferrer"&gt;REST API query&lt;/a&gt;, to use the Gemini API for the code explanation feature.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expand the &lt;strong&gt;Query Panel&lt;/strong&gt; at the bottom and click the &lt;strong&gt;Add&lt;/strong&gt; button to create a query.&lt;/li&gt;
&lt;li&gt;Choose the &lt;strong&gt;REST API&lt;/strong&gt; query and rename it to &lt;em&gt;getCodeExplanation&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Request&lt;/strong&gt; parameter, choose &lt;strong&gt;POST&lt;/strong&gt; as the &lt;strong&gt;Method&lt;/strong&gt; from the drop-down and replace the &lt;strong&gt;URL&lt;/strong&gt; with: &lt;code&gt;https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=&amp;lt;YOUR_API_KEY&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Replace &lt;code&gt;&amp;lt;YOUR_API_KEY&amp;gt;&lt;/code&gt; with the API Key you generated while creating an account on Gemini API, as mentioned in the start of the tutorial.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Body&lt;/strong&gt; section, toggle on &lt;strong&gt;Raw JSON&lt;/strong&gt; and replace it with the following code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{`{
  "contents": [
    {
      "parts": [
        {
          "text": "This ${components.codeInput.value.replaceAll("\n"," ")}",
        },
      ],
    },
  ],
}`}}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;In ToolJet, &lt;a href="https://docs.tooljet.com/docs/tooljet-concepts/how-to-access-values" rel="noopener noreferrer"&gt;double curly braces&lt;/a&gt; &lt;code&gt;{{}}&lt;/code&gt;  can be used to pass custom code and access data related to components and queries.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To ensure that the query runs every time the application loads, enable &lt;strong&gt;Run this query on application load?&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click on the &lt;strong&gt;Run&lt;/strong&gt; button to run the query, and you can see that the explanation of the default value code we entered in our &lt;em&gt;codeInput&lt;/em&gt; component is provided.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0zb3qsa2tmdhkt4nhywe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0zb3qsa2tmdhkt4nhywe.png" alt="Query" width="800" height="549"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Binding the Query and the Query Data to the Components
&lt;/h2&gt;

&lt;p&gt;As our query is running successfully and we are fetching the code explanation from Gemini API, it’s time to bind the query to our &lt;em&gt;getExplanation&lt;/em&gt; button and display the data in the &lt;em&gt;codeExplanation&lt;/em&gt; component.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select the &lt;em&gt;getExplanation&lt;/em&gt; button, under the &lt;strong&gt;Properties&lt;/strong&gt; section, and click the &lt;strong&gt;New event handler&lt;/strong&gt; button to create a new &lt;strong&gt;Event&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;On click&lt;/strong&gt; as the &lt;strong&gt;Event&lt;/strong&gt;, &lt;strong&gt;Run Query&lt;/strong&gt; as the &lt;strong&gt;Action&lt;/strong&gt;, and select &lt;em&gt;getCodeExplanation&lt;/em&gt; as the &lt;strong&gt;Query&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgil68va9wot80fyamo1o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgil68va9wot80fyamo1o.png" alt="Button Event" width="800" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This event will ensure that whenever we click the &lt;em&gt;getExplanation&lt;/em&gt; button, the &lt;em&gt;getCodeExplanation&lt;/em&gt; query is being run.&lt;/p&gt;

&lt;p&gt;Now, let's display the code explanation in our &lt;em&gt;codeExplanation&lt;/em&gt; component.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select the &lt;em&gt;codeExplanation&lt;/em&gt; component, and under the &lt;strong&gt;Default value&lt;/strong&gt; property, add the following code: &lt;code&gt;{{queries.getCodeExplanation.data.candidates[0].content.parts[0].text.replace(/\*\*/g, '').replace(/\*/g, '')}}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Next, click on the &lt;em&gt;getExplanation&lt;/em&gt; button, and if you followed the above steps correctly, you should now be able to see the explanation of the provided code displayed in the &lt;em&gt;codeExplanation&lt;/em&gt; component.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkje62014xsoe300a08h4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkje62014xsoe300a08h4.png" alt="Final App" width="800" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our app is now ready; try adding different pieces of codes in the &lt;em&gt;codeInput&lt;/em&gt; component, and to generate an explanation, click on the &lt;em&gt;getExplanation&lt;/em&gt; button to see the explanation being displayed &lt;em&gt;codeExplanation&lt;/em&gt; component.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Congratulations! You've successfully created a code explanation tool using ToolJet and the Gemini API. This tool can help users understand complex code snippets, making learning and debugging more efficient. With ToolJet's low-code capabilities and Gemini's powerful language model, you can further enhance this tool by adding features like code formatting, language detection, and more.&lt;/p&gt;

&lt;p&gt;To learn and explore more about ToolJet, check out the &lt;a href="https://docs.tooljet.com/docs/" rel="noopener noreferrer"&gt;ToolJet docs&lt;/a&gt; or connect with us and post your queries on &lt;a href="https://join.slack.com/t/tooljet/shared_invite/zt-2ij7t3rzo-qV7WTUTyDVQkwVxTlpxQqw" rel="noopener noreferrer"&gt;Slack&lt;/a&gt;. Happy coding!&lt;/p&gt;

</description>
      <category>lowcode</category>
      <category>tooljet</category>
      <category>restapi</category>
      <category>gemini</category>
    </item>
    <item>
      <title>Create a Weather App using ToolJet and OpenWeatherMap API</title>
      <dc:creator>Asjad Khan</dc:creator>
      <pubDate>Thu, 23 May 2024 13:07:01 +0000</pubDate>
      <link>https://forem.com/tooljet/create-a-weather-app-using-tooljet-and-openweathermap-api-3cfm</link>
      <guid>https://forem.com/tooljet/create-a-weather-app-using-tooljet-and-openweathermap-api-3cfm</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In this tutorial, we will create a weather app using &lt;a href="https://github.com/ToolJet/ToolJet" rel="noopener noreferrer"&gt;ToolJet&lt;/a&gt; and OpenWeatherMap. By the end of this guide, you'll have a functional app that fetches and displays weather data for any city using the OpenWeatherMap API.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites:
&lt;/h3&gt;

&lt;p&gt;Before we start, make sure you have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ToolJet (&lt;a href="https://github.com/ToolJet/ToolJet" rel="noopener noreferrer"&gt;https://github.com/ToolJet/ToolJet&lt;/a&gt;) :&lt;/strong&gt; An open-source, low-code platform allowing you to build internal tools and applications rapidly. If you don’t have an account, sign up for a free ToolJet cloud account &lt;a href="https://app.tooljet.com/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API Key from OpenWeatherMap :&lt;/strong&gt; Create an account on &lt;a href="https://openweathermap.org/api" rel="noopener noreferrer"&gt;OpenWeatherMap&lt;/a&gt; to generate an API Key that will be used while we create queries to fetch the weather data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s a quick preview of the app that we will be building by the end of this tutorial:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4n95j5xyp3sumxj3q2co.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4n95j5xyp3sumxj3q2co.png" alt="Preview" width="800" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before creating the UI, let’s create a new ToolJet App. On your ToolJet dashboard, click on the &lt;strong&gt;Create an app&lt;/strong&gt; button and name the app &lt;strong&gt;Weather App&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Once the app is created, we can start with the UI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating the UI
&lt;/h2&gt;

&lt;p&gt;Creating a custom UI is straightforward with the help of ToolJet’s &lt;a href="https://docs.tooljet.com/docs/tooljet-concepts/what-are-components" rel="noopener noreferrer"&gt;built-in components&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let’s start by creating the app’s header.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Drag and drop the &lt;strong&gt;Icon&lt;/strong&gt; and a &lt;strong&gt;Text&lt;/strong&gt; Component from the &lt;a href="https://docs.tooljet.com/docs/tooljet-concepts/what-are-components" rel="noopener noreferrer"&gt;components library&lt;/a&gt; on the right and rename them to &lt;em&gt;headerIcon&lt;/em&gt; and &lt;em&gt;headerText&lt;/em&gt;, respectively.&lt;/li&gt;
&lt;li&gt;To configure the Text component, click on it and see the Properties Panel on the right.&lt;/li&gt;
&lt;li&gt;Set its &lt;strong&gt;Data&lt;/strong&gt; property to 'Weather App', and under the &lt;strong&gt;Styles&lt;/strong&gt; section, change its colour to light blue (Hex code: #4a90e2ff), font-weight to bold and font size to 25.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhe39zz6hovu1juqtmhxq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhe39zz6hovu1juqtmhxq.png" alt="Header" width="800" height="433"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Renaming components is an effective way to refer to components as the app grows.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once the header is ready, drag and drop a &lt;strong&gt;Text Input&lt;/strong&gt; component onto the canvas. This is where we will be entering our desired locations. Rename it to &lt;em&gt;locationInput&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;For &lt;em&gt;locationInput&lt;/em&gt;, change &lt;strong&gt;Label&lt;/strong&gt; to &lt;strong&gt;Enter Location&lt;/strong&gt; and &lt;strong&gt;Placeholder&lt;/strong&gt; to &lt;strong&gt;Enter Location&lt;/strong&gt;. Let’s set the default value to 'San Francisco'.&lt;/li&gt;
&lt;li&gt;Next to &lt;em&gt;locationInput&lt;/em&gt; component, add a &lt;strong&gt;Button&lt;/strong&gt; component, rename it to &lt;em&gt;getWeatherButton&lt;/em&gt;, and change the &lt;strong&gt;Button text&lt;/strong&gt; property to &lt;strong&gt;Get Weather&lt;/strong&gt; from the properties panel. From the &lt;strong&gt;Styles&lt;/strong&gt; tab, change the &lt;strong&gt;Background color&lt;/strong&gt; of the button to blue (Hex code: #4a90e2ff).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faku05shl8sxp2uoro9al.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faku05shl8sxp2uoro9al.png" alt="Text Input Component" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next we will create the layout where we will be displaying the weather data.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Drag and drop a &lt;strong&gt;Container&lt;/strong&gt; component. Containers are used to group related components.&lt;/li&gt;
&lt;li&gt;Add an &lt;strong&gt;Image&lt;/strong&gt; component inside the Container and rename it to &lt;em&gt;weatherImage&lt;/em&gt;. This component will be used to display the weather through an image later in the tutorial. For now, let’s add a dummy image. In the &lt;strong&gt;URL&lt;/strong&gt; section, add the URL, &lt;a href="http://openweathermap.org/img/wn/02d@2x.png" rel="noopener noreferrer"&gt;http://openweathermap.org/img/wn/02d@2x.png&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Next, add two &lt;strong&gt;Text&lt;/strong&gt; components and rename them to &lt;em&gt;weatherDescription&lt;/em&gt; and &lt;em&gt;locationText&lt;/em&gt;, respectively. Add some dummy text under their &lt;strong&gt;Data&lt;/strong&gt; property. The dummy data will be made dynamic as the tutorial progresses.&lt;/li&gt;
&lt;li&gt;For both the text components, in the &lt;strong&gt;Styles&lt;/strong&gt; section, change the font size to 25, font-weight to bold and alignment to center.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd447becefrefqvgjv8sz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd447becefrefqvgjv8sz.png" alt="Basic Layout" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will also display a particular location's humidity and wind speed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Drag and drop the &lt;strong&gt;Image&lt;/strong&gt; component and rename it to &lt;em&gt;humidityIcon&lt;/em&gt;. In the &lt;strong&gt;URL&lt;/strong&gt; property, let’s use the following URL for now: &lt;a href="https://cdn.iconscout.com/icon/premium/png-512-thumb/humidity-14-532297.png?f=webp&amp;amp;w=512" rel="noopener noreferrer"&gt;https://cdn.iconscout.com/icon/premium/png-512-thumb/humidity-14-532297.png?f=webp&amp;amp;w=512&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Place two Text components next to the Image component and rename them to &lt;em&gt;humidityPrecent&lt;/em&gt; and &lt;em&gt;humidityText&lt;/em&gt; respectively. In the Styles section, set the font weight to bold for both.&lt;/li&gt;
&lt;li&gt;For the &lt;em&gt;humidityPercent&lt;/em&gt; and &lt;em&gt;humidityText&lt;/em&gt; components, add some dummy data in the &lt;strong&gt;Data&lt;/strong&gt; section of the Properties panel. As the tutorial progresses, we will be fetching the humidity data dynamically.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flxb487s9tpw0pvvdwqrk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flxb487s9tpw0pvvdwqrk.png" alt="Humidity Layout" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To add wind-speed data, copy the Image and Text components and paste them beside the humidity section.&lt;/li&gt;
&lt;li&gt;Rename the Image component to &lt;em&gt;windspeedImage&lt;/em&gt; and the Text components to &lt;em&gt;windpseed&lt;/em&gt; and &lt;em&gt;windspeedText&lt;/em&gt;, respectively.&lt;/li&gt;
&lt;li&gt;Select the &lt;em&gt;windspeedImage&lt;/em&gt; component, and in the &lt;strong&gt;URL&lt;/strong&gt; section, add the following URL for the image: &lt;a href="https://cdn.iconscout.com/icon/premium/png-512-thumb/wind-336-974466.png?f=webp&amp;amp;w=512" rel="noopener noreferrer"&gt;https://cdn.iconscout.com/icon/premium/png-512-thumb/wind-336-974466.png?f=webp&amp;amp;w=512&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Select the &lt;em&gt;windspeed&lt;/em&gt; component, add some dummy data in the &lt;strong&gt;Data&lt;/strong&gt; property. In the &lt;strong&gt;Styles&lt;/strong&gt; tab, set the font weight to bold.&lt;/li&gt;
&lt;li&gt;For the &lt;em&gt;windspeedText&lt;/em&gt; component, add some dummy data in the &lt;strong&gt;Data&lt;/strong&gt; property. In the &lt;strong&gt;Styles&lt;/strong&gt; tab, set the weight to bold.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48nibp9b9brsqyude2l0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48nibp9b9brsqyude2l0.png" alt="Windspeed Layout" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the above steps, our UI is now ready. It’s time to use OpenWeatherMap API to fetch the weather data for our desired location.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use OpenWeatherMap API to Fetch Weather Data
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Creating the Query
&lt;/h3&gt;

&lt;p&gt;To fetch the weather data from OpenWeatherMap API, we will use ToolJet’s &lt;a href="https://docs.tooljet.com/docs/tooljet-concepts/what-are-queries" rel="noopener noreferrer"&gt;queries&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Follow the steps below to create a query and fetch the data.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expand the &lt;strong&gt;Query Panel&lt;/strong&gt; at the bottom and click the &lt;strong&gt;Add&lt;/strong&gt; button to create a query.&lt;/li&gt;
&lt;li&gt;Choose the &lt;strong&gt;REST API&lt;/strong&gt; query and rename it to &lt;em&gt;getWeatherData&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Since we will just be fetching the data, in the &lt;strong&gt;Request&lt;/strong&gt; section, choose the &lt;strong&gt;Method&lt;/strong&gt; as &lt;strong&gt;GET&lt;/strong&gt; from the dropdown, and add the following as the &lt;strong&gt;URL&lt;/strong&gt;: &lt;code&gt;https://api.openweathermap.org/data/2.5/weather?q=&amp;lt;LOCATION&amp;gt;&amp;amp;appid=&amp;lt;APP_ID&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Replace &lt;strong&gt;&lt;/strong&gt; with the following code: &lt;code&gt;{{components.locationInput.value}}&lt;/code&gt;; since we have set the default value to 'San Francisco', the location will be replaced with 'San Francisco' for now.&lt;/li&gt;
&lt;li&gt;Replace the &lt;strong&gt;&lt;/strong&gt; with the API Key that you generated while creating an account on OpenWeatherMap API.&lt;/li&gt;
&lt;li&gt;To ensure that the query runs every time the application loads, enable &lt;strong&gt;Run this query on application load?&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click on the &lt;strong&gt;Run&lt;/strong&gt; button to see that the weather data is being fetched from the OpenWeatherMap API for the city of San Francisco.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftnrp51aj8i48tr2r6a8v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftnrp51aj8i48tr2r6a8v.png" alt="Query" width="800" height="547"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;In ToolJet, &lt;a href="https://docs.tooljet.com/docs/tooljet-concepts/how-to-access-values" rel="noopener noreferrer"&gt;double curly braces&lt;/a&gt; are used to access or refer dynamic values.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Adding Event to &lt;em&gt;locationInput&lt;/em&gt; and &lt;em&gt;getWeatherButton&lt;/em&gt; Components
&lt;/h3&gt;

&lt;p&gt;Now that we’re successfully configured the query, we will bind this query to our &lt;em&gt;locationInput&lt;/em&gt; and &lt;em&gt;getWeatherButton&lt;/em&gt; components.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select the &lt;em&gt;locationInput&lt;/em&gt; component. In the properties panel, click on the &lt;strong&gt;&lt;a href="https://docs.tooljet.com/docs/tooljet-concepts/what-are-events" rel="noopener noreferrer"&gt;New event handler&lt;/a&gt;&lt;/strong&gt; button, set &lt;strong&gt;Event&lt;/strong&gt; as &lt;strong&gt;On enter pressed&lt;/strong&gt;, choose &lt;strong&gt;Action&lt;/strong&gt; as &lt;strong&gt;Run Query&lt;/strong&gt;, and select &lt;em&gt;getWeatherData&lt;/em&gt; as the query.&lt;/li&gt;
&lt;li&gt;To test it, let’s change the location to 'London' and press enter. If you followed the above steps correctly, the query should fetch the data related to London.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh6yf9ks5o54eu9v81q7r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh6yf9ks5o54eu9v81q7r.png" alt="On enter pressed" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We would also want the query to run once we enter a location and press the &lt;strong&gt;Get Weather&lt;/strong&gt; button. To do so, follow the steps below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select the &lt;em&gt;getWeatherButton&lt;/em&gt; button, and click on &lt;strong&gt;New event handler&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Choose the &lt;strong&gt;Event&lt;/strong&gt; as &lt;strong&gt;On click&lt;/strong&gt;, &lt;strong&gt;Action&lt;/strong&gt; as &lt;strong&gt;Run Query&lt;/strong&gt;, and select &lt;em&gt;getWeatherData&lt;/em&gt; as the &lt;strong&gt;Query&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;If you followed the above steps correctly, you can now run the query after clicking on the &lt;strong&gt;Get Weather&lt;/strong&gt; button.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3dedxjb8z45imwklbfyn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3dedxjb8z45imwklbfyn.png" alt="On Click" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Binding the Data to the Components
&lt;/h3&gt;

&lt;p&gt;Since we can now fetch the queries by pressing enter and clicking on the &lt;strong&gt;Get Weather&lt;/strong&gt; button, we will bind the fetched data to our UI to make our app dynamic.&lt;/p&gt;

&lt;p&gt;Let’s start with the weatherImage component first.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select the &lt;em&gt;weatherImage&lt;/em&gt; component, and replace the URL with &lt;code&gt;http://openweathermap.org/img/wn/{{queries.getWeatherData.data.weather[0].icon}}@2x.png&lt;/code&gt;. This will ensure, that the image changes accordingly with the weather of a particular city.&lt;/li&gt;
&lt;li&gt;Next, select the weatherDescription component and replace the text under the &lt;strong&gt;Data&lt;/strong&gt; property with the following code: 
&lt;code&gt;{{Math.round((queries.getWeatherData.data.main.temp - 273.15) * 10) / 10}} °C, {{queries.getWeatherData.data.weather[0].description}}&lt;/code&gt;. Here, we’re converting the temperature to degrees Celsius and adding the weather description.&lt;/li&gt;
&lt;li&gt;Select the &lt;em&gt;locationText&lt;/em&gt; component, and add the following code to the &lt;strong&gt;Data&lt;/strong&gt; property: &lt;code&gt;{{queries.getWeatherData.data.name}}&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr2rsxut1p7gv9td82htg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr2rsxut1p7gv9td82htg.png" alt="Weather Descsription" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you followed the above steps correctly, you should see the image, temperature, weather description and city name changing according to the location we’re adding to the &lt;em&gt;locationInput&lt;/em&gt; component.&lt;/p&gt;

&lt;p&gt;The last step would be to display the actual humidity percentage and the windspeed of the entered location.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select the &lt;em&gt;humidityPercent&lt;/em&gt; component, add &lt;code&gt;{{queries.getWeatherData.data.main.humidity}}%&lt;/code&gt; under the &lt;strong&gt;Data&lt;/strong&gt; property. This will give the humidity percentage of the entered location.&lt;/li&gt;
&lt;li&gt;Next, click on the &lt;em&gt;windspeed&lt;/em&gt; component, and add &lt;code&gt;{{queries.getWeatherData.data.wind.speed}} Km/h&lt;/code&gt; under the &lt;strong&gt;Data&lt;/strong&gt; property. This will display the wind speed of the entered location.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8gtqynlshz9l5v1uowjg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8gtqynlshz9l5v1uowjg.png" alt="Final Image" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you have followed all the steps mentioned above, you can see that all of the component data gets updated after running the query according to the location we add.&lt;/p&gt;

&lt;p&gt;To make sure that our app displays a loader whenever the data is being fetched for the new city, select the Container component and in the &lt;strong&gt;Loading state&lt;/strong&gt; property, click &lt;em&gt;fx&lt;/em&gt; and add &lt;code&gt;{{queries.getWeatherData.isLoading}}&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;You've successfully built a weather app using ToolJet by consuming the OpenWeatherMap REST API. This simple app demonstrates how straightforward it is to create functional apps in ToolJet. To know more about what &lt;a href="https://docs.tooljet.com/docs/" rel="noopener noreferrer"&gt;ToolJet&lt;/a&gt; can do, visit the ToolJet docs or join us and post your queries on &lt;a href="https://join.slack.com/t/tooljet/shared_invite/zt-2ij7t3rzo-qV7WTUTyDVQkwVxTlpxQqw" rel="noopener noreferrer"&gt;Slack&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>restapi</category>
      <category>lowcode</category>
      <category>tooljet</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Build an Employee Engagement Survey Dashboard using ToolJet</title>
      <dc:creator>Asjad Khan</dc:creator>
      <pubDate>Tue, 21 May 2024 13:03:24 +0000</pubDate>
      <link>https://forem.com/tooljet/build-an-employee-engagement-survey-dashboard-using-tooljet-5bed</link>
      <guid>https://forem.com/tooljet/build-an-employee-engagement-survey-dashboard-using-tooljet-5bed</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Employee engagement is a critical factor in the success of any organization. It reflects how committed and motivated employees are towards their work and the organization’s goals. To effectively measure and understand employee engagement, organizations often conduct surveys that capture valuable insights from their workforce. However, collecting data is only the first step. Analysing and presenting this data meaningfully is essential for making informed decisions that enhance employee satisfaction and productivity.&lt;/p&gt;

&lt;p&gt;This tutorial will walk you through creating an &lt;strong&gt;Employee Engagement Survey Dashboard&lt;/strong&gt; using &lt;a href="https://github.com/ToolJet/ToolJet" rel="noopener noreferrer"&gt;ToolJet&lt;/a&gt;, an open-source low-code platform. By the end of this tutorial, you will have a fully functional dashboard that visually represents your survey results, enabling you to identify trends, areas of improvement, and actionable insights.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ToolJet (&lt;a href="https://github.com/ToolJet/ToolJet" rel="noopener noreferrer"&gt;https://github.com/ToolJet/ToolJet&lt;/a&gt;) :&lt;/strong&gt; An open-source, low-code platform for quickly building and deploying internal tools. Sign up for a free ToolJet cloud account &lt;a href="https://app.tooljet.com/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Basic understanding of JavaScript :&lt;/strong&gt; Familiarity with JavaScript concepts will help you follow the tutorial more effectively.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s a quick preview of what our final dashboard looks like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjvupeeqqsl1cow4x6sxe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjvupeeqqsl1cow4x6sxe.png" alt="Final Image" width="800" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This tutorial will use the employee survey data which contains responses to various questions, such as job satisfaction, work environment, and compensation. &lt;/p&gt;

&lt;p&gt;The employee data will be stored in a table in the &lt;strong&gt;&lt;a href="https://docs.tooljet.com/docs/tooljet-db/tooljet-database" rel="noopener noreferrer"&gt;ToolJet Database&lt;/a&gt;&lt;/strong&gt; - ToolJet's in-built database that makes data management simple and efficient.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9wwvfuqixhzrkdo4859m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9wwvfuqixhzrkdo4859m.png" alt="Employee Data" width="800" height="254"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Designing the UI
&lt;/h2&gt;

&lt;p&gt;With the help of ToolJet’s &lt;a href="https://docs.tooljet.com/docs/widgets/overview" rel="noopener noreferrer"&gt;pre-built components&lt;/a&gt;, we will design a simple UI for our application.&lt;/p&gt;

&lt;p&gt;The first step will be creating an app. Log in to your ToolJet account to access the dashboard. Click on &lt;strong&gt;Create an App button&lt;/strong&gt;, and let's name our app &lt;strong&gt;Employee Engagement Survey&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Once our app is ready, let’s dive into creating the UI.&lt;/p&gt;

&lt;p&gt;We will start by creating the header.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Creating the Header
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Drag and drop the &lt;strong&gt;Text&lt;/strong&gt; Component from the components library onto the canvas.&lt;/li&gt;
&lt;li&gt;Rename the Text Component to &lt;em&gt;headerText&lt;/em&gt;, and change its &lt;strong&gt;Data&lt;/strong&gt; property to &lt;em&gt;Employee Engagement Survey&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;In the Styles section, change the font size to 25 and the font weight to bold.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frf07em41qs720fv4ytzv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frf07em41qs720fv4ytzv.png" alt="Header" width="800" height="433"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Renaming components is an effective way to refer to components as we progress further while creating the application.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Creating the Dashboard Panel
&lt;/h3&gt;

&lt;p&gt;In this step, we will create the layout of our dashboard. To design the dashboard, follow the steps below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Drag and drop the &lt;strong&gt;Container&lt;/strong&gt; component onto the canvas. Containers are used to group components.&lt;/li&gt;
&lt;li&gt;Once we have the Container component in place, drag and drop three &lt;strong&gt;Chart&lt;/strong&gt; components and place them next to each other. Rename them &lt;em&gt;pieChart&lt;/em&gt;, &lt;em&gt;barChart,&lt;/em&gt; and &lt;em&gt;lineChart&lt;/em&gt;, respectively.&lt;/li&gt;
&lt;li&gt;Enable &lt;strong&gt;Plotly JSON Chart Schema&lt;/strong&gt; for all three. We will modify the &lt;strong&gt;JSON Description&lt;/strong&gt; according to the desired chart later in the tutorial.&lt;/li&gt;
&lt;li&gt;To add neat borders to the Chart components, adjust their &lt;strong&gt;Box shadow&lt;/strong&gt; properties under the &lt;strong&gt;Styles&lt;/strong&gt; tab.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fryp9og7gtojbnrhxq602.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fryp9og7gtojbnrhxq602.png" alt="Adding Charts" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Drag and drop the &lt;strong&gt;Table&lt;/strong&gt; Component onto the canvas just below the charts. The Table will display the data stored in the ToolJet Database.&lt;/li&gt;
&lt;li&gt;Rename the Table component to &lt;em&gt;employeeSurveyTable&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcslhd1sdktfq0uflrhi4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcslhd1sdktfq0uflrhi4.png" alt="Add Table" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The app UI is now ready. It’s time to add some functionality.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fetching and Displaying the Data in the Dashboard
&lt;/h2&gt;

&lt;p&gt;Let’s fetch and display our data in our ToolJetDB on the table.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Fetching the Data and Displaying it on the Table
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Open the Query Panel at the bottom of the screen, click the &lt;strong&gt;+Add&lt;/strong&gt; button and create a new ToolJet Database &lt;a href="https://docs.tooljet.com/docs/tooljet-concepts/what-are-queries" rel="noopener noreferrer"&gt;query&lt;/a&gt; and rename it to &lt;em&gt;fetchEmployeeData&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Select &lt;em&gt;employeeSurveyData&lt;/em&gt; as the &lt;strong&gt;Table name&lt;/strong&gt; and &lt;strong&gt;List rows&lt;/strong&gt; as the &lt;strong&gt;Operations&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;To ensure that the query runs every time the application loads, enable &lt;strong&gt;Run this query on application load?&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Run&lt;/strong&gt; button to see the data fetched from the &lt;em&gt;employeeSurveyData&lt;/em&gt; database.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16yj5zqpehngnifcc5mk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16yj5zqpehngnifcc5mk.png" alt="Fetch Survey Data" width="800" height="545"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once we can fetch the data, select the &lt;em&gt;employeeSurveyTable&lt;/em&gt; component, and in the &lt;strong&gt;Data&lt;/strong&gt; property, add the following code: &lt;code&gt;{{queries.fetchEmployeeData.data}}&lt;/code&gt;. You should now see the data returned by the query on the Table component.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu9ry8ydx03eii4dmgzb3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu9ry8ydx03eii4dmgzb3.png" alt="Add Employee Data" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Displaying the Data through Charts
&lt;/h3&gt;

&lt;p&gt;Next we'll display data on the charts.&lt;/p&gt;

&lt;h3&gt;
  
  
  a.) Pie Chart
&lt;/h3&gt;

&lt;p&gt;First, we will display data based on &lt;strong&gt;“Job_Satisfaction”&lt;/strong&gt; through a Pie Chart. We must convert the data we fetched into a &lt;strong&gt;Plotly JSON Chart Schema&lt;/strong&gt; for a pie chart.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expand the Query Panel, create a new &lt;strong&gt;Run JavaScript Code&lt;/strong&gt; query, and rename it to &lt;em&gt;pieChart&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;In the code editor, paste the following code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// run the fetchEmployeeData query
await queries.fetchEmployeeData.run();
const data = queries.fetchEmployeeData.getData();
function generatePlotlyPieChartData(data) {
  // Step 1: Extract and count job satisfaction values
  const jobSatisfactionCounts = data.reduce((acc, curr) =&amp;gt; {
    const satisfaction = curr.job_satisfaction;
    if (acc[satisfaction]) {
      acc[satisfaction]++;
    } else {
      acc[satisfaction] = 1;
    }
    return acc;
  }, {});

  // Step 2: Prepare labels and values for the pie chart
  const labels = Object.keys(jobSatisfactionCounts);
  const values = Object.values(jobSatisfactionCounts);

  // Step 3: Generate Plotly pie chart schema
  const plotlyPieChartSchema = {
    type: 'pie',
    labels: labels,
    values: values,
    textinfo: 'percent',
    insidetextorientation: 'radial'
  };

  return plotlyPieChartSchema;
}

// Generate Plotly pie chart data
const plotlyPieChartData = generatePlotlyPieChartData(data);

// converts the plotlyPieChartData into a string
const finalData = JSON.stringify(plotlyPieChartData);

return finalData;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;This code turns the data in the 'Job_Satisfaction' column into the format that is accepted by a Plotly pie chart.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To ensure that the query runs every time the application loads, enable &lt;strong&gt;Run this query on application load?&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Run&lt;/strong&gt; button to see the data formatted for a pie chart.&lt;/li&gt;
&lt;li&gt;Next, select the &lt;em&gt;pieChart&lt;/em&gt; component and in the &lt;strong&gt;JSON Description&lt;/strong&gt; of the &lt;em&gt;pieChart&lt;/em&gt; component, replace the value under the "data" key with &lt;code&gt;{{queries.pieChart.data}}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If you follow the above steps correctly, you can see the data displayed via a pie chart.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4v9op8bj49ashijwpeqc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4v9op8bj49ashijwpeqc.png" alt="pieChart" width="800" height="432"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;For better understanding, in the &lt;strong&gt;Properties&lt;/strong&gt; panel of pieChart, change the &lt;strong&gt;Title&lt;/strong&gt; to &lt;strong&gt;Employee Satisfaction Index&lt;/strong&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  b.) Bar Chart
&lt;/h3&gt;

&lt;p&gt;Next, we will display data based on &lt;strong&gt;“Work_Environment”&lt;/strong&gt; through a Bar Chart. We must first convert the data we fetched into a &lt;strong&gt;Plotly JSON Chart Schema&lt;/strong&gt; for a bar chart.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expand the Query Panel, create another  &lt;strong&gt;Run JavaScript Code&lt;/strong&gt; query, and rename it to &lt;em&gt;barChart&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;In the code editor, paste the following code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// run the fetchEmployeeData query
await queries.fetchEmployeeData.run();
const data = queries.fetchEmployeeData.getData();
function generateWorkEnvironmentBarChartData(data) {
  // Step 1: Extract and count job satisfaction values grouped by work_environment
  const workEnvironmentCounts = data.reduce((acc, curr) =&amp;gt; {
    const workEnvironment = curr.work_environment;
    if (acc[workEnvironment]) {
      acc[workEnvironment]++;
    } else {
      acc[workEnvironment] = 1;
    }
    return acc;
  }, {});

  // Step 2: Prepare x (work environment levels) and y (counts) for the bar chart
  const x = Object.keys(workEnvironmentCounts);
  const y = Object.values(workEnvironmentCounts);

  // Step 3: Generate Plotly bar chart schema
  const plotlyBarChartSchema = {
    type: 'bar',
    x: x,
    y: y,
    marker: { color: 'blue' }
  };

  return plotlyBarChartSchema;
}

// Generate Plotly bar chart data
const plotlyBarChartData = generateWorkEnvironmentBarChartData(data);

// converts the plotlyBarChartData into a string
const finalData = JSON.stringify(plotlyBarChartData);

return finalData;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;This code turns the data in the 'Work_Environment' column into the format that is accepted by a bar chart&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To ensure that the query runs every time the application loads, enable &lt;strong&gt;Run this query on application load?&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click on the &lt;strong&gt;Run&lt;/strong&gt; button; you should now see the data based on the &lt;strong&gt;“work_environment”&lt;/strong&gt; column and in a format accepted by a bar chart.&lt;/li&gt;
&lt;li&gt;Next, in the &lt;strong&gt;JSON Description&lt;/strong&gt; of the &lt;em&gt;barChart&lt;/em&gt; component, replace the value under the "data" key with &lt;code&gt;{{queries.barChart.data}}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Properties&lt;/strong&gt; panel, edit the &lt;strong&gt;Title&lt;/strong&gt; to &lt;strong&gt;Work Environment Index&lt;/strong&gt; for better reference.&lt;/li&gt;
&lt;li&gt;If you follow the above steps correctly, you can see the data in the &lt;strong&gt;"Work_Environment"&lt;/strong&gt; column displayed via a bar chart.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ihpvahyxem63t76oukq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ihpvahyxem63t76oukq.png" alt="Bar Chart" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  c.) Line Chart
&lt;/h3&gt;

&lt;p&gt;Lastly, we will display data based on &lt;strong&gt;“Compensation”&lt;/strong&gt; through a Line Chart. We must first convert the data we fetched into a &lt;strong&gt;Plotly JSON Chart Schema&lt;/strong&gt; for a line chart.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expand the Query Panel, create a new &lt;strong&gt;Run JavaScript Code&lt;/strong&gt; query, and rename it to &lt;em&gt;lineChart&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;In the code editor, paste the following code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
// run the fetchEmployeeData query
await queries.fetchEmployeeData.run();
const data = queries.fetchEmployeeData.getData();
function generatePlotlyLineChartData(data) {
  // Step 1: Extract and count job satisfaction values grouped by compensation
  const compensationCounts = data.reduce((acc, curr) =&amp;gt; {
    const compensation = curr.compensation;
    if (acc[compensation]) {
      acc[compensation]++;
    } else {
      acc[compensation] = 1;
    }
    return acc;
  }, {});

  // Step 2: Prepare x (compensation levels) and y (counts) for the line chart
  const x = Object.keys(compensationCounts);
  const y = Object.values(compensationCounts);

  // Step 3: Generate Plotly line chart schema
  const plotlyLineChartSchema = {
    type: 'scatter',
    mode: 'lines+markers',
    x: x,
    y: y,
    marker: {color: 'blue'},
    line: {shape: 'linear'}
  };

  return plotlyLineChartSchema;
}

// Generate Plotly line chart data
const plotlyLineChartData = generatePlotlyLineChartData(data);

// converts the plotlyLineChartData into a string
const finalData = JSON.stringify(plotlyLineChartData);

return finalData;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;This code turns the data in the 'Compensation' column into the format that is accepted by a line chart&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To ensure that the query runs every time the application loads, enable &lt;strong&gt;Run this query on application load?&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click on the &lt;strong&gt;Run&lt;/strong&gt; button to see the data based on the &lt;strong&gt;“compensation”&lt;/strong&gt; column and in a format accepted by a line chart.&lt;/li&gt;
&lt;li&gt;Next, in the &lt;strong&gt;JSON Description&lt;/strong&gt; of the &lt;em&gt;lineChart&lt;/em&gt; component, replace the “data” value with &lt;code&gt;{{queries.lineChart.data}}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Edit the &lt;strong&gt;Title&lt;/strong&gt; to &lt;strong&gt;Compensation Index&lt;/strong&gt; in the &lt;strong&gt;Properties&lt;/strong&gt; panel for better understanding.&lt;/li&gt;
&lt;li&gt;If you follow the above steps correctly, you can see the data displayed based on &lt;strong&gt;"Compensation"&lt;/strong&gt; via a line chart.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5jyqtj4063r79jgt7j73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5jyqtj4063r79jgt7j73.png" alt="Line Chart" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Congratulations, you have successfully created an Employee Engagement Survey Dashboard. You can customise this dashboard according to your needs by utilizing other pre-built components in ToolJet. To know more about the capabilities of ToolJet, look at the official &lt;a href="https://docs.tooljet.com/docs" rel="noopener noreferrer"&gt;ToolJet docs&lt;/a&gt; or connect with us on &lt;a href="https://join.slack.com/t/tooljet/shared_invite/zt-2ij7t3rzo-qV7WTUTyDVQkwVxTlpxQqw" rel="noopener noreferrer"&gt;Slack&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>tooljet</category>
      <category>javascript</category>
      <category>lowcode</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Implement Advanced Chart Types like Heatmaps and Contour Plots</title>
      <dc:creator>Asjad Khan</dc:creator>
      <pubDate>Tue, 14 May 2024 12:53:58 +0000</pubDate>
      <link>https://forem.com/tooljet/implement-advanced-chart-types-like-heatmaps-and-contour-plots-3h1f</link>
      <guid>https://forem.com/tooljet/implement-advanced-chart-types-like-heatmaps-and-contour-plots-3h1f</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This tutorial will explore implementing advanced chart types like Heatmaps and Contour plots using ToolJet’s Chart Component. &lt;a href="https://github.com/ToolJet/ToolJet" rel="noopener noreferrer"&gt;ToolJet&lt;/a&gt; provides excellent tools for visualizing complex datasets. By the end of this tutorial, you will learn how to integrate these sophisticated visualizations into your applications. Heatmaps and contour plots are invaluable for revealing patterns and gradients in data. Let's dive into the steps to create these visual elements efficiently.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ToolJet (&lt;a href="https://github.com/ToolJet/ToolJet" rel="noopener noreferrer"&gt;https://github.com/ToolJet/ToolJet&lt;/a&gt;) :&lt;/strong&gt; An open-source, low-code platform for quickly building and deploying internal tools. Sign up for a free ToolJet cloud account &lt;a href="https://app.tooljet.com/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Basic understanding of JavaScript :&lt;/strong&gt; Familiarity with JavaScript concepts will help you follow the tutorial more effectively.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s what our final application will look like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnz5snuexm4kyncfv17yh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnz5snuexm4kyncfv17yh.png" alt="Final Application" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For this tutorial, we will use temperature variations during different times of the day across the week for London and Paris.&lt;/p&gt;

&lt;p&gt;The weather data will be stored in two tables in the &lt;strong&gt;&lt;a href="https://docs.tooljet.com/docs/tooljet-db/tooljet-database" rel="noopener noreferrer"&gt;ToolJet Database&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8vqqladt6xgmoi8muc1x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8vqqladt6xgmoi8muc1x.png" alt="London Weather DB" width="800" height="221"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4pi9f13ku329ewq6argz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4pi9f13ku329ewq6argz.png" alt="Paris Weather DB" width="800" height="221"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Designing the UI
&lt;/h2&gt;

&lt;p&gt;Creating a user-friendly UI is pretty straightforward with the help of ToolJet’s built-in components.&lt;/p&gt;

&lt;p&gt;Let’s start by creating the header.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Adding the Header
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Drag and drop the &lt;strong&gt;Text&lt;/strong&gt; Component from the components library on the canvas.&lt;/li&gt;
&lt;li&gt;Rename the Text Component to &lt;em&gt;headerText&lt;/em&gt;, and change the Data property to &lt;strong&gt;London and Paris Weather Analysis&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Styles&lt;/strong&gt; section, change the font size to 28 and the font weight to bold.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftn7ko43wt3vostaxxdct.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftn7ko43wt3vostaxxdct.png" alt="Header" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Adding the Chart Component
&lt;/h3&gt;

&lt;p&gt;Since we will analyse the data through &lt;strong&gt;Charts&lt;/strong&gt;, we will use ToolJet’s Chart Component.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Drag and drop a Chart component from the Components library. &lt;/li&gt;
&lt;li&gt;Select the Chart component, rename it to &lt;em&gt;heatmapChart&lt;/em&gt; and enable &lt;strong&gt;Plotly JSON Chart Schema&lt;/strong&gt;, and in the &lt;strong&gt;JSON Description&lt;/strong&gt; section.&lt;/li&gt;
&lt;li&gt;Add the following code for a placeholder chart:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "data": [
        {
            "z": [[1, 20, 30], [20, 1, 60], [30, 60, 1]],
            "x": ["Experiment 1", "Experiment 2", "Experiment 3"],
            "y": ["Trial 1", "Trial 2", "Trial 3"],
            "type": "heatmap"
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This will create a placeholder heatmap based on the data provided above. In the later sections of the tutorial, we will be able to create a heatmap based on our own data. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4clzlb7l1nlv5qvoosiy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4clzlb7l1nlv5qvoosiy.png" alt="Initial Heatmap" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Next, drag and drop another Chart component next to the heatmap. Since this will be a contour, rename it to &lt;em&gt;countourChart&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Enable the &lt;strong&gt;Plotly JSON Chart Schema&lt;/strong&gt; and provide the following &lt;strong&gt;JSON Description&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
"data": [
    {
      "x": [1, 2, 3, 4],
      "y": [1, 2, 3, 4],
      "z": [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]],
      "type": "contour"
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;You should now see a contour plot next to the heatmap.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjbdbs4hmfob48kj5irea.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjbdbs4hmfob48kj5irea.png" alt="Contour" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;To know more about the examples available for the Chart component, visit ToolJet’s documentation for &lt;a href="https://docs.tooljet.com/docs/widgets/chart/chart-examples" rel="noopener noreferrer"&gt;Charts&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The UI is now ready. It’s time to display some actual data through Heatmaps and Contours.&lt;/p&gt;

&lt;h2&gt;
  
  
  Analysing Data through Heatmap and Contour Plot
&lt;/h2&gt;

&lt;p&gt;Let’s fetch London’s temperature variation data from our &lt;em&gt;londonWeather DB&lt;/em&gt; and displaying it through the Heatmap. Here are the steps to implement it.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Fetching the Data for the Heatmap
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Expand the &lt;strong&gt;Query Panel&lt;/strong&gt; at the bottom of the screen and create a new &lt;a href="https://docs.tooljet.com/docs/tooljet-concepts/what-are-queries" rel="noopener noreferrer"&gt;query&lt;/a&gt; - rename it to &lt;em&gt;fetchLondonWeather&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Select &lt;em&gt;londonWeather&lt;/em&gt; as the &lt;strong&gt;Table name&lt;/strong&gt; and &lt;strong&gt;List rows&lt;/strong&gt; as the &lt;strong&gt;Operations&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;To ensure that the query runs every time the application loads, in the &lt;strong&gt;Settings&lt;/strong&gt; property toggle, &lt;strong&gt;Run this query on application load?&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Run&lt;/strong&gt; button to see the data fetched from your &lt;em&gt;londonWeather&lt;/em&gt; database.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqaepacz691akpxg7io6e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqaepacz691akpxg7io6e.png" alt="Fetch London Weather" width="800" height="547"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Creating RunJS Query to Display the Data on the Heatmap
&lt;/h3&gt;

&lt;p&gt;As we can now fetch our data, we must convert it into the format that the heatmap accepts. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expand the Query Panel, create a new &lt;strong&gt;Run JavaScript Code&lt;/strong&gt; query, and rename it to &lt;em&gt;heatmap&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;In the code editor, paste the following code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//run the fetchLondonWeather query
await queries.fetchLondonWeather.run();
//get data from the fetchLondonWeather query
const data = queries.fetchLondonWeather.getData();

function convertDataToHeatmapJSON(data) {
    // Assuming each object has a time_day label and each weekday as a key
    const days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'];
    const times = data.map(item =&amp;gt; item.time);
    const z = data.map(item =&amp;gt;
        days.map(day =&amp;gt; item[day]) // Construct rows for each time slot
    );

    // Constructing the Plotly JSON
    const plotlyJSON = {
            x: days.map(day =&amp;gt; day.charAt(0).toUpperCase() + day.slice(1)), // Capitalize day names
            y: times,
            z: z,
      type: 'heatmap',
    };

    return plotlyJSON;
}

const heatmapJSON = convertDataToHeatmapJSON(data);

const heatmapData = JSON.stringify(heatmapJSON); //converting the data to string

return heatmapData;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;The JavaScript code above converts the data fetched from the londonWeather database to a &lt;strong&gt;Plotly JSON Chart Schema&lt;/strong&gt; for a heatmap.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on the &lt;strong&gt;Run&lt;/strong&gt; button to see the data formatted to three axes, named &lt;strong&gt;x&lt;/strong&gt;, &lt;strong&gt;y&lt;/strong&gt; and &lt;strong&gt;z&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Next, in the &lt;strong&gt;JSON Description&lt;/strong&gt; of the &lt;em&gt;heatmapChart&lt;/em&gt; component, replace “&lt;strong&gt;data&lt;/strong&gt;” value with &lt;code&gt;{{queries.heatmap.data}}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If you follow the above steps correctly, you can see the data displayed via heatmap.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqauzh4tg4kykl2l8pomq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqauzh4tg4kykl2l8pomq.png" alt="London Heatmap" width="800" height="434"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;To make the heatmap more descriptive, replace the &lt;strong&gt;Title&lt;/strong&gt; from the properties panel with &lt;strong&gt;London&lt;/strong&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We will use similar data for a different city, Paris, to implement a contour plot. As mentioned in the tutorial, our data is stored in the &lt;em&gt;parisWeather DB&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Fetching the Data for the Contour Plot
&lt;/h3&gt;

&lt;p&gt;To fetch the data for Paris, we need to follow the similar steps mentioned in Step 1.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expand the Query Panel, create a new &lt;strong&gt;ToolJet Database query&lt;/strong&gt;, and rename it to &lt;em&gt;fetchParisWeather&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Select &lt;em&gt;parisWeather&lt;/em&gt; as the &lt;strong&gt;Table name&lt;/strong&gt; and &lt;strong&gt;List rows&lt;/strong&gt; as the &lt;strong&gt;Operations&lt;/strong&gt;. Also, toggle the &lt;strong&gt;Run this query on application load?.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Run&lt;/strong&gt; button to see the data fetched from your &lt;em&gt;parisWeather&lt;/em&gt; database.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr4pahw9dda27z0uo9ynf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr4pahw9dda27z0uo9ynf.png" alt="Fetch Paris Weather" width="800" height="548"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Creating RunJS Query to Display the Data on the Contour Plot
&lt;/h3&gt;

&lt;p&gt;Now that we can fetch our data, we must convert it into the format the contour plot accepts.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expand the Query Panel, create a new &lt;strong&gt;Run JavaScript Code&lt;/strong&gt; query, and rename it to &lt;em&gt;contour&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;In the code editor, paste the following code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//run the fetchParisWeather query
await queries.fetchParisWeather.run();
//get data from the fetchDataParis query
const data = queries.fetchParisWeather.getData();

function convertToContourPlotJSON(data) {
    // Extract unique days and times assuming data is sorted by time
    const days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'];
    const times = data.map(item =&amp;gt; item.time);

    // Construct the z matrix
    const z = data.map(item =&amp;gt;
        days.map(day =&amp;gt; item[day.toLowerCase()]) // Access day values; ensure day keys are in lowercase
    );

    // Constructing the Plotly JSON for a contour plot
    const plotlyJSON = {
            x: days,   // Day labels
            y: times,  // Time labels
            z: z,     // Matrix of values
            type: 'contour',
    };

    return plotlyJSON;
}

const contourPlotJSON = convertToContourPlotJSON(data);

const contourData = JSON.stringify(contourPlotJSON); //converting the data to string

return contourData;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;The JavaScript code above converts the data fetched from the parisWeather table to a &lt;strong&gt;Plotly JSON Chart Schema&lt;/strong&gt; for a contour plot.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on the &lt;strong&gt;Run&lt;/strong&gt; button to see the data.&lt;/li&gt;
&lt;li&gt;Next, in the &lt;strong&gt;JSON Description&lt;/strong&gt; of the &lt;em&gt;contourChart&lt;/em&gt; component, replace “&lt;strong&gt;data&lt;/strong&gt;” value with &lt;code&gt;{{queries.contour.data}}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Following the above steps correctly, you can see the data displayed via a contour plot.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fug72lurcu2cwr1tn0ae6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fug72lurcu2cwr1tn0ae6.png" alt="Paris Contour" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Let’s update the &lt;strong&gt;Title&lt;/strong&gt; of the contourChart Component to &lt;strong&gt;Paris&lt;/strong&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Congratulations!
&lt;/h2&gt;

&lt;p&gt;Awesome job completing this tutorial on Implementing Advanced Chart Types like Heatmaps and Contour Plots. This tutorial gives us an overview of using different chart types available on ToolJet to analyse data. To continue exploring other Chart options available on ToolJet, check out the &lt;a href="https://docs.tooljet.com/docs/" rel="noopener noreferrer"&gt;ToolJet docs&lt;/a&gt; on charts.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>lowcode</category>
      <category>tooljet</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Build a Todo Application Using ToolJet and ToolJetDB</title>
      <dc:creator>Asjad Khan</dc:creator>
      <pubDate>Wed, 08 May 2024 14:59:59 +0000</pubDate>
      <link>https://forem.com/tooljet/build-a-todo-application-using-tooljet-and-tooljetdb-3fbp</link>
      <guid>https://forem.com/tooljet/build-a-todo-application-using-tooljet-and-tooljetdb-3fbp</guid>
      <description>&lt;p&gt;This tutorial provides a step-by-step walkthrough for creating a Todo application with &lt;a href="https://github.com/ToolJet/ToolJet" rel="noopener noreferrer"&gt;ToolJet&lt;/a&gt;. This application allows tracking of daily tasks, distinguishing between pending and completed activities. Throughout this tutorial, we will leverage ToolJet's built-in database (ToolJet DB) to manage the application's data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ToolJet&lt;/strong&gt; (&lt;a href="https://github.com/ToolJet/ToolJet" rel="noopener noreferrer"&gt;https://github.com/ToolJet/ToolJet&lt;/a&gt;) : An open-source, low-code platform designed for quickly building and deploying internal tools. Sign up for a free ToolJet cloud account &lt;a href="https://app.tooljet.com/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Basic understanding of databases and JavaScript :&lt;/strong&gt; Familiarity with database concepts and JavaScript will help you follow along more effectively.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s what the final application will look like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0wj8kmldu4w1l89lzx1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0wj8kmldu4w1l89lzx1.png" alt="Final Application" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  We’ll build the Todo App in three steps:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Setup:&lt;/strong&gt; From your new application’s workspace, find the 'ToolJet Database' panel on the left sidebar click on  ‘Create new table’ and then create a new app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Building the UI:&lt;/strong&gt; Using ToolJet's visual app-builder and pre-built components, we'll craft a UI for selecting languages and entering code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adding Functionality:&lt;/strong&gt; This is where the major part of the application comes in. We will create queries to add, display, and update the status of our Todos.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Setting up the ToolJet Database is pretty simple. We will configure the database and create a new app after that.&lt;/li&gt;
&lt;li&gt;Once you login, find the ToolJet Database panel on the left sidebar and click on the Create new table button.&lt;/li&gt;
&lt;li&gt;Next, name the table that you’ve just created. For this tutorial, we are naming our database as todoList, and adding the following fields:

&lt;ul&gt;
&lt;li&gt;id (Primary Key, Auto-increment)&lt;/li&gt;
&lt;li&gt;task (String)&lt;/li&gt;
&lt;li&gt;status (Boolean)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;We will also add dummy data to our Database, which will be fetched first once we create a table for our application in the next steps.&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F30jeng7l7dc29j22u0fq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F30jeng7l7dc29j22u0fq.png" alt="Dummy Data in the ToolJetDB" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now that we have created our database table, click on the &lt;strong&gt;Apps&lt;/strong&gt; icon in the left sidebar and select &lt;strong&gt;Create new app&lt;/strong&gt;. Name your app &lt;em&gt;Todo Application&lt;/em&gt; and click &lt;strong&gt;Create app&lt;/strong&gt; to confirm the app creation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can start building the UI now that our basic setup is ready.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the UI
&lt;/h2&gt;

&lt;p&gt;Creating an appealing UI with ToolJet is quick and simple with its visual app-builder and inbuilt components. We will start building the UI by creating the header first.&lt;/p&gt;

&lt;p&gt;ToolJet makes UI creation quick and easy with its visual app-builder and pre-built components! We'll start by creating the header.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Designing the Header
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Drag and drop an &lt;strong&gt;Icon&lt;/strong&gt; component from the components library.&lt;/li&gt;
&lt;li&gt;Click on the Icon component, navigate to its Properties Panel on the right and select the checklist symbol under its &lt;strong&gt;Icon&lt;/strong&gt; property.&lt;/li&gt;
&lt;li&gt;Place a &lt;strong&gt;Text&lt;/strong&gt; component beside it and enter &lt;strong&gt;Todo Application&lt;/strong&gt; under its &lt;strong&gt;Data&lt;/strong&gt; property.&lt;/li&gt;
&lt;li&gt;Next, change its font size to 24 and font-weight to bold.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzho6sfdyuz3u2pdmvqio.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzho6sfdyuz3u2pdmvqio.png" alt="Adding the Header Component" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Adding the Table Component
&lt;/h3&gt;

&lt;p&gt;To display the todos, we will use the &lt;strong&gt;Table&lt;/strong&gt; Component.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Drag and drop a Table component on the canvas. Let’s rename the Table component to &lt;em&gt;todoTable&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fin9lendgxk1v7avhvtdw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fin9lendgxk1v7avhvtdw.png" alt="Table Component" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Adding Text Input and a Logo Component
&lt;/h3&gt;

&lt;p&gt;Once the Table component is added to list our todos, we would need an option to add a new todo. We would add a &lt;strong&gt;Text Input&lt;/strong&gt; and a &lt;strong&gt;Logo&lt;/strong&gt; Component that will act as a button to add a new todo.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Below the Table, drag and drop the &lt;strong&gt;Text Input&lt;/strong&gt; component and name the component &lt;em&gt;addTodoInput&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Next to the Text Input component, drop an &lt;strong&gt;Icon&lt;/strong&gt; component choose &lt;em&gt;IconCirclePlus&lt;/em&gt; as the icon and name it to addTodoButton.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvq64sobrby47b56j6lyc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvq64sobrby47b56j6lyc.png" alt="Text Input and Logo Component" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that our UI is ready, let’s dive into adding functionality to our app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding Functionality
&lt;/h2&gt;

&lt;p&gt;ToolJet allows us to interact with the UI of an application that we easily create with the ToolJet DB. We will integrate the ToolJet Database we created earlier with our UI by creating queries.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Creating Query to Fetch the Data
&lt;/h3&gt;

&lt;p&gt;Let's first fetch the dummy todo that we created earlier in the tutorial.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Expand the Query Panel at the bottom of the screen and click the &lt;strong&gt;+Add&lt;/strong&gt; button to create a new query - rename it &lt;em&gt;fetchTodos&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Choose &lt;em&gt;todoList&lt;/em&gt; as the &lt;strong&gt;Table name&lt;/strong&gt; and &lt;strong&gt;List rows&lt;/strong&gt; as the &lt;strong&gt;Operation&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;Settings&lt;/strong&gt;, toggle the &lt;strong&gt;Run this query on application?&lt;/strong&gt; to run this query every time the app reloads.&lt;/li&gt;
&lt;li&gt;Click on the &lt;strong&gt;Run&lt;/strong&gt; Button to run the query - you can now see the dummy data that we had added earlier under &lt;strong&gt;Preview&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fefl539srpernidy861yk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fefl539srpernidy861yk.png" alt="fetch query" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Binding the Fetched Data to &lt;em&gt;todoTable&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;Once we successfully fetch the data, we would want to display it on our todoTable .&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open the Properties Panel of the todoTable, and in the &lt;strong&gt;Data&lt;/strong&gt; property, enter &lt;code&gt;{{queries.fetchTodos.data}}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Now you should see the dummy data on our table.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffz88lki16h6g2gdt3ri7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffz88lki16h6g2gdt3ri7.png" alt="Data binded to _todoTable_" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Creating &lt;em&gt;addTodo&lt;/em&gt; Query
&lt;/h3&gt;

&lt;p&gt;Now that we can fetch the data in our table, it’s time to create a new query that adds the data to our ToolJet DB.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expand the Query Panel at the bottom of the screen and click on the &lt;strong&gt;+Add&lt;/strong&gt; button to create a new query - rename it to addTodos.&lt;/li&gt;
&lt;li&gt;Choose &lt;em&gt;todoList&lt;/em&gt; as the Table name, and Create row as the operation.&lt;/li&gt;
&lt;li&gt;Since we will be adding a new todo, with two columns named &lt;strong&gt;Task&lt;/strong&gt; and &lt;strong&gt;Status&lt;/strong&gt;, in the &lt;strong&gt;Columns&lt;/strong&gt; property, &lt;strong&gt;click + Add&lt;/strong&gt; column, and perform the following:

&lt;ul&gt;
&lt;li&gt;Choose &lt;strong&gt;task&lt;/strong&gt; from the dropdown, and in the &lt;strong&gt;value&lt;/strong&gt;, add the code:  &lt;code&gt;{{components.addTodoInput.value}}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;For the second column, choose &lt;strong&gt;status&lt;/strong&gt; from the dropdown and set its &lt;strong&gt;value&lt;/strong&gt; to false.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Under &lt;strong&gt;Events&lt;/strong&gt;, add a &lt;strong&gt;New Event Handler&lt;/strong&gt;, select &lt;strong&gt;Query Success&lt;/strong&gt; as the Event and &lt;strong&gt;Run Query&lt;/strong&gt; as the Action. Under &lt;strong&gt;Action Options&lt;/strong&gt;, choose &lt;em&gt;fetchTodos&lt;/em&gt; as the Query.  This will ensure that whenever a new todo is added, fetchTodos query is run again to fetch all the todos, including the newly added one.&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu8pn1ex24v8ysgkcqdwb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu8pn1ex24v8ysgkcqdwb.png" alt="_addTodo_ Query" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Binding the &lt;em&gt;addTodos&lt;/em&gt; Query to Components
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Click on the &lt;em&gt;addTodoInput&lt;/em&gt; component, and in the Properties Panel, create a new event by clicking on the &lt;strong&gt;New event handler&lt;/strong&gt; button.&lt;/li&gt;
&lt;li&gt;To add a new todo by just pressing enter after typing in the addTodoInput component, lets choose the &lt;strong&gt;Event&lt;/strong&gt; as &lt;strong&gt;On enter pressed&lt;/strong&gt; and the &lt;strong&gt;Action&lt;/strong&gt; as &lt;strong&gt;Run Query&lt;/strong&gt;. In the &lt;strong&gt;Action Options&lt;/strong&gt;, choose the &lt;em&gt;addTodos&lt;/em&gt; query. This will add a new todo(which is the value in the addTodoInput component) to the table once we press enter.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fol4hlttp1gxtxvlrr9wo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fol4hlttp1gxtxvlrr9wo.png" alt="_addTodoInput_" width="800" height="464"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To clear the input area after pressing enter, create another &lt;strong&gt;On enter pressed&lt;/strong&gt; event, with the action of &lt;strong&gt;Control component&lt;/strong&gt;, choose the component as &lt;em&gt;addTodoInput&lt;/em&gt; and &lt;strong&gt;Action&lt;/strong&gt; to &lt;strong&gt;clear&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdsdfa3vj5ql6nf087yvw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdsdfa3vj5ql6nf087yvw.png" alt="_addTodoInput_" width="800" height="502"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To also add the functionality of adding a new todo by clicking on the &lt;em&gt;addTodoButton&lt;/em&gt; component(Icon component), add an event to run the &lt;em&gt;addTodos&lt;/em&gt; query and another one to clear the &lt;em&gt;addTodoInput&lt;/em&gt; component. But choose &lt;strong&gt;On click&lt;/strong&gt; as the &lt;strong&gt;Action&lt;/strong&gt; instead of &lt;strong&gt;On enter pressed&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Following the above steps, we can add new todos to our table.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo3yb1taoff8jp6ak1c5u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo3yb1taoff8jp6ak1c5u.png" alt="Adding Todos" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Add Action Buttons to the Table
&lt;/h3&gt;

&lt;p&gt;Now that we can add new todos to our table, we would want to add the functionality of changing their status to complete or deleting them. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to the Properties Panel of the &lt;em&gt;todoTable&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Under the Action Buttons property, click the &lt;strong&gt;+ New action button&lt;/strong&gt; and create two new action buttons, &lt;strong&gt;Completed&lt;/strong&gt; and &lt;strong&gt;Delete&lt;/strong&gt;, respectively (The labels can be added in the &lt;strong&gt;Button Text&lt;/strong&gt; property).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frjoqf9ds2ij1b9dkivj8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frjoqf9ds2ij1b9dkivj8.png" alt="Action Buttons" width="800" height="950"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Updating the Status of the Todo
&lt;/h3&gt;

&lt;p&gt;Whenever we complete our todos, we would want them to be marked as completed. To update the todo status, we will create a new query and name it &lt;em&gt;updateTodo&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the Query Panel, click the +Add button to create a new query - rename it to &lt;em&gt;updateTodo&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Choose todoList as the Table name and Update rows as the operation.&lt;/li&gt;
&lt;li&gt;Since we will update the todo by id, in the &lt;strong&gt;Filter&lt;/strong&gt; property, choose id as the column, equals as the operation and the value to be &lt;code&gt;{{components.todoTable.selectedRow.id}}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Columns&lt;/strong&gt; property, choose status from the dropdown and set its value to true.&lt;/li&gt;
&lt;li&gt;After updating the status of our todos, we would want to fetch all the items again, so for that, we will create a new event in this query. For the new event, select &lt;strong&gt;Query Success&lt;/strong&gt; as the &lt;strong&gt;Event&lt;/strong&gt; and &lt;strong&gt;Run Query&lt;/strong&gt; as the &lt;strong&gt;Action&lt;/strong&gt;, and choose &lt;em&gt;fetchTodos&lt;/em&gt; as the Query from the dropdown.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwin1r6ooau0c3ktebz78.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwin1r6ooau0c3ktebz78.png" alt="_updateTodo_ Query" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Deleting the Todo
&lt;/h3&gt;

&lt;p&gt;After we have completed our pending Todo, we would want to delete it. To do so, let’s create a new query that deletes a particular Todo.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a new query from the Query Panel and name it as &lt;em&gt;deleteTodo&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Choose todoList as the &lt;strong&gt;Table name&lt;/strong&gt; and &lt;strong&gt;Delete rows&lt;/strong&gt; as the &lt;strong&gt;Operation&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;From the &lt;strong&gt;Filter&lt;/strong&gt; option, choose id as the column, equals as the operation, and set its value to: &lt;code&gt;{{components.todoTable.selectedRow.id}}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Under Events, add a &lt;strong&gt;New Event Handler&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Query Success&lt;/strong&gt; as the &lt;strong&gt;Event&lt;/strong&gt; and &lt;strong&gt;Run Query&lt;/strong&gt; as the &lt;strong&gt;Action&lt;/strong&gt;,  choose &lt;em&gt;fetchTodos&lt;/em&gt; as the Query from the dropdown.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fveusxb5w16imwwyhkgod.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fveusxb5w16imwwyhkgod.png" alt="_deleTodo_ Query" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Binding Update and Delete Queries to the Completed and Delete Action Buttons.
&lt;/h3&gt;

&lt;p&gt;The final step for our application to be fully functional would be to make our Completed and Deleted buttons to work.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to the Properties Panel of &lt;em&gt;todoTable&lt;/em&gt;, and select the &lt;strong&gt;Completed&lt;/strong&gt; button, from the &lt;strong&gt;Action Buttons&lt;/strong&gt; property, create a new event handler for this button and choose &lt;strong&gt;On click&lt;/strong&gt; as the &lt;strong&gt;Event&lt;/strong&gt;, &lt;strong&gt;Run Query&lt;/strong&gt; as the &lt;strong&gt;Action&lt;/strong&gt; and from the &lt;strong&gt;Action Options&lt;/strong&gt;, choose the query as &lt;em&gt;updateTodo&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsrrrmn8r0kqmczrbo1d0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsrrrmn8r0kqmczrbo1d0.png" alt="Completed Button" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now, go to the Properties Panel of &lt;em&gt;todoTable&lt;/em&gt; again, and select the &lt;strong&gt;Delete&lt;/strong&gt; button, from the &lt;strong&gt;Action Buttons&lt;/strong&gt; property, create a new event handler for this button and choose On click as the &lt;strong&gt;Event&lt;/strong&gt;, &lt;strong&gt;Run Query&lt;/strong&gt; as the &lt;strong&gt;Action&lt;/strong&gt; and from the &lt;strong&gt;Action Options&lt;/strong&gt;, choose the query as &lt;em&gt;deleteTodo&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl617o4bac4vqls27y7n0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl617o4bac4vqls27y7n0.png" alt="Delete Button" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now once you click on the &lt;strong&gt;Completed&lt;/strong&gt; action button, the todo will be marked as completed and the status will be updated accordingly. Similarly, the &lt;strong&gt;Delete&lt;/strong&gt; button will delete the todo.&lt;/p&gt;

&lt;h2&gt;
  
  
  Congratulations!
&lt;/h2&gt;

&lt;p&gt;Great job on successfully building a fully functional Todo Application! Ready to dive deeper? Explore more possibilities and expand your skills with our extensive &lt;a href="https://docs.tooljet.com/docs/" rel="noopener noreferrer"&gt;ToolJet docs&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>lowcode</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
