<?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>DEV Community: Ananya Deka</title>
    <description>The latest articles on DEV Community by Ananya Deka (@ananya_deka).</description>
    <link>https://dev.to/ananya_deka</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%2F2114055%2F53ab4aa2-4c07-467d-8000-ce6f5bc598dd.jpg</url>
      <title>DEV Community: Ananya Deka</title>
      <link>https://dev.to/ananya_deka</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ananya_deka"/>
    <language>en</language>
    <item>
      <title>Smarter Axis Label Formatting Based on Zoom Level in CanvasJS</title>
      <dc:creator>Ananya Deka</dc:creator>
      <pubDate>Thu, 20 Mar 2025 11:04:04 +0000</pubDate>
      <link>https://dev.to/ananya_deka/smarter-axis-label-formatting-based-on-zoom-level-in-canvasjs-2pc7</link>
      <guid>https://dev.to/ananya_deka/smarter-axis-label-formatting-based-on-zoom-level-in-canvasjs-2pc7</guid>
      <description>&lt;p&gt;When building time-series charts, how you format axis labels can make or break readability — especially when users zoom across seconds to years. &lt;a href="https://canvasjs.com/" rel="noopener noreferrer"&gt;CanvasJS&lt;/a&gt; provides excellent out-of-the-box support for time-based axis labels, but when working with sub-minute or sub-hour data (e.g., sensor readings, real-time dashboards), the default behavior might not always deliver the best readability. This guide shows how to refine axis labels for small time ranges (seconds, minutes) while retaining CanvasJS’s automatic interval calculations for larger ranges.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Challenge
&lt;/h3&gt;

&lt;p&gt;For small time windows (e.g., 30 seconds or 10 minutes), CanvasJS might:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Omit seconds in labels, even when critical for precision.&lt;/li&gt;
&lt;li&gt;Choose intervals that create cluttered labels (e.g., 1-second intervals for a 30-second range).&lt;/li&gt;
&lt;li&gt;Fail to align label formats with user expectations (e.g., showing 14:00 instead of 14:00:00).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Solution Overview
&lt;/h3&gt;

