<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by John Bellizzi on Medium]]></title>
        <description><![CDATA[Stories by John Bellizzi on Medium]]></description>
        <link>https://medium.com/@jbellizzi?source=rss-7295723f35ae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*ofbFXHpAtIfGPNwBlBgR4Q.jpeg</url>
            <title>Stories by John Bellizzi on Medium</title>
            <link>https://medium.com/@jbellizzi?source=rss-7295723f35ae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 16:58:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jbellizzi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Accessing the Qlik Engine API From React Using Qlik Hooks]]></title>
            <link>https://medium.com/swlh/accessing-the-qlik-engine-api-from-react-using-qlik-hooks-54fe09568e8d?source=rss-7295723f35ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/54fe09568e8d</guid>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[qlik-sense]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[John Bellizzi]]></dc:creator>
            <pubDate>Tue, 06 Oct 2020 20:57:13 GMT</pubDate>
            <atom:updated>2020-10-09T23:38:08.867Z</atom:updated>
            <content:encoded><![CDATA[<p>Most React developers are familiar with React Hooks which has been around for a couple years now. If you’re not, definitely check out how they work <a href="https://reactjs.org/docs/hooks-intro.html">here</a>.</p><p>When I first met React Hooks, I fell in love. When our team builds applications that are driven by the Qlik engine, we need a way to handle the varying states of requests and responses from the API. If I want to display data from a hypercube in a chart, I need to request the data using GetLayout(). If I want to request the layout of the hypercube, I first need to create the hypercube and wait until the engine gives me the handle of the new object I created. If I want to create a new object, I need to wait until I’ve opened the app. If I… ok i think you get the point.</p><p>This isn’t a new problem really. We’ve always had to handle asynchronous dependencies when working with the engine API. Typically this means using JavaScript promises returned from Enigma.js, or Observables from RxQ. But React Hooks make defining and using connections to the engine easier.</p><h3>Connecting to the engine</h3><p>Before continuing, set up a React sandbox to test in using create react app, and also install qlik-hooks</p><p>npm install --save qlik-hooks</p><p>We’ll run all these examples in App.js.</p><p>Define a config object that will connect to a Qlik Sense engine (I’m using the Qlik demo site)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/07c2c7ae5ea450ce5200980f78840d79/href">https://medium.com/media/07c2c7ae5ea450ce5200980f78840d79/href</a></iframe><p>Now import the useConnectEngine hook from qlik-hooks and pass the config object in to it</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7dcf25746844641fb9ca5de00a9190e/href">https://medium.com/media/e7dcf25746844641fb9ca5de00a9190e/href</a></iframe><p>You will first see engine returned with loading: true and handle: null. Then, if the connection is made successfully, loading will be false and handle will have a Global handle defined.</p><h3>Making an API call</h3><p>Now that we have a connection, let’s see how we can actually send an api request to get the version of the engine we are working with.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9044683737597428377068ddeaa255a0/href">https://medium.com/media/9044683737597428377068ddeaa255a0/href</a></iframe><p>After we import useEngineVersion from the Global directory of qlik-hooks, we can use it by passing in 2 parameters. The first parameter is the object that contains the handle we are running the method on. In this case, it’s the engine object we defined above. The second parameter is an object that contains a property params that will have all the arguments passed into the EngineVersion API method (in this case, there are no arguments needed so we pass an empty array).</p><p>For the first few renders, engineVersion.qResponse will be null while the engine is still connecting and the client is waiting for a response from the EngineVersion method. If it returns successfully, you will end up with a qResponse object containing the information requested from Qlik Sense.</p><p>So what’s so special about this? On its own, this isn’t really anything groundbreaking. We’re already able to get data with other Qlik Engine libraries.</p><p>The main benefit here is how React can be leveraged using this new Hook model. Whenever the state within a React component function updates, the component will rerender. So instead of having to listen for a valid response from EngineVersion, we can just tell React to use engineVersion.qResponse if it exists, or ignore it until it is not null</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b4029d87cd46561f59442ae1b71c38f/href">https://medium.com/media/2b4029d87cd46561f59442ae1b71c38f/href</a></iframe><p>No need to handle calling a render function on your own. When the state of engineVersion updates, the component will automatically rerender, and if engineVersion has a qResponse, we’ll display the information in the app.</p><h3>Opening an app</h3><p>Let’s take this one step further and display some properties from a Qlik app on our site</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1bb1ec8b4dff49fc2934e934a6a15d8/href">https://medium.com/media/f1bb1ec8b4dff49fc2934e934a6a15d8/href</a></iframe><p>We can open an application using the useOpenDoc hook and passing the app id into the params array property. Then, we can pass the app object into useGetAppProperties to get information about the app. Finally, we use the response in appProps to render information on our site.</p><p>What’s nice about Qlik Hooks is I don’t have to worry about waiting for a handle response from the OpenDoc method before I call GetAppProperties. I just set up the hook calls and Qlik Hooks internally will do the async handling for you.</p><h3>Getting into Hook trouble</h3><p>Before we continue with more examples, I want to explain some rules for React Hooks that also apply to Qlik Hooks. Mainly, hooks can not be called from inside loops, conditions, or nested functions. These uses are not allowed:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11e8732e0a49669c5a5213d4335b27ec/href">https://medium.com/media/11e8732e0a49669c5a5213d4335b27ec/href</a></iframe><p>These are contrived examples, but it’s probably not hard to imagine a use case where you need to call api methods conditionally or with parameters that are dependent on other api responses.</p><p>Qlik Hooks have another way of executing under these conditions though by exposing a call method that can be called from anywhere. It’s implementation looks like this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/33eb9a0b54edee145efe722d49ecb9f2/href">https://medium.com/media/33eb9a0b54edee145efe722d49ecb9f2/href</a></iframe><p>There’s a couple new things here. First, when we call useEngineVersion this time, we aren’t passing the second parameter. Without the second parameter, the hook will set up an api call method, but it won’t actually execute when the hook is initialized, only when the call method on engineVersion is run.</p><p>Second, we are running engineVersion.call() inside of a useEffect hook. Why? Well if we called it from outside the hook we would end up infinitely re-rendering the App component function. Remember, every time we call engineVersion, the state of engineVersion will update, and every time the state updates, the App component function will rerun, which will again execute engineVersion.call().</p><p>useEffect allows us to selectively run code within our App function component, instead of it running every re-render of the component. useEffect takes in a function as its first parameter that will run when necessary. Its second parameter is an array of dependencies that define when the function should run. Whenever a parameter in the dependency array changes its value, the function will re-execute. Since we are passing an empty array, there are no changing dependencies and the code will only execute 1 time when the component is first established.</p><h3>A real use case for Qlik Hooks call()</h3><p>Now let’s walk through an example of when we would need to leverage the call method on a qlik hook. In this example, I’m going to create a listbox on our webpage from a field in the Qlik app, and when a user clicks on a listbox item, we want to run SelectListObjectValues on the selected item.</p><p>First, we need to connect to our app and create a ListObject</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce088e59453f030576b3f23cdddf79c0/href">https://medium.com/media/ce088e59453f030576b3f23cdddf79c0/href</a></iframe><p>We’re off to a good start. Next we need to get data from the listObject</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/db8ccbb049d63766061be9d1cce7f6b8/href">https://medium.com/media/db8ccbb049d63766061be9d1cce7f6b8/href</a></iframe><p>Ok we’ve got some new stuff going on here. First, we’re running useGetListObjectData on listObject, but we’re also passing in a property invalidations: true. This is telling the hook that whenever the selection state for listObject changes, re-run the GetListObjectData method so we have an updated state of the selected field.</p><p>After we get the data, we need to loop through each item in the qMatrix and render an &lt;li&gt; element. We could do this in the return function with something like listObjectData.qResponse[0].qMatrix.map(row =&gt; &lt;li...&gt;) but there’s a small issue with this implementation: Whenever the selection state on listObject changes, the GetListObjectData method will run again, temporarily setting the listObjectData’s qResponse to null. This will result in the list disappearing momentarily while new data is being fetched until the new data is received.</p><p>Alternatively, we want to set up a way in which we define the state of the listObject items, and only update that state when new data is available. We can do this using React’s useState and useEffect hooks.</p><p>When we define const [films, setFilms] = useState([]) we’re creating a new state variable called films that is initialized as an empty array. We also get a setter function setFilms that allows us to update the state of films elsewhere in our code.</p><p>Next, the useEffect hook runs a function that checks if listObjectData has a response on it, and then maps that response into an array that is set to the films state. Since the useEffect hook has a dependency list that includes listObjectData the useEffect function will only run when listObjectData changes.</p><p>The films array is then used to render &lt;li&gt;’s for each film in the dataset.</p><p>Finally, each &lt;li&gt; has an onClick function that calls a function handleClick. Inside this function is where we’ll define how the listObject item will be selected.</p><p>One might be inclined to define a function that runs the following code inside handleClick</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad735f5e344ffc5e8baceb4154310bd7/href">https://medium.com/media/ad735f5e344ffc5e8baceb4154310bd7/href</a></iframe><p>But remember, this breaks our rule above about calling hooks from inside functions. Instead, we need to set up an object using useSelectListObjectValues outside the function that we can call from inside handleClick</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd77a724e1220fbc5cf23a97ac937fbc/href">https://medium.com/media/dd77a724e1220fbc5cf23a97ac937fbc/href</a></iframe><p>The full solution looks like</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f211cded45de2911a213b59f7c301be/href">https://medium.com/media/0f211cded45de2911a213b59f7c301be/href</a></iframe><p>I hope this walkthrough demonstrates some clear examples of how Qlik Hooks can help with developing React apps powered by the Qlik Engine. These examples only show a subset of what is possible with Qlik Hooks, but if you want to see more ways it can be leveraged, check out the recipes <a href="https://opensrc.axisgroup.com/qlik-hooks/recipes/connect.html">here</a>.</p><p>If there are any issues you encounter while using Qlik Hooks, or even features you would like to see added, create a new issue on the <a href="https://github.com/axisgroup/qlik-hooks/issues">Qlik Hooks GitHub page</a>, or reach out to me on <a href="https://twitter.com/jbellizzi4">Twitter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54fe09568e8d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/accessing-the-qlik-engine-api-from-react-using-qlik-hooks-54fe09568e8d">Accessing the Qlik Engine API From React Using Qlik Hooks</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[New qExt]]></title>
            <link>https://medium.com/@jbellizzi/new-qext-277121a59b93?source=rss-7295723f35ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/277121a59b93</guid>
            <category><![CDATA[qlik-sense]]></category>
            <category><![CDATA[qlik]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[John Bellizzi]]></dc:creator>
            <pubDate>Tue, 14 Jul 2020 21:28:49 GMT</pubDate>
            <atom:updated>2020-07-14T21:29:09.669Z</atom:updated>
            <content:encoded><![CDATA[<h3>qExt v2</h3><p>Hey Qlik developers. I’ve made some updates to the qExt Qlik Development tool (<a href="https://github.com/axisgroup/qExt">github</a>) and released a new major version (v2 🎉).</p><p>The full qExt documentation can be found <a href="https://opensrc.axisgroup.com/qext/">here</a>.</p><h3>Building extensions with qExt</h3><p>Working off of the original qExt Qlik extension development library, I’ve made some changes to make development easier. If you’re new to qExt, read on to see how it works, or if you want to learn how Qlik extensions work, follow <a href="http://opensrc.axisgroup.com/tutorials/extensions/100.%20Prereq%20Qliks%20Open%20Ecosystem.html">this tutorial</a>.</p><h4>A smarter way to develop extensions</h4><p>Qlik extensions are becoming increasingly popular as a way to implement custom visualizations within Qlik dashboards. If you’ve worked on building Qlik extensions in the past, you may know how difficult it can be to set up a development environment and deploy your extension to a Qlik server. qExt is a tool that helps with all of that. It includes bootstrapped templates to quickly spin up new extension projects, compiles your code with babel and webpack, and even deploys it to a Qlik server for you, eliminating the need to manually delete old extensions in the QMC just to upload a new one.</p><h4>Starting a new extension project</h4><p>To get started, you’ll need to install qExt</p><p>npm install -g qext</p><p>Next, use the command line to create a new extension</p><p>qext --create-extension my-extension --install</p><p>--create-extension tells qext we’re creating a new project with the name my-extension and --install will install all project dependencies</p><h4>Updating your project</h4><p>After creating the extension, you’ll see your project directory includes a src directory with all source project files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*5aQB0n-vhsDdIzkl2O2w3Q.png" /></figure><p>in src/index.js you’ll find the root of the extension project. All extension properties are defined and imported from src/methods</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*2MoSb6Gt6W7b3RzA0vkrTw.png" /></figure><p>Open the methods/paint.js file and add the following code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*It4kiVYQv8g8f79D5N3RxA.png" /></figure><p>Now from a command line at the root of the project directory, run npm run build. qExt will bundle the code and place it in the dist folder. It also zips up the project so you can easily import it into the QMC.</p><p>Instead of manually importing it though, try using qExt to upload it to a Qlik server. Open up qext.config.json and add the “serverDeploy” section with the pertinent information</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*eDUgMaictglsLQ3m4b2oyg.png" /></figure><p><em>note: if the server has a self signed certificate, you’ll also need to add the </em><em>allowSelfSignedSignature property within “serverDeploy” and set its value to true</em></p><p>Now run npm run deploy from the command line and enter the username and password of a Qlik user who has extension publishing privileges in the QMC. qExt will delete the extension from the QMC if it already exists and upload the built extension zip file from the dist directory.</p><p>You can find your extension in the custom objects/extensions section of an app in edit mode and check to see if it works. <strong><em>By default, the extension name defined in </em></strong><strong><em>src/index.qext is qExt Template and that is what will display in the extensions section until you update the name in the </em></strong><strong><em>index.qext file</em></strong></p><p>One last feature to be aware of when using qExt is the watch script. Instead of running npm run build and npm run deploy every time you make a change to your code, you can instead run npm run watch-deploy once and qExt will continue to watch for any changes you make to your extension code, and then redeploy those updates to the Qlik server.</p><h3>Updates</h3><p>Since the original version of qExt, there have been a few important updates to take note of:</p><h4>Authentication</h4><p>As we demonstrated above, you can now have qExt authenticate against the server with a Qlik username and password instead of setting up header-authentication.</p><h4>Header authentication config</h4><p>Header authentication is still available if that’s your jam. qExt now has the option to also define a header name if it is different than the oft-used hdr-usr. More info on header authentication can be found in the docs <a href="https://opensrc.axisgroup.com/qext/configuration/qext-config-json.html#serverdeploy">here</a>.</p><h4>Alternate webpack configuration</h4><p>qExt v2 now includes the option to provide your own alternate webpack configuration. You can install any special loaders that are need to make your extension run and define them in your own webpack.config.js file. To use an alternate webpack configuration, reference the compile docs <a href="https://opensrc.axisgroup.com/qext/configuration/qext-config-json.html#compile">here</a>.</p><p>Reach out on <a href="https://github.com/axisgroup/qExt/issues">GitHub</a> if there are any issues or new features you would like to see, or give me a shoutout on <a href="https://twitter.com/jbellizzi4">Twitter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=277121a59b93" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Time-lapse Visualizations with React Hooks and D3 (part 3)]]></title>
            <link>https://medium.com/@jbellizzi/building-time-lapse-visualizations-with-react-hooks-and-d3-part-3-857c9067b8fa?source=rss-7295723f35ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/857c9067b8fa</guid>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[d3js]]></category>
            <dc:creator><![CDATA[John Bellizzi]]></dc:creator>
            <pubDate>Thu, 02 Apr 2020 14:41:06 GMT</pubDate>
            <atom:updated>2020-04-02T14:41:06.535Z</atom:updated>
            <content:encoded><![CDATA[<p>In <a href="https://medium.com/@jbellizzi/building-time-lapse-visualizations-with-react-hooks-and-d3-part-2-c70e03b7d368">part 2</a> of this tutorial, we added a visualization to control the timer and display the transitioning state of data. In this final part, we’ll explore utilizing the timer output to display the current state of data onto a US map. We’ll also see how the D3 enter/update/exit methods can make visualization rendering with transitions easy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*hqZXG6Bm7fSEIu_ytRMerA.gif" /></figure><p>Before we dive into the Map component, let’s take a quick look at the data that we need to incorporate into our project. <a href="https://raw.githubusercontent.com/jbellizzi/timelapse-visualization/03-map/src/data/casesByCounty.json">Here</a> we have a data source that breaks down per date and per US county, the number of confirmed COVID-19 cases to date. It combines the New York Times data set we referenced earlier with the geo location of each county in the form of latitude and longitude points.</p><p>We could pass the entire data object into our Map component, be we are only ever plotting 1 date at a time in the map. A cleaner implementation is to pre-filter the data first to only records for the current date output from our timer, and then pass that data into the map.</p><p>First, we take our flat data structure and nest it by date using the d3 nest function. We convert this nesting into a hash table so that we can look up the data for the date when the timer increments to a new day.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a49458685e8f38daab828822399dfb85/href">https://medium.com/media/a49458685e8f38daab828822399dfb85/href</a></iframe><p>This makes it easier to take our current timer value and extract the data we need from our hash table</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5fd0e0b99f193908d0600d394cd32f0d/href">https://medium.com/media/5fd0e0b99f193908d0600d394cd32f0d/href</a></iframe><p>We also need to find the maximum # of cases across all counties and dates so that our circle sizes in the Map can be scaled appropriately. (<em>Note: this is calculated from the flat data</em>)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/541425ea9296b9538fea665b8bbd09ba/href">https://medium.com/media/541425ea9296b9538fea665b8bbd09ba/href</a></iframe><p>Now we can pass this all to our Map component as such</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e988138f0d19c55cd7e746f6ee5bda0/href">https://medium.com/media/6e988138f0d19c55cd7e746f6ee5bda0/href</a></iframe><p>Now let’s start building our Map component. Our component takes in the data array for the specified date and the maxCases value, and returns an svg that will render a map and data circles.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee40ad50ea17db5642c528cc46b0b53c/href">https://medium.com/media/ee40ad50ea17db5642c528cc46b0b53c/href</a></iframe><p>Next we’ll create a scale to size the radius of of our circles representing the number of cases in a county. In this case, we use a square root scale so there is higher discrepancy across counties with smaller total confirmed cases</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/025b85024af99fda3c40d3f294a89d2a/href">https://medium.com/media/025b85024af99fda3c40d3f294a89d2a/href</a></iframe><p>Now, we’ll run a side effect in a useEffect hook to render the map and overlay circles. First we need to set up the functions that will create our map. <a href="https://github.com/d3/d3-geo/blob/master/README.md#geoPath">geoPath()</a> is a path generator that uses GeoJSON data to render svg paths (like the feature collection of states we’re pulling from <a href="https://raw.githubusercontent.com/jbellizzi/timelapse-visualization/03-map/src/data/us-states.json">here</a>). We could directly use geoPath() to render the feature collection data set as path elements in our svg, but using an Albers projection is better suited toward displaying spherical coordinates on a flat plane (for this we use <a href="https://github.com/d3/d3-geo/blob/master/README.md#geoAlbersUsa">geoAlbersUsa()</a>).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/779e6916f0ebedb05f034289f60e5583/href">https://medium.com/media/779e6916f0ebedb05f034289f60e5583/href</a></iframe><p>With this pathGenerator, we can now plot the states on our svg element. Here we are using the array of state features and create a path for each one, generated using the pathGenerator function. We aren’t using any update or exit logic in this section as we don’t anticipate changes in the states’ paths.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f771cde14c690c9c9b98c40d51d76e3/href">https://medium.com/media/7f771cde14c690c9c9b98c40d51d76e3/href</a></iframe><p>Finally, we can add the circles. Because this chart is dynamic and data is constantly being passed in, we need to define the d3 render in a way that will smoothly transition the points onto the map, and increase their size as data is updated</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8af6ae02dee8630aef055dc7f6fa9afe/href">https://medium.com/media/8af6ae02dee8630aef055dc7f6fa9afe/href</a></iframe><p>We’re using the Enter/Update/Exit methodology from d3 to gracefully handle the changing data state coming into the component. In order for d3 to index data points so it can differentiate what is a new data point, and what data point existed in the prior state, we define a key within our data function. The callback function above uses the FIPS code field to define a unique key for each data point data(data, d =&gt; d.FIPS).</p><p>Everything after the enter() function defines what happens to a new data point when it is added to our data set, and everything following the merge() function defines what happens when a data point already exists, but its value has changed.</p><p>Let’s take an example of New York City case data. If on February 29th there are no data points for New York City, it won’t exist in the data set and our d3 function will not have seen the FIPS code in the data. If then on March 1st NYC has its first case, the function will recognize the new data point and run everything after the enter() function, appending a new circle, giving it a class, and styling it. It will also set its cx, cy, and r values.</p><p>Now we advance to March 3rd and NYC has increased its case count from 1 to 2. Since NYC already exists in the data set, the function won’t enter a new data point, but the data has updated so we will run the update part of our function, which means increasing the r value to a larger radius representing 2 cases.</p><p>Finally, we are removing any data points that exit our data set. Say the timer pauses at March 3rd, and then we select February 1st. There are no data points for NYC for this selection state, so when d3 gets its updated data set, it recognizes that all NYC data points have exited, and the corresponding circles are removed from the DOM.</p><p>One last effect we are implementing here is a transition on the radius size. Without the transition().duration(1000) function, you’ll see that the radius sizes jump from 1 state to the next. Adding a transition makes the size increase (or decrease) smoothly.</p><p>This wraps up the series on time-lapse visualizations. As in prior sections, the full code is accessible from <a href="https://github.com/jbellizzi/timelapse-visualization/tree/03-map">GitHub</a>. If you have any questions or feedback, leave a comment and I will try to respond as soon as possible. If</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=857c9067b8fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Time-lapse Visualizations with React Hooks and D3 (part 2)]]></title>
            <link>https://medium.com/@jbellizzi/building-time-lapse-visualizations-with-react-hooks-and-d3-part-2-c70e03b7d368?source=rss-7295723f35ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/c70e03b7d368</guid>
            <category><![CDATA[d3js]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[react-hook]]></category>
            <dc:creator><![CDATA[John Bellizzi]]></dc:creator>
            <pubDate>Mon, 30 Mar 2020 16:42:32 GMT</pubDate>
            <atom:updated>2020-03-30T16:42:32.229Z</atom:updated>
            <content:encoded><![CDATA[<p>In our <a href="https://medium.com/@jbellizzi/building-time-lapse-visualizations-with-react-hooks-and-d3-a9f7c94b9a0b">last tutorial</a>, we saw how to build a timer using React hooks. Now, we’re going to add a trend line to visualize the total growth of our data over time, as well as control the timer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*KEjk_aWX-CdI922EfDeODQ.gif" /></figure><p>Using data sourced from the <a href="https://github.com/nytimes/covid-19-data">New York Times</a>, we generated a json file aggregating <a href="https://github.com/jbellizzi/timelapse-visualization/blob/02-trendline/src/data/casesByDate.json">total confirmed COVID cases by date</a>.</p><p>Going back to the project started in part 1, we are using the data with the timer output to generate the trend line we see above</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a207b085dcfccd4cb153d12a6ad5702/href">https://medium.com/media/3a207b085dcfccd4cb153d12a6ad5702/href</a></iframe><p>With our new casesByDate array, we can grab the first and last data point to get the start and end date to create our timer. We pass the data, and the timer properties, into a new component called Trend . (<em>Note: we also need to update useTimer to return </em><em>isPlaying, </em><em>startTime, and </em><em>endTime properties</em>).</p><p>In our Trend component, let’s start by defining the plot dimensions and creating d3 scales for our x and y axes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50e3fd1c5c50b4e3d82b60e2c8a24f55/href">https://medium.com/media/50e3fd1c5c50b4e3d82b60e2c8a24f55/href</a></iframe><p>For our xScale, we’re using the d3 scaleTime to create scales from the timer’s start and end time mapped across the width of our plot. Our yScale uses the d3 extent function to find the min and max values of our Confirmed field, and maps the extent of that across the height of our plot.</p><p>Our trend is composed of 2 parts: a base area and the current area. the base area is the lighter area that is always displayed, while the current area is the darker area that gets overlaid while the timer count increases. Let’s look at how the area is plotted.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df065495d230b56f45c9ad605dc92e9c/href">https://medium.com/media/df065495d230b56f45c9ad605dc92e9c/href</a></iframe><p>In our first useEffect, we have 2 path generators, an area and a line. We pass in the data to these generators to create a path data string, and that can be passed to the d attribute of our area and line paths. In our jsx below, we’re using each one twice. The first set is the bottom layer of the chart with the fainter plot that represents time after the current state of our timer, while the second set is the top layer displaying the current state of data from our timer. We can display only the part of the top layer we want to by using a clipPath element that clips the section of the path to show. The clipPath width is updated every time the timer’s state updates its value.</p><p>Let’s add an x and y axis to the chart too.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/87431b83504af78662451c0984032e05/href">https://medium.com/media/87431b83504af78662451c0984032e05/href</a></iframe><p>With the useRef hook from React, we can access the DOM elements for the x and y axes and attach the d3 axes we create.</p><p>Finally, we want to add the ability to update our timer state from the chart by clicking on the plot. To do this, we’ll first need to add functionality to the useTimer hook that can take in a new time and update the state from an external source. Going back to useTimer, let’s create and return a new function that updates the time state for us</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aac164d2cab9b1f8711b129616d9a665/href">https://medium.com/media/aac164d2cab9b1f8711b129616d9a665/href</a></iframe><p>The update is pretty simple. We just need to remember that the time state is stored in useTimer as a number (not a date object). Also, don’t forget to return updateTime from the function.</p><p>Back in our Trend component, we now have access to this new function that we can call when we click on our svg element.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37c8f30eafa75a59b5df3df28ffedf29/href">https://medium.com/media/37c8f30eafa75a59b5df3df28ffedf29/href</a></iframe><p>We should now have a working timeline chart. You’ll also want to add the css from <a href="https://github.com/jbellizzi/timelapse-visualization/blob/02-trendline/src/App.css">here</a>. You can find the full source code on <a href="https://github.com/jbellizzi/timelapse-visualization/tree/02-trendline">GitHub</a>.</p><p>Look out for the next part where we’ll go through using the data broken down by US county to visualize across a Map.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c70e03b7d368" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Time-lapse Visualizations with React Hooks and D3]]></title>
            <link>https://medium.com/@jbellizzi/building-time-lapse-visualizations-with-react-hooks-and-d3-a9f7c94b9a0b?source=rss-7295723f35ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9f7c94b9a0b</guid>
            <category><![CDATA[visualization-transitions]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[d3js]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[John Bellizzi]]></dc:creator>
            <pubDate>Sun, 29 Mar 2020 03:00:36 GMT</pubDate>
            <atom:updated>2020-04-02T14:49:07.739Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building Time-lapse Visualizations with React Hooks and D3 (part 1)</h3><p><em>Note: This is part 1 in a 3-part series. The second part of this tutorial can be found </em><a href="https://medium.com/@jbellizzi/building-time-lapse-visualizations-with-react-hooks-and-d3-part-2-c70e03b7d368"><em>here</em></a><em>, and part 3 can be found </em><a href="https://medium.com/@jbellizzi/building-time-lapse-visualizations-with-react-hooks-and-d3-part-3-857c9067b8fa"><em>here</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*9B14tPr8tqA5bW8T3KlZSQ.gif" /></figure><p>Interactive transitions in our visualizations add context to changing elements across different data states (see Mike Bostock’s article on <a href="https://bost.ocks.org/mike/constancy/">object constancy</a>). This can be especially powerful for changing events that occur in geographic space. Above, we have an example of a visualization we are working on that demonstrates the growth of COVID-19 cases over time across the US. The timeline at the top automatically plays through a daily series of events, and can be clicked to act as a selection filter.</p><p>The charts are built using <a href="https://reactjs.org/docs/hooks-intro.html">React Hooks</a> to control the time functionality, and <a href="https://d3js.org/">D3</a> to plot the line and map. In this article (part 1 of the series) we are going to go over how the timer hook is built, and how we can use it to display time and control play state. Later pieces in this series will show how we use the time along with data to plot cases on the map, as well as adding more control to the timer.</p><p>With React Hooks, we can compose hooks together to create our own custom hooks that internally keep and update state. Our timer hook initializes with a start and end date, a step period, and an update frequency. What we get back is the current time state, and functions that allow us to play, stop, and update the time.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/124be2af44cc6bd95ef7c05af3aa9209/href">https://medium.com/media/124be2af44cc6bd95ef7c05af3aa9209/href</a></iframe><p>Our custom hook takes in the following properties</p><ul><li>startTime: Minimum time of timer</li><li>endTime: Maximum time of timer</li><li>step: Number of milliseconds the timer increases by on each tick. If we want our timer to increase by 1 day every tick, we will set our step to be 1 day * 24 hrs/day * 60 mins/hr * 60 secs/min * 1000 ms/sec =<strong> 86400000 ms</strong></li><li>frequency: How many times per second the timer increases by the provided tick. A value of 1 with the above step will increase the timer value by 1 (86400000 ms) every second</li></ul><p>From this, we get the current state of the timer that can be displayed, and functions that allow us to control the timer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*-kM5JyC4A_yTcVezzfOgZQ.gif" /></figure><p>We can decrease our step to 60 * 60 * 1000 = <strong>3600000</strong> so that every tick increments the timer by 1 hour instead of 1 day</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*YOZGkoEjH14B-8jwonmxFA.gif" /></figure><p>This is a pretty slow update though, so let’s see what happens when we also increase our frequency to <strong>24</strong> ticks per second</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*jiNGgQtvdxJL_NmUmtMv5w.gif" /></figure><p>This looks great, but what’s going on within the hook? Let’s dive into the useTimer function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f87e0a519a548fe8a84c696a79830ce/href">https://medium.com/media/1f87e0a519a548fe8a84c696a79830ce/href</a></iframe><p>The first thing we do is set up and initialize our time state using the useState hook with the startTime as the initial value. For ease of internally maintaining and updating time, we’ll store it’s value as a number in milliseconds. We also set up a state for whether the timer is playing.</p><p>With a useEffect hook, we can run a side effect every time the state of isPlaying changes. When it’s equal to true, we’ll run the interval at the frequency input and update the time by 1 step with every interval run. (<em>Note: we cleanup the effect by clearing the interval every time the component un-mounts</em>).</p><p>We also set up a play and stop function to control the isPlaying state. Stop is called internally when time’s value is equal or greater than the endTime. These functions are exposed so that a parent component can control the play state (as we see in the example above with Play and Stop buttons).</p><p>We now have a timer that gives us the state of an updating time, and control over the timer. Look out for the second part of this series, where we will see how to use the time returned from this timer to render the trend line and map charts using D3. To see the full code, check out the project on <a href="https://github.com/jbellizzi/timelapse-visualization/tree/01-building-useTimer">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9f7c94b9a0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Qlik Sense Extension Development with qExt]]></title>
            <link>https://medium.com/axis-group-visual-analytics-practice/qlik-sense-extension-development-with-qext-646c98dc9ae1?source=rss-7295723f35ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/646c98dc9ae1</guid>
            <category><![CDATA[qlik-sense-extension]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[qlik-sense]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[John Bellizzi]]></dc:creator>
            <pubDate>Mon, 26 Feb 2018 17:37:16 GMT</pubDate>
            <atom:updated>2018-02-26T17:37:16.192Z</atom:updated>
            <content:encoded><![CDATA[<h4>Using modern web dev tools to develop badass extensions</h4><p>Have you ever wanted a button to set a variable in a Qlik Sense app? Ever been asked to show data in a Sankey Diagram? If you want any custom functionality or visualization in Qlik Sense, your options are either tell the users it can’t be done, or use extensions to provide enhanced capabilities. The power of Sense extensions is no secret, but those who are new to extension development often spend too much time figuring out how to set up a development environment, and not enough time actually building the cool visualizations they envisioned.</p><p>At Axis Group, we have been working on our own development template that we use to build extensions. Recently, we decided to package this up so anyone can download it and spin up an extension development environment in 3 easy steps (<a href="https://github.com/axisgroup/qExt">here’s the qExt project on GitHub</a>). We’ll show you how easy it is to generate a new extension project, and even automate the process of deploying your project to both a Desktop and Server environment.</p><h3>First-time installation</h3><h4>Install NodeJS</h4><p>If you don’t already have <a href="https://nodejs.org/en/">NodeJS</a> on your local machine, install it so that you can use npm to install and run qExt.</p><h4>Install qExt</h4><p>In your Command Prompt or Terminal Window, install qExt globally</p><pre>npm install -g qext</pre><h3>3 steps to create new project</h3><h4>1. Install template files</h4><p>Now that qExt is installed, you can begin using it to create new projects. Change the working directory of your command line to the location you would like to build your extension and run the following command (replacing my-extension with your desired extension name):</p><pre>qext --create-extension my-extension --install</pre><p>After all dependencies finish installing, you will notice that your new project contains a src directory with template files for getting started. These files are linked together using ES6 modules; qExt uses Babel and Webpack to compile your code before it is deployed to Qlik Sense.</p><h4>2. Define deployment location (QS Desktop)</h4><p>Before you start writing code, we need to tell qExt where to deploy the bundled extension. You’ll notice a file deployment.config.json in the generated project folder. Here, we’ll update the username within the desktop.destination property (Don’t worry about the server configuration just yet, we will cover server deployment later on).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5A2-IfEgRZjPnNTPFEmzpQ.png" /><figcaption>Updated Extension File Destination</figcaption></figure><h4>3. Build, Watch, and Deploy</h4><p>The last step is to run the npm script that will watch our source code for any changes, and automatically bundle and deploy the zipped up extension file to the Extension folder in our Qlik Sense Documents. To do this, run:</p><pre>npm run watch-webpack-deploy-desktop</pre><p>Any time you make a change to any file in your src directory, the entire directory will be bundled using webpack, zipped up, and then copied into your Extensions directory.</p><h3>The environment</h3><p>When you create a new qExt project, the generated environment will include a directory called src where you will do all of your development. qExt uses Webpack and Babel, so you can use ES6 and file imports to modularize your code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*hAoEzuQNlH--RqBZyMIIjg.png" /><figcaption>src Directory</figcaption></figure><p>In src, you’ll find a JavaScript file named the same as your project (ex. my-extension.js)— This is the entry point where we import all of our module dependencies:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*lFSPk1XoAwVk5tPEY2yMjw.png" /><figcaption>Entry JavaScript File</figcaption></figure><p>This way, you can handle each of these properties/functions in separate files, and if you don’t need all of these modules for your extension, just delete unnecessary ones from your directory.</p><p>The project directory also contains a style.scss file that uses <a href="https://sass-lang.com/guide">SASS</a> to style the content of your extension. It includes the class name of the extension container, so as long as all of your css/sass is written within the scope of this class, your styles won’t affect other Qlik objects.</p><h3>Deploying to Qlik Sense Server</h3><p>The above solution is great for local QS Desktop development, but if you’re like me, you want to develop and test your Qlik Sense Extensions against a server environment. Manually deploying your extension to your Sense Server can be a tedious effort; Every time you make a change to your code, you need to zip up your source files and import to the QMC (oh, and don’t forget to delete your old extension 🙃).</p><p>While developing qExt, we decided to address this issue by using the Qlik Sense Repository Service APIs to automate all of those actions for a hands-free server deployment process. This has allowed us to develop extensions locally on OSX, while running Qlik Sense Server on VMware Fusion (if you’re interested in how I set up Qlik Sense Server on my Mac, let me know in the comments and I can write another article on that).</p><h3>First-time setup</h3><p>qExt uses the <a href="http://help.qlik.com/en-US/sense-developer/November2017/Subsystems/RepositoryServiceAPI/Content/RepositoryServiceAPI/RepositoryServiceAPI-Introduction.htm">Qlik Sense QRS API</a> to push extensions from the development environment to the Sense Server. To deploy extensions to the server, we will need to set up a virtual proxy so that Header Authentication can be used to allow the deleting and importing of extensions (we’ll walk through the basic setup, but for more detailed information, see <a href="http://help.qlik.com/en-US/sense-developer/November2017/Subsystems/Platform/Content/Examples/config-header-authentication.htm">Qlik’s Header Authentication Config</a> walkthrough). Note that Header Authentication acts as a backdoor into your server, and should only be used under the following situations:</p><ul><li>Use only between systems that can fully trust each other</li><li>Use only in combination with a firewall, proxy or routing solution</li><li>Use only in a development environment</li></ul><h4>1. Create Virtual Proxy</h4><ol><li>Go to QMC</li><li>Select <strong>Virtual Proxy</strong></li><li>Click <strong>Create new</strong></li></ol><h4><strong>2. Identification</strong></h4><ol><li>Enter header-authentication in the Description</li><li>Enter hdr in the Prefix</li><li>Session inactivity can be left to the default 30</li><li>Enter X-Qlik-Session-hdr in Session cookie header name</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DQnD1teqdmW-HAzoC_vYiQ.png" /><figcaption>Virtual Proxy Identification Settings</figcaption></figure><h4>3. Authentication</h4><ol><li>Set Anonymous access mode to No anonymous user</li><li>Set Authentication method to Header authentication dynamic user directory</li><li>Enter hdr-usr in Header authentication header name</li><li>Enter $ud\\$id in Header authentication dynamic user directory</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FeRAQFSDRjkz9b2RHHIKCA.png" /><figcaption>Virtual Proxy Authentication Settings</figcaption></figure><h4>4. Load Balancing</h4><ol><li>Click Add new server node and add desired node (I am adding Central node)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EkDUXIDakUexISiS4IlQ2A.png" /><figcaption>Adding Load Balancing Node</figcaption></figure><p>2. Click apply to save settings</p><h4>5. Linking Virtual Proxy to Proxy</h4><ol><li>Under Associated items select Proxies</li><li>Click the Link button at the bottom of the page</li><li>Select the proxy service node you want to link to and click Link (again, I’m using the Central node here)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*toRRhuzArUzc8hlGUjmaxA.png" /><figcaption>Linking Virtual Proxy</figcaption></figure><h3>Now you can deploy extensions to your server!</h3><p>Remember the 3 steps we took above to create and deploy an extension to Desktop? It looked like this:</p><ol><li>Run qext --create-extension [name] --install anywhere you wish to start a new project</li><li>Update deployment.config.json file</li><li>In the new project directory, run npm run watch-webpack-deploy-desktop and start coding</li></ol><p>If we want to deploy to the server instead, we just have to update the server.host and server.headers.hdr-usr properties in our deployment.config.json file with the hostname of our server and the domain\user admin account that will be used to deploy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hWdqZQQbJsXf8IMH4WMuNw.png" /><figcaption>Updating Hostname and User in deployment.config.json</figcaption></figure><p>and instead of deploying to desktop, as we previously did in step 3, run</p><pre>npm run watch-webpack-deploy-server</pre><p>The above will tell qExt to watch for any changes in the src directory, bundle the updated files with Webpack and Babel, zip them up, and then will delete the old extension in your server and import the new one.</p><p>Try it yourself. You should see the extension in your Custom Objects pane from any Qlik Sense application. Add a console.log() to your paint.js file and save it; You should see the update in your developer console when you refresh the Sense app page.</p><h3>Build badass extensions</h3><p>With the above resources, you can now start developing Qlik Sense Extensions in 3 easy steps. Just remember:</p><ol><li>Run qext --create-extension [name] --install anywhere you wish to start a new project</li><li>Update deployment.config.json with either the desktop extension destination, or the server hostname and username.</li><li>In the new project directory, run the script to watch and deploy to either desktop or server</li></ol><p><strong>Desktop:</strong></p><pre>npm run watch-webpack-deploy-desktop</pre><p>or<strong> Server:</strong></p><pre>npm run watch-webpack-deploy-server</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=646c98dc9ae1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/axis-group-visual-analytics-practice/qlik-sense-extension-development-with-qext-646c98dc9ae1">Qlik Sense Extension Development with qExt</a> was originally published in <a href="https://medium.com/axis-group-visual-analytics-practice">Axis Group Visual Analytics Practice</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>