Home forums Using CanvasJS Creating a column using jquery (GetJson) result variable

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #28247

    Hallo,
    I am new with canvasjs and Javascript anyway. I found Posts similar to my issue but could not find a solution in following the instructions provided in the answers.

    When I used hard corded intergers in my Code, everything works fine.

    Code:
    ——
    anychart.onDocumentReady(function () {
    var chart = anychart.column();
    var tooltip = chart.tooltip();
    var yaxis = chart.yAxis().labels();
    tooltip.format(“{%value}{groupsSeparator:\\.}”);
    yaxis.format(“{%value}{groupsSeparator:\\.}”);
    series = chart.column([
    {x: ‘2019’, value: 2583894},
    {x: ‘2018’, value: 3075778},
    {x: ‘2017’, value: 1680455},
    {x: ‘2016’, value: 1497074},
    {x: ‘2015’, value: 1788678},
    {x: ‘2014’, value: 768014},
    {x: ‘2013’, value: 102911}
    ]);
    chart.title(‘Year 2013 – 2019’);
    chart.yScale().ticks().interval(500000);
    chart.container(‘grafik’);
    chart.draw();
    });

    My Problem is, I want “value” to be filled with an integer provided by the result of a jquery search on a solr.
    The request which stores the result in “#countTH_pdf” Looks like this:

    $.getJSON(‘../api/v1/search?q=objectProject:TH* AND (sb_format:”PDF”) AND state:published&wt=json’,
    function (data) {
    $(‘#countTH_pdf’).text(data.response.numFound)
    });

    How do I manage “#countTH_pdf” to be siplayed as an integer of “value:” I tried

    {x: ‘2017’, value: Number(countTH_pdf)},

    But is not working. What is missing in my Code?
    I appreciate any Kind of help!

    #28271

    @michel-m,

    Please take a look at this example to render CanvasJS chart using json data.

    —-
    Manoj Mohan
    Team CanvasJS

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

You must be logged in to reply to this topic.