Forum Replies Created by Thangaraj Raman

Viewing 15 posts - 121 through 135 (of 232 total)
  • in reply to: Live StockChart with Navigator #41964

    @mcigorli,

    1. How to make the navigator follow the new data if the navigator is in the far right corner?

    Please check this gallery page for an example of a dynamic/live stockchart where the position of the slider is updated as new data is added to the chart.

    2. How to make a gap at the beginning as shown in the picture?

    You can set the x-axis viewPortMaximum to a value greater than the last datapoint to add gap towards the right side of the chart as per your requirement from the screenshot.


    Thangaraj Raman
    Team CanvasJS

    in reply to: chart is not loading when intervaltype is change #41945

    @kishanbhola1311gmail-com,

    The range between the datapoints in your example is in minutes, however, you are setting the intervalType to hour, due to which axis labels are missing since labels are outside the viewport range. Setting x-axis viewportMinimum seems to be working fine in your case.

    Please check this JSFiddle for a working example.


    Thangaraj Raman
    Team CanvasJS

    in reply to: Easiest Google Sheets Integration? #41933

    @hejenemy,

    You can read a specific row from the CSV file by its index / header. Please take a look at this documentation page for a step-by-step tutorial on rendering charts with data from a CSV file and parsing it. Also, please refer to this article for more information on parsing CSV data.


    Thangaraj Raman
    Team CanvasJS

    in reply to: Easiest Google Sheets Integration? #41913

    @hejenemy,

    You can publish Google-Sheet as CSV and use the URL generated to fetch data using jQuery AJAX as shown in this JSFiddle.

    Chart with data from external CSV


    Thangaraj Raman
    Team CanvasJS

    in reply to: 2 Stacked area charts with same x-axis? #41874

    @canvas_chartist,

    The x-axis cannot be positioned to the middle of the chart as of now. However, you can create a multi-series area chart with positive and negative values to achieve your requirement.

    Please check this JSFiddle for a working example.

    Multi-series are chart


    Thangaraj Raman
    Team CanvasJS

    in reply to: Adding the decimal places to the Y-axis #41854

    @elanchezhiyan,

    You can use labelFormatter function instead of valueFormatString and set the label format using the formatNumber() method. Please take a look at the code snippet below.

    labelFormatter: function(e) {
       if(e.value >= 0 && e.value <= 1)
          return CanvasJS.formatNumber(e.value, "0.00");
       else if (e.value >= 1 && e.value <=10 )
          return CanvasJS.formatNumber(e.value, "0.0");
       else 
          return CanvasJS.formatNumber(e.value, "0");
    }

    Please check this updated JSFiddle for a working example.


    Thangaraj Raman
    Team CanvasJS

    in reply to: Changing background color using my own CSS #41844

    @colibrisan,

    In order to change the background color of the chart using CSS, you will have to first set the chart backgroundColor property to transparent. You can then, apply CSS styles to the chart container using the chart id.

    Please check this JSFiddle for a working example similar to your requirement, which shows how to set gradient as chart background using CSS.

    Set chart background using CSS


    Thangaraj Raman
    Team CanvasJS

    in reply to: Show tooltip when hovered over stripline label #41600

    @mustadirmahmood,

    Sorry, it is not possible to display a tooltip for stripline labels as of now. However, as a workaround, you can position the stripline label to the center of the plot area using the labelAlign property and add a scatter point for displaying the tooltip content. Please take a look at the code snippet below:

    chart.addTo("data", {
        type: "scatter",
        markerSize: 0,
        highlightEnabled: false,
        toolTipContent: "Content to be displayed on hover",
        dataPoints: [{
          x: (chart.axisX[0].viewportMaximum + chart.axisX[0].viewportMinimum) / 2 , 
          y: chart.axisY[0].stripLines[0].value
        }]
    })

    Please check this JSFiddle for a working example.

    Tooltip for stripline labels


    Thangaraj Raman
    Team CanvasJS

    in reply to: Bar chart showing 1 and -1 value #41372

    @alfonso-arroyo,

    It looks like you are setting the axisX interval manually due to which the extra labels -1 and 1 are shown. Based on the interval & other factors, the axis range is calculated & hence the extra labels are added in this case. You can overcome this behavior by either not setting interval when there are fewer datapoints or by manually setting the axis range.

    Please take a look at this JSFiddle for a working example.

    Bar Chart with Single Label


    Thangaraj Raman
    Team CanvasJS

    in reply to: Stripline – index label position – adjustments #40141

    @elanchezhiyan,

    You can update the position of the scatter datapoints on resizing the window by calculating the width of the index labels and using convertPixeltoValue. Please check the code snippet below:

    window.onresize = function() {
      indexLabelOffset = (chart.width < 700) ? 5 : 2 ;
      for(var i = 0; i < customLinesData.length; i++) {
        for(var j = 0; j < scatterDps.length; j++) {
          if( scatterDps[j].indexLabel === "\u25C0 " + customLinesData[i].label) {
    	indexLabelWidth = getWidth(customLinesData[i].label);
         	scatterDps[j].x = customLinesData[i].x + chart.axisX[0].convertPixelToValue(indexLabelWidth) / 2 + indexLabelOffset;
          }
        } 
      }
      chart.render();
    };

    Please take a look at this updated JSFiddle for a working example.


    Thangaraj Raman
    Team CanvasJS

    in reply to: Stripline – index label position – adjustments #40020

    @elanchezhiyan,

    Striplines are drawn from end to end across the full width/height of the plot-area. However, in your case, you can use a multi-series line chart with interactivity disabled and 2 datapoints each to represent the start and end coordinates of the line. To display text representing each line, you can use a scatter chart with indexlabels.

    Please take a look at this JSFiddle for a working example.

    Multi Series Line Chart


    Thangaraj Raman
    Team CanvasJS

    in reply to: How to change dataPoints axisY Y value dynamically #39765

    @rashedk,

    To update the y value of a datapoint using a dropdown menu you need to update the chart options / data based on the options selected from the dropdown list. Please check the code snippet below.

    var country = document.getElementById("country");
    country.addEventListener( "change",  function(){
      for(var i = 0; i < chart.options.data[0].dataPoints.length; i++) {
        if(country.options[country.selectedIndex].text === chart.options.data[0].dataPoints[i].label)
          chart.options.data[0].dataPoints[i].y = Number(country.options[country.selectedIndex].value);
      }
      chart.render();
    });

    Please take a look at this JSFiddle for a working example.


    Thangaraj Raman
    Team CanvasJS

    in reply to: A proper way to destroy charts #39667

    @walterschaefer,

    It seems to be working fine. Can you kindly create a sample project reproducing the issue you are facing and share it with us over Google Drive or OneDrive so that we can look into your code, run it locally at our end to understand the scenario better, and help you out?


    Thangaraj Raman
    Team CanvasJS

    in reply to: Y-Axis StripLines side-by-side #39479

    @mgavserv,

    Striplines are drawn from end to end across the full width/height of the plot-area. You can use rangeArea chart with interactivity disabled for the corresponding dataseries to achieve your requirement.

    Please take a look at this JSFiddle for a working example.

    Chart with highlighted regions


    Thangaraj Raman
    Team CanvasJS

    in reply to: dynamic Year-Month on Axis value-bar chart #39466

    @rajuweb,

    You can pass x-value in date-time format and use valueFormatString to define how axis labels must be formatted before they appear on the x-axis.


    Thangaraj Raman
    Team CanvasJS

Viewing 15 posts - 121 through 135 (of 232 total)