jQuery UI Widgets Forums Chart Pie-chart legend problems

Tagged: , , ,

This topic contains 1 reply, has 2 voices, and was last updated by  Dimitar 11 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Pie-chart legend problems #11588

    diekwagga
    Member

    Hi there,

    Upon creating a pie chart, I’m trying to set the legend to display vertically next to the pie chart:
    legendLayout: { left: 225, top: 60, width: 50, height: 500, padding:5, flow: ‘vertical’ },

    However, the chart data is very dynamic and can be a huge list of data or a few entries. The problem this causes, is that the legend items fill a new column when reaching the height of the grid. This causes padding issues with the legend items.

    My question is: Is there any way to change the chart to:

    i) Display the top 5/10 legend items, or
    ii) Apply padding to the legend items, or
    iii) Prevent the legend from creating a new column of items when the items has reached the height of the grid.

    Your swift correspondence will be highly appreciated.

    Pie-chart legend problems #11693

    Dimitar
    Participant

    Hello diekwagga,

    By modifying legendLayout, padding and the chart div’s width and height, you can fully customize the chart and its legends layout. For example:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html lang="en">
    <head>
    <title id='Description'>jqxChart Pie Series Legend Example</title>
    <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" src="../../scripts/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxchart.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
    <script type="text/javascript">
    $(document).ready(function () {
    // prepare chart data as an array
    var source =
    {
    datatype: "csv",
    datafields: [
    { name: 'Browser' },
    { name: 'Share' }
    ],
    url: '../sampledata/mobile_browsers_share_dec2011.txt'
    };
    var dataAdapter = new $.jqx.dataAdapter(source, { async: false, autoBind: true, loadError: function (xhr, status, error) { alert('Error loading "' + source.url + '" : ' + error); } });
    // prepare jqxChart settings
    var settings = {
    title: "Mobile browsers share in Dec 2011",
    description: "(source: wikipedia.org)",
    enableAnimations: true,
    showLegend: true,
    legendLayout: { left: 50, top: 50, width: 70, height: 700, flow: 'vertical' },
    padding: { left: 400, top: 5, right: 5, bottom: 100 },
    titlePadding: { left: 0, top: 0, right: 0, bottom: 10 },
    source: dataAdapter,
    colorScheme: 'scheme03',
    seriesGroups:
    [
    {
    type: 'pie',
    showLabels: true,
    series:
    [
    {
    dataField: 'Share',
    displayText: 'Browser',
    labelRadius: 120,
    initialAngle: 15,
    radius: 95,
    centerOffset: 0,
    formatSettings: { sufix: '%', decimalPlaces: 1 }
    }
    ]
    }
    ]
    };
    // setup the chart
    $('#jqxChart').jqxChart(settings);
    });
    </script>
    </head>
    <body class='default'>
    <div id='host' style="margin: 0 auto; width: 699px; height: 700px;">
    <div id='jqxChart' style="width: 680px; height: 700px; position: relative; left: 0px;
    top: 0px;">
    </div>
    </div>
    </body>
    </html>

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.