jQWidgets Forums

jQuery UI Widgets Forums Getting Started Setting JSON object in JQWIDGET chart

This topic contains 1 reply, has 1 voice, and was last updated by  aroopkumar792 8 years ago.

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

  • aroopkumar792
    Participant

    Hi,

    I was using the JQwidget chart.
    I have a JSON object:
    [{“quantity_sold”:”60″,”product”:”books”,”quantity”:”100″},{“quantity_sold”:”20″,”product”:”pens”,”quantity”:”100″},{“quantity_sold”:”40″,”product”:”pencils”,”quantity”:”200″}]

    I need to set this JSON object to the chart different axis.
    But even though the JSON format is right. I am not able to set the JSON .

    By code is:
    var settings = {
    title: “Products and their quantities”,
    description: “Products sold”,
    padding: { left: 5, top: 5, right: 5, bottom: 5 },
    titlePadding: { left: 90, top: 0, right: 0, bottom: 10 },
    source: sampleData,
    categoryAxis:
    {
    dataField: ‘product’,
    showGridLines: true
    },
    colorScheme: ‘scheme01’,
    seriesGroups:
    [
    {
    type: ‘column’,
    columnsGapPercent: 30,
    seriesGapPercent: 0,
    valueAxis:
    {
    minValue: 0,
    maxValue: 100,
    unitInterval: 10,
    description: ‘Quantity in KG’
    },
    series: [
    { dataField: ‘quantity’,
    displayText: ‘Total’},
    { dataField: ‘quantity_sold’,
    displayText: ‘Sold’},
    ]
    }
    ]
    };
    // setup the chart
    $(‘#chartContainer’).jqxChart(settings);
    }});

    Please help me .

    Thanks

    Setting JSON object in JQWIDGET chart #92784

    aroopkumar792
    Participant

    I got the solution from JQWidget Chart data source article:
    var source =
    {
    datatype: “json”,
    datafields: [
    { name: ‘product’},
    { name: ‘quantity’},
    { name: ‘quantity_sold’}
    ],
    url: ‘json/json.js’
    };

    var dataAdapter = new $.jqx.dataAdapter(source,
    {
    autoBind: true,
    async: false,
    downloadComplete: function () { },
    loadComplete: function () { },
    loadError: function () { }
    });

    // prepare jqxChart settings
    var settings = {
    title: “Products and their quantities”,
    description: “Products sold”,
    padding: { left: 5, top: 5, right: 5, bottom: 5 },
    titlePadding: { left: 90, top: 0, right: 0, bottom: 10 },
    source: dataAdapter,
    categoryAxis:
    {
    dataField: ‘product’,
    showGridLines: true
    },
    colorScheme: ‘scheme01’,
    seriesGroups:
    [
    {
    type: ‘column’,
    columnsGapPercent: 30,
    seriesGapPercent: 0,
    valueAxis:
    {
    minValue: 0,
    maxValue: 220,
    unitInterval: 10,
    description: ‘Quantity in KG’
    },
    series: [
    { dataField: ‘quantity’, displayText: ‘Total’},
    { dataField: ‘quantity_sold’, displayText: ‘Sold’},
    ]
    }
    ]
    };
    // setup the chart
    $(‘#chartContainer’).jqxChart(settings);

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

You must be logged in to reply to this topic.