How can I make the jChartFx pie chart responsize in size? There is a lot of empty space around the chart. I want to be able to increase/decrease the size of the jChartFx chart as the window increase/decrease. Thx
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Question
StatementSolutions
How can I make the jChartFx pie chart responsize in size? There is a lot of empty space around the chart. I want to be able to increase/decrease the size of the jChartFx chart as the window increase/decrease. Thx
Code:
@model ePortfolio.Models.WidgetViewModel
@using System.Web.Script.Serialization;
<div class="widget-head" style="display:block;overflow:no-content;height:10%;width:100%;">
<div class="widget-title text-center" style="padding-top:10px;"><label>@Model.Widget.Title</label></div>
<div id="id-refresh-@Model.Widget.Id" class="wdgbkg"> </div>
@*<div id="header">
<table class="tablesorter" border="0" cellpadding="0" cellspacing="1" width="100%" height="100%">
<tr>
<th class="wdgcenter" style="width:50px">Qty/Shares</th>
<th class="wdgcenter" style="width:50px">Account #</th>
<th class="wdgcenter" style="width:50px">% of Portfolio</th>
</tr>
</table>
</div>*@
</div>
<div class="widget-body" style="display: inline-block;overflow: visible;height:100%;width:100%;">
<div class="widget-content" id="ChartDiv" style="display: inline-block; overflow: visible;height:90%;width:100%;"></div>
</div>
<script type="text/javascript" language="javascript">
var chart@(Model.Widget.Id);
function LoadPieChart() {
chart@(Model.Widget.Id) = new cfx.Chart();
chart@(Model.Widget.Id).setGallery(cfx.Gallery.Pie);
chart@(Model.Widget.Id).getAllSeries().getPointLabels().setVisible(true);
var pieAttr = chart@(Model.Widget.Id).getAllSeries().getGalleryAttributes();
pieAttr.setLabelsInside(true);
pieAttr.setExplodingMode(cfx.ExplodingMode.First);
//chart@(Model.Widget.Id).getAllSeries().getPointLabels().setFormat("%l %p%%");
chart@(Model.Widget.Id).getAllSeries().getPointLabels().setFormat("%p%%");
var str = @Html.Raw(Json.Encode(ViewData["Asset Allocations Chart"]));
chart@(Model.Widget.Id).getAxisY().getDataFormat().setDecimals(2);
chart@(Model.Widget.Id).getView3D().setEnabled(true);
//chart@(Model.Widget.Id).getAllSeries().getPointLabels().setVisible(true);
chart@(Model.Widget.Id).setDataSource(str);
//chart@(Model.Widget.Id).getAllSeries().getPointLabels().setVisible(true);
var data = chart@(Model.Widget.Id).getData();
data.setSeries(1);
data.setPoints(10);
chart@(Model.Widget.Id).getToolTips().setEnabled(true);
chart@(Model.Widget.Id).getToolTips().setAlignment("near");
chart@(Model.Widget.Id).getToolTips().setFormat("%l%");
//chart@(Model.Widget.Id).getAllSeries().getPointLabels().setVisible(true);
//chart@(Model.Widget.Id).getAllSeries().getPointLabels().setAlignment(cfx.StringAlignment.NEAR);
chart@(Model.Widget.Id).getLegendBox().setVisible(false);
chart@(Model.Widget.Id).getLegendBox().setWidth(175);
chart@(Model.Widget.Id).getLegendBox().setDock(cfx.DockArea.Right);
chart@(Model.Widget.Id).getLegendBox().setContentLayout(cfx.ContentLayout.Near);
chart@(Model.Widget.Id).getPlotAreaMargin().setTop(0);
chart@(Model.Widget.Id).getPlotAreaMargin().setBottom(0);
chart@(Model.Widget.Id).getPlotAreaMargin().setRight(0);
chart@(Model.Widget.Id).getPlotAreaMargin().setLeft(0);
var divHolder = document.getElementById('ChartDiv');
chart@(Model.Widget.Id).create(divHolder);
}
$(function() {
LoadPieChart();
});
//$(window).resize(function() {
function ResizeChart()
{
if (chart@(Model.Widget.Id) != null)
chart@(Model.Widget.Id).doUpdate(true);
};
</script>
Link to comment
Share on other sites
18 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.