jQWidgets Forums
jQuery UI Widgets › Forums › Chart › Scale chart according to given percentage value
This topic contains 3 replies, has 2 voices, and was last updated by Dimitar 11 years, 8 months ago.
-
Author
-
Hi,
I want to resize chart with given percentage value. e.g if chart size set to 100% , it will show full size image set according to browser window size, and if chart size set to 60%, it must scale its size accordingly ,
Can we scale chart size according to given percentage value?
Thanks.
Hello abc,
Here is an example of a chart set to 100% width and height:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html lang="en"><head> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <style type="text/css"> body, html { width: 100%; height: 100%; } </style> <script type="text/javascript" src="../../scripts/jquery-1.10.2.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxchart.js"></script> <script type="text/javascript"> $(document).ready(function () { // prepare the data var source = { datatype: "tab", datafields: [ { name: 'Date' }, { name: 'Referral' }, { name: 'SearchPaid' }, { name: 'SearchNonPaid' } ], url: '../sampledata/website_analytics.txt' }; var dataAdapter = new $.jqx.dataAdapter(source, { async: false, autoBind: true, loadError: function (xhr, status, error) { alert('Error loading "' + source.url + '" : ' + error); } }); var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; // prepare jqxChart settings var settings = { title: "Web Traffic Analysis", description: "Unique site visitors in January 2012", enableAnimations: true, showLegend: true, padding: { left: 10, top: 5, right: 10, bottom: 5 }, titlePadding: { left: 90, top: 0, right: 0, bottom: 10 }, source: dataAdapter, categoryAxis: { type: 'date', baseUnit: 'day', textRotationAngle: 0, dataField: 'Date', formatFunction: function (value) { return value.getDate(); }, toolTipFormatFunction: function (value) { return value.getDate() + '-' + months[value.getMonth()] + '-' + value.getFullYear(); }, showTickMarks: true, tickMarksInterval: 1, tickMarksColor: '#888888', unitInterval: 1, showGridLines: true, gridLinesInterval: 30, gridLinesColor: '#888888', valuesOnTicks: true }, colorScheme: 'scheme06', seriesGroups: [ { type: 'stackedarea100', valueAxis: { unitInterval: 20, displayValueAxis: true, description: 'Daily visitors', tickMarksColor: '#888888' }, series: [ { dataField: 'SearchNonPaid', displayText: 'Organic Search Traffic' }, { dataField: 'SearchPaid', displayText: 'Paid Search Traffic' }, { dataField: 'Referral', displayText: 'Referral Traffic' } ] } ] }; // setup the chart $('#jqxChart').jqxChart(settings); }); </script></head><body class='default'> <div id='jqxChart' style="width: 100%; height: 100%;"> </div></body></html>
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar,
Thanks, I have set its height and width , it is resizing chart according to window size, its so much helpful.
but getting one more issue,When we re-size window the category axis values are getting mixed, and its not understandable,
see ” javascript_chart_bar_series.htm ” demo example and set its height and width like you shown in above example,
and re-size window to minimum width and check, you will see that the values of category axis are mixed,
please suggest any solution for this issue..Thanks.
Hi abc,
A possible solution is to set the textRotationAngle property of the categoryAxis to 90.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.