Forum Replies Created by Ananya

Viewing 11 posts - 31 through 41 (of 41 total)
  • in reply to: how to enable export csv in canvas js angualr chart #44715

    @himak,

    Exporting chart data as CSV is not available as an in-built feature as of now. However, with few lines of code, you can achieve the same as shown in this JSFiddle. You can even use the export-canvasjs-chart-data-as-csv npm package to export chart data as CSV in Angular app. Please take a look at this Stackblitz project for an example of the same.

    Exporting Angular Chart Data as CSV


    Ananya Deka
    Team CanvasJS

    in reply to: Creating a chart from a JSON file #44692

    @murrayr,

    Due to security measures, web browsers impose restrictions on reading local files & cross-origin requests. To work around this, one effective approach is to serve your JSON file from a local web server or utilize a CORS-enabled JSON hosting service like npoint.io. By doing so, you enable your web application to fetch data seamlessly without encountering the cross-origin limitations. Please take a look at this JSFiddle for an example of the same.

    Column chart with data from JSON file


    Ananya Deka,
    Team CanvasJS

    in reply to: When exporting a chart to PNG, change the axis color. #44665

    sora,

    To change the axis colour before exporting the chart, you can change the theme to a light theme before export and revert it back after. Please take a look at this JSFiddle for an example of the same.

    Changing Theme in the Exported Image


    Ananya Deka
    Team CanvasJS

    in reply to: rangeChanged firing while panning #44629

    @fdelvalle,

    1) What is the difference between rangeChanging and rangeChanged then? They seem to fire just one after another.

    rangeChanging is fired just before the range of the chart is about to be changed, i.e., before rendering takes place. rangeChanged is triggered after the chart has been rendered with the updated viewport range. rangeChanging can be useful for modifying chart options based on the new range before the chart updates, while rangeChanged is suitable for tasks that need to react to the finalized change in the range.

    2) Is there a way to detect when the Pan ends? My intention is to query the database for new values only when Pan or Zoom ends.

    You can check if panning has ended or not with the help of rangeChanged event and mouseup event. Please check the code-snippet below.

    rangeChanged: function(e) {
          if(e.trigger === 'pan') {
            panning = true;
          }
        }
    
    document.addEventListener('mouseup', function () {
        if(panning) {
          // query your database here
          panning = false;
        }
      });

    Please take a look at this JSFiddle for an example of the same.

    Ananya Deka
    Team CanvasJS

    in reply to: rangeChanged firing while panning #44611

    @fdelvalle,

    While panning, the axis range is being changed as you move the mouse along the chart and hence rangeChanged will be fired at every instance. In contrast, while zooming the range is changed only once after the desired range has been selected, and as a result rangeChanged is fired only once. The sequence of fired events while panning, i.e., rangeChanging followed by rangeChanged, is the intended behaviour.


    Ananya Deka
    Team CanvasJS

    @kkoroleva,

    We don’t have CanvasJS Charts TypeScript definition as of now. However, charts seems to work fine with TypeScript as well. You can ignore the corresponding error by adding //@ts-ignore above the import statement as shown in the code-snippet below:

    //@ts-ignore
    import * as CanvasJS from '@canvasjs/charts';


    Ananya Deka
    Team CanvasJS

    @kkoroleva,

    You can import CanvasJS from @canvasjs/charts package directly in this case. Please find the code-snippet below.

    import * as CanvasJS from '@canvasjs/charts';
    

    Please check out CanvasJS npm package from this link.


    Ananya Deka
    Team CanvasJS

    in reply to: Large Data Query Question #44546

    Doug,

    You can use rangeChanging event to update the data with a new set of datapoints based on the zoomed range. Please take a look at this JSFiddle for an example of the same.
    Data Filtering in Column Chart

    —-
    Ananya Deka
    Team CanvasJS

    Aung,

    Range Selector is a part of StockChart, and not Chart. Using StockChart instead of Chart should fulfill your requirement.

    StockChart With Range Selector

    __
    Ananya Deka
    Team CanvasJS

    in reply to: Convert chart to base64 image #44096

    @lujakob

    You can get base64 image data of a canvas by using toDataURL method. As CanvasJS charts are rendered on canvas, you can use toDataURL to get base64 image data of the chart. Please find the code-snippet below:

    var base64Image = chart.canvas.toDataURL();

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

    Export Chart as Base64 Image


    Ananya Deka
    Team CanvasJS

    in reply to: Stacked Column Wrong Label X #43973

    @danura,

    In case of Stacked Charts, datapoints across multiple dataseries are aligned based on x-values and not the labels. Passing x-value along with label should work fine in this case. Please take a look at this JSFiddle for an example.


    Ananya Deka
    Team CanvasJS

Viewing 11 posts - 31 through 41 (of 41 total)