Home Forums Chart Support chart render fails when $.get pings servlet that returns string.

chart render fails when $.get pings servlet that returns string.

Viewing 4 posts - 1 through 4 (of 4 total)
  • #25879

    Hi all, my chart renders good when i use the $get method like below, where path to the CSV file is explicitly mention in the url of $.get
    $.get(“/files/ReloadedOIFiles/BankNiftyOptionChain_todisplayinchart.csv” , getDataPointsFromCSV);

    csv file has data like
    Jul 12 2019,11:44:23,30647.6,1402680,986080,409059,884740,478260,346442,755501,-507820
    Jul 12 2019,11:44:53,30642.2,1402680,986080,409842,884740,478260,346911,756753,-507820

    but when $.get invokes servlet , even though the servlet sends String data with data format as in csv, and the window.alert successfully gives the lines and the values that are split with coma, chart rendering is not happening.

    below is the code.

    $.get(“LoadLiveChart”,{TradingDate:tradingDate,LowerStrike:lowerStrike,UpperStrike:upperStrike,LastLine:lastLine} , getDataPointsFromCSV);

    var chart1 = new CanvasJS.Chart(“chartContainer1”, {
    animationEnabled: true,
    exportEnabled: true,
    text: “Bank Nifty Index ”


    title: “Time”,
    crosshair: {
    enabled: true,
    snapToDataPoint: true
    axisY: {
    title: “Bank Nifty Index”,
    includeZero: false,
    crosshair: {
    enabled: true,
    snapToDataPoint: true}
    data: [{
    type: “line”,
    axisYType: “primary”,
    toolTipContent: “{y} Bank Nifty Index”,
    dataPoints: dataPoints1

    function getDataPointsFromCSV(csv) {
    var csvLines = points = [];
    csvLines = csv.split(/[\r?\n|\r|\n]+/);
    for (var i = 0; i < csvLines.length; i++) {
    if (csvLines[i].length > 0) {
    points = csvLines[i].split(“,”);
    label: points[1],
    y: parseInt(points[2])


    It would be of great help if some one helps me in this case as i have spent many hours trying to make it work.I even tried with JSON, but the chart does not render even then. is there anything i am missing with $.get



    Can you kindly share a sample project along with sample data over Google-Drive or Onedrive so that we can look at your code, understand it better and help you out?

    Manoj Mohan
    Team CanvasJS


    Hi Manoj, i could resolve it. error was due to wrong coding. thanks.



    Glad that you were able to resolve the issue and make it work :)

    Manoj Mohan
    Team CanvasJS

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.