&lt;p&gt;We’ll override the &lt;em&gt;valueFormatString&lt;/em&gt; property only for sub-hour ranges, while letting CanvasJS handle larger ranges automatically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Improvements:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Seconds precision for ranges &amp;lt; 1 minute.&lt;/li&gt;
&lt;li&gt;Clean intervals (e.g., 5-second or 1-minute increments).&lt;/li&gt;
&lt;li&gt;Dynamic transitions between formats (seconds → minutes → hours).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Strategy: Let CanvasJS Handle Long Ranges, You Handle Short Ranges
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Zoom Level (Visible Range)&lt;/th&gt;
&lt;th&gt;CanvasJS Auto Format OK?&lt;/th&gt;
&lt;th&gt;Custom Format Suggested&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;≥ 1 month&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;≤ 10 days&lt;/td&gt;
&lt;td&gt;⚠ Decent&lt;/td&gt;
&lt;td&gt;✅ MMM DD hh:mm&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;≤ 1 day&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;✅ hh:mm TT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;≤ 1 hour&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;✅ hh:mm TT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;≤ 1 minute&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;✅ hh:mm:ss TT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;≤ 10 seconds&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;✅ hh:mm:ss TT&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Dynamic Axis Label Formatting for Short Ranges&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function getFormatString(axis) {
    var min = axis.viewportMinimum || axis.minimum;
    var max = axis.viewportMaximum || axis.maximum;
    var rangeMs = max - min;
    var MINUTE = 60 * 1000;
    var HOUR = 60 * MINUTE;
    var DAY = 24 * HOUR;
    var MONTH = 30 * DAY; // Approximation
    var YEAR = 365 * DAY;

    if (rangeMs &amp;lt; 1 * MINUTE) 
        return "HH:mm:ss"; // &amp;lt;1 minute: show seconds
    if (rangeMs &amp;lt; 1 * HOUR) 
        return "HH:mm"; // 1min–1hr: minutes
    if (rangeMs &amp;lt; 1 * DAY) 
        return "HH:mm"; // 1hr–1 day: hours
    if (rangeMs &amp;lt; 10 * DAY) 
        return "MMM DD HH:mm"; // 1 day–10 days: day + month + hours
    if (rangeMs &amp;lt; 3 * MONTH) 
        return "MMM DD"; // 10 days–3 months: day + month
    if (rangeMs &amp;lt; 3 * YEAR) 
        return "MMM YYYY"; // 3 months–3 years: month + year

    return "YYYY"; // &amp;gt;3 years: year only
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Hook Into Chart Events&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var chart = new CanvasJS.Chart("chartContainer", {
    zoomEnabled: true,
    axisX: {
        valueFormatString: "MMM DD, YYYY" // Initial format, may be overridden
    },
    data: [{
        type: "line",
        xValueType: "dateTime",
        dataPoints: generateDataPoints() // Generate your time-series data
    }],
    rangeChanged: function (e) {
        var formatString = null;
        if (e.trigger != "reset")
            formatString = getFormatString(e.axisX[0]);
        e.chart.axisX[0].set("valueFormatString", formatString);
    }
});

chart.render();
// chart.axisX[0].set(“valueFormatString”,
// getFormatString(chart.axisX[0])); // Handle initial format, if not fixed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why This Approach Works
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Saves time&lt;/strong&gt;: No need to manage complex interval settings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Optimized for clarity&lt;/strong&gt;: Users see what’s most relevant at each zoom level.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Minimal code&lt;/strong&gt;: Focuses only on improving what CanvasJS doesn’t handle well.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalable&lt;/strong&gt;: Works across dashboards, analytics apps, stock charts, and more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/vishwas/embed/bNGvBwY?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;p&gt;By overriding intervals and formats only for sub-hour ranges, this approach balances customization with CanvasJS’s built-in intelligence. Developers gain fine-grained control over seconds/minutes without sacrificing the library’s robustness for larger timeframes. Implement this to build dashboards that shine at all zoom levels—from milliseconds to decades!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Integrating WebDataRocks and CanvasJS for Interactive Data Visualization</title>
      <dc:creator>Ananya Deka</dc:creator>
      <pubDate>Thu, 28 Nov 2024 12:09:26 +0000</pubDate>
      <link>https://dev.to/ananya_deka/integrating-webdatarocks-and-canvasjs-for-interactive-data-visualization-4kbi</link>
      <guid>https://dev.to/ananya_deka/integrating-webdatarocks-and-canvasjs-for-interactive-data-visualization-4kbi</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;In modern web applications, data analysis and visualization play a crucial role in delivering insights. While pivot tables allow users to explore and manipulate data interactively, charts make it easier to understand trends and patterns at a glance. &lt;a href="https://www.webdatarocks.com/" rel="noopener noreferrer"&gt;&lt;em&gt;WebDataRocks&lt;/em&gt;&lt;/a&gt;, a JavaScript pivot table library, and &lt;a href="https://canvasjs.com/" rel="noopener noreferrer"&gt;&lt;em&gt;CanvasJS&lt;/em&gt;&lt;/a&gt;, a versatile charting library, can be seamlessly integrated to combine the best of data exploration and visualization.&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%2Fxnarf6pnaf9he1rkkxwv.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%2Fxnarf6pnaf9he1rkkxwv.png" alt="Image description" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  About the Libraries
&lt;/h3&gt;

&lt;h4&gt;
  
  
  WebDataRocks
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;WebDataRocks&lt;/em&gt; is a lightweight JavaScript library designed to simplify data analysis. It enables developers to create powerful pivot tables in web applications with ease. &lt;/p&gt;

&lt;p&gt;Key features include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A drag-and-drop interface for slicing and dicing data.&lt;/li&gt;
&lt;li&gt;Support for JSON and CSV data formats.&lt;/li&gt;
&lt;li&gt;Real-time filtering, sorting, and aggregation.&lt;/li&gt;
&lt;li&gt;Cross-browser compatibility and a responsive design.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;WebDataRocks&lt;/em&gt; empowers users to analyze data interactively without requiring advanced coding skills.&lt;/p&gt;

&lt;h4&gt;
  
  
  CanvasJS
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;CanvasJS&lt;/em&gt; is a robust charting library that offers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A wide variety of chart types (bar, column, pie, etc.).&lt;/li&gt;
&lt;li&gt;Interactive and responsiveness.&lt;/li&gt;
&lt;li&gt;Lightweight performance optimized for web applications.&lt;/li&gt;
&lt;li&gt;Customization options for styling charts to match application themes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;CanvasJS&lt;/em&gt; helps visualize complex datasets in a way that is both visually appealing and easy to understand.&lt;/p&gt;

&lt;h3&gt;
  
  
  Integration with Code Examples
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Step 1&lt;/strong&gt;: HTML Structure
&lt;/h4&gt;

&lt;p&gt;Create placeholders for the pivot table and chart.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div id="pivot-table" style="width: 100%; height: 400px;"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;div id="chart-container" style="height: 400px; width: 100%;"&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Step 2&lt;/strong&gt;: Include Required Libraries
&lt;/h4&gt;

&lt;p&gt;Include &lt;em&gt;WebDataRocks&lt;/em&gt; and &lt;em&gt;CanvasJS&lt;/em&gt; using their CDN links.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link rel="stylesheet" href="https://cdn.webdatarocks.com/latest/webdatarocks.css"&amp;gt;
&amp;lt;script src="https://cdn.webdatarocks.com/latest/webdatarocks.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="https://canvasjs.com/assets/script/canvasjs.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Step 3&lt;/strong&gt;: Initialize WebDataRocks
&lt;/h4&gt;

&lt;p&gt;Set up a pivot table to summarize your data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var pivot = new WebDataRocks({
  container: "#pivot-table",
  toolbar: true,
  report: {
    dataSource: {
      data: [
        { Category: "Fruits", Sales: 100, Month: "January" },
        { Category: "Vegetables", Sales: 200, Month: "January" },
        { Category: "Fruits", Sales: 150, Month: "February" },
        { Category: "Vegetables", Sales: 250, Month: "February" },
      ],
    },
    slice: {
      rows: [{ uniqueName: "Category" }],
      columns: [{ uniqueName: "Measures" }],
      measures: [{ uniqueName: "Sales", aggregation: "sum" }],
    },
  },
  reportcomplete: function () {
    pivot.off("reportcomplete")
    updateChart()
  },
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Step 4&lt;/strong&gt;: Fetch Summarized Data and Render Chart
&lt;/h4&gt;

&lt;p&gt;Fetch pivot table data and render it as a chart using &lt;em&gt;CanvasJS&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var chartData = [];
var chart = new CanvasJS.Chart("chart-container", {
  animationEnabled: true,
  theme: "light2",
  title: {
    text: "Sales by Category"
  },
  data: [
    {
      type: "column",
      dataPoints: chartData
    },
  ],
});

function updateChart() {
  pivot.getData({}, renderChart);
}

function renderChart(data) {
  if (data.data) {
    data.data.forEach((row) =&amp;gt; {
      if (row.r0 &amp;amp;&amp;amp; row.v0) {
        chartData.push({
          label: row.r0,
          y: row.v0
        })
      }
    })
  }
  chart.render();
}

// Update the chart dynamically on data changes
pivot.on("datachanged", updateChart);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Take a look at this &lt;a href="https://jsfiddle.net/ananyadeka/rzby6j8g/" rel="noopener noreferrer"&gt;JSFiddle&lt;/a&gt; for the complete working example.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;The integration of &lt;em&gt;WebDataRocks&lt;/em&gt; and &lt;em&gt;CanvasJS&lt;/em&gt; provides a comprehensive solution for building interactive, data-driven dashboards. &lt;em&gt;WebDataRocks&lt;/em&gt; enables users to analyze and manipulate data in real-time, while &lt;em&gt;CanvasJS&lt;/em&gt; transforms the data into beautiful, responsive charts. This combination empowers developers to deliver seamless analytical experiences that are both functional and visually engaging. &lt;/p&gt;

&lt;p&gt;By following the steps above, you can create dashboards that meet modern data analysis and visualization demands, improving decision-making and enhancing user experience.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Creating a Gantt Chart with CanvasJS</title>
      <dc:creator>Ananya Deka</dc:creator>
      <pubDate>Fri, 04 Oct 2024 11:35:51 +0000</pubDate>
      <link>https://dev.to/ananya_deka/creating-a-gantt-chart-with-canvasjs-2nhe</link>
      <guid>https://dev.to/ananya_deka/creating-a-gantt-chart-with-canvasjs-2nhe</guid>
      <description>&lt;p&gt;Gantt charts are a fantastic way to visualize project timelines by illustrating tasks against time. They help in tracking progress, scheduling, and resource allocation in project management. In this article, we’ll walk through the steps to create a Gantt chart using &lt;a href="https://canvasjs.com/" rel="noopener noreferrer"&gt;&lt;em&gt;CanvasJS&lt;/em&gt;&lt;/a&gt;, a user-friendly JavaScript charting library.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fq1lped0jujdjiut8whln.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fq1lped0jujdjiut8whln.png" alt="Gantt Chart implemented using CanvasJS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Benefits of Gantt Charts
&lt;/h3&gt;

&lt;p&gt;Gantt charts are a staple of project management, and for good reason. They offer a range of benefits, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Clear visualization&lt;/strong&gt;: Gantt charts provide a clear and concise visual representation of the project timeline, making it easy to understand task dependencies and relationships.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Improved scheduling&lt;/strong&gt;: With a Gantt chart, you can schedule resources and allocate tasks to team members with ease.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enhanced planning&lt;/strong&gt;: Gantt charts allow you to plan and visualize the timeline of events and activities, making it easier to identify potential bottlenecks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Steps to Create Gantt Chart
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Setting Up Your Environment
&lt;/h4&gt;

&lt;p&gt;To get started, you need to include the &lt;em&gt;CanvasJS&lt;/em&gt; library in your HTML file by linking it via CDN. Here's the initial HTML structure you can work with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE HTML&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;script src="https://cdn.canvasjs.com/canvasjs.min.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;style&amp;gt;
        #chartContainer {
            height: 400px; 
            width: 100%; 
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div id="chartContainer"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;script&amp;gt;
        // Your Gantt chart code will go here
    &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Creating the Gantt Chart
&lt;/h4&gt;

&lt;p&gt;Creating a Gantt chart in &lt;em&gt;CanvasJS&lt;/em&gt; is a straightforward process that requires just a few simple steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Choose the &lt;em&gt;rangeBar&lt;/em&gt; chart type&lt;/strong&gt;: The &lt;em&gt;rangeBar&lt;/em&gt; chart type is a versatile chart type that can be used to create a Gantt chart-like visualization. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Provide timestamp values as y-values&lt;/strong&gt;: To create a Gantt chart, you'll need to provide timestamp values as y-values. These values will represent the start and end times of each task.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use the &lt;em&gt;CanvasJS.formatDate()&lt;/em&gt; function&lt;/strong&gt;: The &lt;em&gt;CanvasJS.formatDate()&lt;/em&gt; function is used to convert the timestamp values to display date and time values in the labels and tooltip content.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Gantt Chart Configuration
&lt;/h4&gt;

&lt;p&gt;Next, we’ll set up the chart configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const options = {
  ...
  axisY: {
    labelFormatter: function(e){
      return CanvasJS.formatDate(e.value, "MMM D, YYYY");
    },
    gridThickness: 1
  },
  toolTip:{
    contentFormatter: function ( e ) {
      return "&amp;lt;strong&amp;gt;" + e.entries[0].dataPoint.label + "&amp;lt;/strong&amp;gt;&amp;lt;/br&amp;gt; Start: " +  CanvasJS.formatDate(e.entries[0].dataPoint.y[0], "MMM D - h:mm TT") + "&amp;lt;/br&amp;gt;End : " +  CanvasJS.formatDate(e.entries[0].dataPoint.y[1], "MMM D - h:mm TT");
    },
    backgroundColor: "#f7f7f7",
    color: "#333",
    borderThickness: 1,
    borderColor: "#ddd"
  },
  data: [
    {
      type: "rangeBar",
      dataPoints: [
        { label: "Research", y: [(new Date(2024, 9, 4, 9, 0)).getTime(), (new Date(2024, 9, 7, 17, 0)).getTime()] },
        { label: "Design", y: [(new Date(2024, 9, 7, 9, 0)).getTime(), (new Date(2024, 9, 10, 17, 0)).getTime()] },
        { label: "Development", y: [(new Date(2024, 9, 10, 9, 0)).getTime(), (new Date(2024, 9, 20, 17, 0)).getTime()] },
        { label: "Testing", y: [(new Date(2024, 9, 20, 9, 0)).getTime(), (new Date(2024, 9, 25, 17, 0)).getTime()] },
        { label: "Documentation", y: [(new Date(2024, 9, 25, 9, 0)).getTime(), (new Date(2024, 9, 27, 17, 0)).getTime()] },
        { label: "Release &amp;amp; Verify", y: [(new Date(2024, 9, 28, 9, 0)).getTime(), (new Date(2024, 9, 28, 17, 0)).getTime()] }
      ]
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code creates a &lt;em&gt;rangeBar&lt;/em&gt; chart with six tasks, each with a start and end time. The &lt;em&gt;CanvasJS.formatDate()&lt;/em&gt; function is used to convert the timestamp values to display date and time values in the labels and tooltip content.&lt;/p&gt;

&lt;p&gt;Check out this &lt;a href="https://jsfiddle.net/ananyadeka/harmpucn/" rel="noopener noreferrer"&gt;JSFiddle&lt;/a&gt; for the complete code of this example.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tips and Variations
&lt;/h3&gt;

&lt;p&gt;Here are a few tips and variations to help you customize your Gantt chart:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use different colors and styles&lt;/strong&gt;: Use different colors and styles to differentiate between tasks and resources.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add more data points&lt;/strong&gt;: Add more data points to create a more detailed Gantt chart.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Customize the date and time format&lt;/strong&gt;: Use the &lt;em&gt;CanvasJS.formatDate()&lt;/em&gt; function to customize the date and time format.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Experiment with different chart options&lt;/strong&gt;: Experiment with different chart options and settings to customize the appearance and behavior of the Gantt chart.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;And there you have it! You’ve successfully created a Gantt chart using &lt;em&gt;CanvasJS&lt;/em&gt; to visualize how long different activities will take over the course of a project. Feel free to adjust the activities, durations, and other chart configurations to suit your project’s needs.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Customizing Your CanvasJS Charts</title>
      <dc:creator>Ananya Deka</dc:creator>
      <pubDate>Wed, 25 Sep 2024 11:28:27 +0000</pubDate>
      <link>https://dev.to/ananya_deka/customizing-your-canvasjs-charts-4347</link>
      <guid>https://dev.to/ananya_deka/customizing-your-canvasjs-charts-4347</guid>
      <description>&lt;p&gt;&lt;a href="https://canvasjs.com/" rel="noopener noreferrer"&gt;&lt;em&gt;CanvasJS&lt;/em&gt;&lt;/a&gt; is a versatile and powerful charting library that has a simple API, and offers a wide range of customization options. For advanced users looking to create highly tailored and interactive charts, here are some tips and techniques to help you get the most out of &lt;em&gt;CanvasJS&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fbf5p3gx1jdmg9we1s01t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fbf5p3gx1jdmg9we1s01t.png" alt="CanvasJS Combination of Charts"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  ToolTip
&lt;/h4&gt;

&lt;p&gt;Tooltips provide additional information when users hover over data points. In &lt;em&gt;CanvasJS&lt;/em&gt;, the &lt;em&gt;toolTip&lt;/em&gt; object lets the user set the behaviour of toolTip, and customize it according to their requirement.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Custom Content&lt;/em&gt;: Use the &lt;em&gt;content&lt;/em&gt; property to format the tooltip content. HTML tags and data point values can be included to provide relevant information in a concise manner.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;toolTip: { 
    shared: true,
    content: "Category &amp;lt;i&amp;gt;{label}&amp;lt;/i&amp;gt; &amp;lt;br /&amp;gt;Value: {y} units &amp;lt;br /&amp;gt;"     
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Styling Tooltips&lt;/em&gt;: Target the &lt;em&gt;.canvasjs-chart-tooltip&lt;/em&gt; class in your CSS file, which allows application of custom CSS styling to your tooltip.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;style&amp;gt;
    .canvasjs-chart-tooltip  {
         box-shadow: rgba(0, 0, 0, 0.15) 0px 5px 15px 0px !important;
    }
    .canvasjs-chart-tooltip div {
         padding: 8px !important;
    }
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Real-time Data Visualization
&lt;/h4&gt;

&lt;p&gt;Certain applications may require real-time data visualization, and in such cases, &lt;em&gt;CanvasJS&lt;/em&gt; allows you to update data dynamically.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Updating Data Points&lt;/em&gt;: You can use the &lt;em&gt;dataPoints&lt;/em&gt; array within the data object, to update existing data points or add new ones.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chart.data[0].addTo("dataPoints", {
    x: chart.data[0].dataPoints[chart.data[0].dataPoints.length-1].x + 10, y: Math.random() * (100 - 10) + 10})
}); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Live Data Feed&lt;/em&gt;: You can also implement some function to fetch new data at regular intervals and update the chart accordingly.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var updateChart = function () {     
    yVal = yVal +  Math.round(5 + Math.random() *(-5-5));
    dps.push({x: xVal,y: yVal});
    xVal++;

    if (dps.length &amp;gt;  10 ) {
        dps.shift();                
    }

    chart.render();     
};

setInterval(function(){updateChart()}, updateInterval);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Axis Customization
&lt;/h4&gt;

&lt;p&gt;CanvasJS provides several attributes within the &lt;em&gt;axis&lt;/em&gt; object that allow customizations, and can help make your chart more readable, informative, and attractive.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Custom Labels&lt;/em&gt;: Use the &lt;em&gt;labelFormatter&lt;/em&gt; function to customize the axis labels.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;axisX: {
    labelFormatter: function (e) {
        return CanvasJS.formatDate( e.value, "DD MMM");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Grid Lines and Ticks&lt;/em&gt;: Customize the appearance of grid lines and ticks to improve chart readability.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;axisX:{
    gridThickness: 1,
    gridColor: "#ddd",
    tickColor: "#000"
},
axisY:{
    gridColor: "#ddd",
    tickColor: "#000"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  User Interactivity
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;CanvasJS&lt;/em&gt; offers event handlers for various events across different elements, which can be used to enhance the user experience.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Click Events&lt;/em&gt;: Add &lt;em&gt;click&lt;/em&gt; event handlers to data points or the chart itself, to make it a more interactive experience.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data: [
    {
        click: (e) =&amp;gt; {
            if(!e.dataPoint.indexLabel)
                e.dataPoint.indexLabel = (e.dataPoint.y).toString();
            else e.dataPoint.indexLabel = "";
                e.chart.render();
        },
        dataPoints: [
            { x: 10, y: 34},
            { x: 20, y: 45},
            { x: 30, y: 19 },
            { x: 40, y: 75 },
            { x: 50, y: 15 },
            { x: 60, y: 60 },
            { x: 70, y: 48 },
            { x: 80, y: 04 },
            { x: 90, y: 35 }
        ]
    }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Mouseover and Mouseout&lt;/em&gt;: Set &lt;em&gt;mouseover&lt;/em&gt; and &lt;em&gt;mouseout&lt;/em&gt; handlers for data points to customize hover effects.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data: [
    {
        mouseover: (e) =&amp;gt; {
            let markerSize = e.chart.data[e.dataSeriesIndex].dataPoints[e.dataPointIndex].markerSize || e.chart.data[e.dataSeriesIndex].markerSize;
            e.dataPoint.markerSize = markerSize*1.5;
            e.chart.render();
        },
        mouseout: (e) =&amp;gt; {
            let markerSize = e.chart.data[e.dataSeriesIndex].dataPoints[e.dataPointIndex].markerSize || e.chart.data[e.dataSeriesIndex].markerSize;
            e.dataPoint.markerSize = markerSize / 1.5;
            e.chart.render();
        },
        type: "scatter",
        dataPoints: [
            { x: 10, y: 34},
            { x: 20, y: 45},
            { x: 30, y: 19 },
            { x: 40, y: 75 },
            { x: 50, y: 15 },
            { x: 60, y: 60 },
            { x: 70, y: 48 },
            { x: 80, y: 04 },
            { x: 90, y: 35}
        ]
    }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Mixed Chart Types
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;CanvasJS&lt;/em&gt; allows you to combine different chart types in a single chart to provide a more comprehensive view of your data. For example, line and column charts can be combined to show trends and comparisons across different categories.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data: [
   {
        type: "column",
        name: "Actual Sales",
        dataPoints: [
            { x: new Date(2016, 0), y: 20000 },
            { x: new Date(2016, 1), y: 30000 },
            { x: new Date(2016, 2), y: 25000 },
            { x: new Date(2016, 3), y: 70000 },
            { x: new Date(2016, 4), y: 50000 },
            { x: new Date(2016, 5), y: 35000 },
            { x: new Date(2016, 6), y: 30000 },
            { x: new Date(2016, 7), y: 43000 },
            { x: new Date(2016, 8), y: 35000 },
            { x: new Date(2016, 9), y: 30000 },
            { x: new Date(2016, 10), y: 40000 },
            { x: new Date(2016, 11), y: 50000 }
        ]
    }, 
    {
        type: "line",
        name: "Expected Sales",
        dataPoints: [
            { x: new Date(2016, 0), y: 40000 },
            { x: new Date(2016, 1), y: 42000 },
            { x: new Date(2016, 2), y: 45000 },
            { x: new Date(2016, 3), y: 45000 },
            { x: new Date(2016, 4), y: 47000 },
            { x: new Date(2016, 5), y: 43000 },
            { x: new Date(2016, 6), y: 42000 },
            { x: new Date(2016, 7), y: 43000 },
            { x: new Date(2016, 8), y: 41000 },
            { x: new Date(2016, 9), y: 45000 },
            { x: new Date(2016, 10), y: 42000 },
            { x: new Date(2016, 11), y: 50000 }
       ]
    }   
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Customizing &lt;em&gt;CanvasJS&lt;/em&gt; charts can significantly enhance the visual appeal and functionality of your data visualizations. By leveraging features the likes of the ones discussed in this article, you can create highly engaging and informative charts. These tips will help you unlock the full potential of &lt;em&gt;CanvasJS&lt;/em&gt; and create charts that stand out.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>canvasjs</category>
    </item>
    <item>
      <title>Analyzing Trends with Technical Indicators in CanvasJS</title>
      <dc:creator>Ananya Deka</dc:creator>
      <pubDate>Mon, 23 Sep 2024 13:57:40 +0000</pubDate>
      <link>https://dev.to/ananya_deka/analyzing-trends-with-technicalindicators-in-canvasjs-29m1</link>
      <guid>https://dev.to/ananya_deka/analyzing-trends-with-technicalindicators-in-canvasjs-29m1</guid>
      <description>&lt;p&gt;In the world of trading, technical indicators are invaluable for analyzing market trends and making informed decisions. This article will demonstrate how to utilize the &lt;a href="https://www.npmjs.com/package/technicalindicators" rel="noopener noreferrer"&gt;&lt;em&gt;technicalIndicators&lt;/em&gt;&lt;/a&gt; library alongside &lt;a href="https://canvasjs.com/docs/stockcharts/basics-of-creating-html5-stockchart/" rel="noopener noreferrer"&gt;&lt;em&gt;CanvasJS&lt;/em&gt;&lt;/a&gt; to visualize a few key indicators: Simple Moving&lt;br&gt;
Average (SMA), Exponential Moving Average (EMA), Relative Strength Index (RSI), On Balance Volume (OBV), and Bollinger Bands.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fieo0wvauzrx9roo19ldk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fieo0wvauzrx9roo19ldk.png" alt="Analysing Trends with Technical Indicators" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Understanding Technical Indicators
&lt;/h4&gt;

&lt;p&gt;Technical indicators are calculations based on historical price data, helping traders gauge market conditions and predict future price movements. Some commonly used indicators include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Simple Moving Average (SMA)&lt;/strong&gt;: SMA calculates the average of a selected range of prices, usually closing prices, over a specified period.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exponential Moving Average (EMA)&lt;/strong&gt;: EMA is similar to SMA but gives more weight to recent prices, making it more responsive to new information.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relative Strength Index (RSI)&lt;/strong&gt;: RSI measures the speed and change of price movements, oscillating between 0 and 100. It is typically used to identify overbought or oversold conditions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;On Balance Volume (OBV)&lt;/strong&gt;: OBV is a momentum indicator that uses volume flow to predict changes in stock price. It adds volume on up days and subtracts volume on down days.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bollinger Bands&lt;/strong&gt;: Bollinger Bands consist of a middle band (SMA) and two outer bands (standard deviations above and below the SMA). They help identify overbought and oversold conditions.&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;
  
  
  Implementing Technical Indicators with &lt;em&gt;technicalindicators&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;The &lt;em&gt;technicalindicators&lt;/em&gt; package simplifies the calculation of these indicators. Below is a step-by-step guide to implementing SMA, EMA, RSI, OBV, and Bollinger Bands in a CanvasJS StockChart:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Setting Up Your Environment&lt;/strong&gt;
First, include the necessary CanvasJS scripts and install the &lt;em&gt;technicalindicators&lt;/em&gt; package:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script type="text/javascript" src="https://cdn.canvasjs.com/canvasjs.stock.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="https://cdn.jsdelivr.net/npm/technicalindicators@3.0.0/dist/browser.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Adding Technical Indicators&lt;/strong&gt;
Use the &lt;em&gt;technicalindicators&lt;/em&gt; package to calculate SMA, RSI and the other mentioned technical indicators. Format the calculated indicators to the format accepted by CanvasJS, and adjust the indices to
align with the datapoints correctly.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function getSMADataSeries(input) {
    let dataPoints = [];
    const sma = SMA.calculate({period: 20, values: input.close});
    let data = {
      type: "line",
      name: "sma",
      dataPoints: sma.map((elem, index) =&amp;gt; ({ x: new Date(new Date(input.date[index]).getTime() + (20 * 24 * 60 * 60 * 1000)), y: elem })
      ),
    };
    return data;
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;iframe src="https://jsfiddle.net/ananyadeka/1owg5vsb//embedded//dark" width="100%" height="600"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h4&gt;
  
  
  Analyzing Trends
&lt;/h4&gt;

&lt;p&gt;With the chart set up, you can now analyze market trends:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Identify Trends&lt;/strong&gt;: Look at how the price relates to the SMA and EMA. Prices above the moving averages suggest an upward trend, while those below indicate a downward trend.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Crossovers&lt;/strong&gt;: A bullish crossover occurs when the price moves above the SMA or EMA, indicating a potential buying opportunity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Bollinger Bands&lt;/strong&gt;: The distance between the upper and lower bands indicates market volatility. When bands are close together, it suggests lower volatility, while wider bands indicate higher volatility.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;OBV Analysis&lt;/strong&gt;: OBV can provide insight into buying/selling pressure. Rising OBV suggests accumulation, while falling OBV indicates distribution.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By integrating the &lt;em&gt;technicalIndicators&lt;/em&gt; library with &lt;em&gt;CanvasJS&lt;/em&gt;, you can easily calculate and visualize various technical indicators. This approach enables you to analyze market trends more effectively and make informed trading decisions. As you become comfortable with these tools, feel free to explore additional indicators and customization options to enhance your trading strategies.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>canvasjs</category>
      <category>stockcharts</category>
    </item>
  </channel>
</rss>
