Page 1 of 1
Setting margins ....
Posted: Sat Jan 07, 2012 1:51 pm
by 13051266
Hi all,
I am trying to adjust the size of margins of a webchart with several different series in it, in order to create space for some other stuff, like footers and the like. I want the footer to be proportional to the chart, and have arranged for a resizing of the chart, by means of a javascript, upon a body.onresize. I have put code along the following lines in the _BeforeDraw event handler, but nothing happens.
g.Chart.Footer.Font.Size:=Convert.ToInt32(OrigChartHeight/70);
g.Chart.Panel.MarginUnits:=PanelMarginUnits.Pixels;
g.Chart.Panel.MarginBottom:=10*g.Chart.Footer.Font.Size;
In the same routine I resize fonts for labels and Heading, which works perfectly well. The margin adjustment doesn'tcreate a thing , however.
Any good ideas, anyone ?
Re: Setting margins ....
Posted: Mon Jan 09, 2012 4:12 pm
by 10050769
Hello Janne,
I recommend use Bitmap method to repaint the Chart as do in next lines of code:
Code: Select all
Steema.TeeChart.Styles.Line line1;
int OrigChartHeight;
private void InitializeChart()
{
WebChart1.Chart.Aspect.View3D = false;
line1 = new Steema.TeeChart.Styles.Line(WebChart1.Chart);
line1.FillSampleValues();
WebChart1.Chart.Chart.Footer.Visible = true;
WebChart1.Chart.Footer.Text = "TeeChart1";
OrigChartHeight = WebChart1.Chart.Height;
WebChart1.BeforeDraw += new PaintChartEventHandler(WebChart1_BeforeDraw);
System.Drawing.Bitmap bitmpa1 = WebChart1.Chart.Bitmap();
}
void WebChart1_BeforeDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
g.Chart.Footer.Font.Size = Convert.ToInt32(OrigChartHeight / 70);
g.Chart.Panel.MarginUnits = PanelMarginUnits.Pixels;
g.Chart.Panel.MarginBottom = 10 * g.Chart.Footer.Font.Size;
}
Previous code works fine for me using last version of TeeChartFor.Net. Can you tell us, if code works as you want?
I hope will helps.
Thanks,
Re: Setting margins ....
Posted: Tue Jan 10, 2012 3:36 pm
by 13051266
Hi Sandra,
I'm not sure I completely get it. I'm using Prism as a code - not that it's terribly different but anyway. In any case I want to keep the chart interactive, with hotspots and zoom alive, so pictureformat should not be a bitmap, if that's what this implies. What I've done is the following: (please could you direct me to specifically what I'm doing wrong)
I've set the TempChart = httpHandler (designtime) (the web.config updated accordingly);
GetChartFile is automatically set by the IDE as GetChart.aspx, and I haven't changed that.;
Pictureformat designtime is PNG, I'm not sure that is of significance at all,
finally, I use code as follows
method GanttChart.populate(various parameters);
begin
-
various code adding data to the series
and adding the series to the chart
-
end
method GanttChart.wcGantt_BeforeDraw(sender: System.Object;
g: Steema.TeeChart.Drawing.Graphics3D);
begin
...some code...
g.Chart.Footer.Font.Size:=Convert.ToInt32(OrigChartHeight/70);
g.Chart.Panel.MarginUnits:=PanelMarginUnits.Pixels;
g.Chart.Panel.MarginBottom:=2*g.Chart.Footer.Font.Size;
g.Chart.Footer.CustomPosition:=True;
g.Chart.Footer.Font.Color:=Color.Black;
g.Chart.Footer.Left:=0;
g.Chart.Footer.Top:=g.Chart.Height-g.Chart.Footer.Font.Size;
g.Chart.Footer.Visible:=True;
g.Chart.Footer.Text:='Some text';
...some code
end;
Since we're now touching upon it, I have a problem whith displaying the chart as a plain graphic as well, effected by code. I suppose I need to change the PictureFormat setting, but I can't make it work now. That, however, will be my next question, after having had this one sorted out. Thanks for your help.
cheers for now,
Re: Setting margins ....
Posted: Thu Jan 12, 2012 8:58 am
by 10050769
Hello Janne,
Could you send us your project, because we can reproduce exactly your problem here and try to suggest you a good solution?
Thanks,
Re: Setting margins ....
Posted: Fri Jan 13, 2012 4:08 pm
by 13051266
Well, not easily. Its driven by an SQL database, so in order not to have to connect you remotely I'd have to rewrite it a fair deal and end up with essentially the above.. (add the fillsamplevalues trick and you will essentially have it).
I realize however that I am focusing on the wrong problem. The footer issue is not important really, I can put a label underneath the chart, that works fine.
I am more puzzled with the fact that it doesn't behave on the screen as an img (there are no copy etc options like Windows normally provide upon rightclick).
I hope you can bear with me here, since I'm really very new to this art, allthough I cant stay away from pretty complex tasks, as usual.
I have discovered however, that if I remove the webchart1_ClickSeries( .. args ..) eventhandler from the code, then, all of a sudden, it behaves like an image.
Problem is that I want to have that interaction intact, I use it for exploding and collapsing tasks in the Gantt chart by clicking the gantt bars.
I suspect that the bitmap routine you demonstrate above could potentially solve this. Rather than record the chart right-click-and-copy-style, one might hope that your bitmap trick could lead to some means of downloading that bitmap file.
So, supposing I did this (this is Prism now, sorry):
webChart1.PictureFormat:=PictureFormats.JPEG;
var ChartImg : BitMap := new Bitmap(webchart1.Chart.Width,webchart1.Chart.Height);
ChartImg:=webchart1.Chart.Bitmap();
Then, if I understand this correctly, I have the chart hidden away as a jpeg imagefile in the variable ChartImg, right? How would you offer that to the user, i.e. how could the user get access to it?
Thanks for your help.
Re: Setting margins ....
Posted: Mon Jan 16, 2012 1:26 pm
by 13051266
Hi again, Sandra
After some fiddling, I found out that this is a way:
webChart1.PictureFormat:=PictureFormats.JPEG;
var ChartImg1 : BitMap := new Bitmap(webChart1.Chart.Width,webChart1.Chart.Height);
ChartImg1:=webChart1.Chart.Bitmap();
var ChartImg2 : BitMap := new Bitmap(ChartImg1);
Response.ContentType := "image/jpeg";
ChartImg2.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
ChartImg1.Dispose();
ChartImg2.Dispose();
Response.End();
This is based on some hints picked up elsewhere on the web, and it works. It will yield a normal jpeg, which can be rightclicked and so on. It feels rather awkward and unnecessary to do that extra copy to ChartImg2, but whatever works...
Is this a route you would support?
cheers,
Re: Setting margins ....
Posted: Tue Jan 17, 2012 7:00 pm
by 13051266
By the way, I don't need the extra copy. I don't know why that was suggested in the first place. It works anyway.
And as for the footer problem above: I finally took your point Sandra. Copying to a new bitmap obviously repaints the chart. So - that too works.
Thanks, Sandra.
I might learn this in due time...
Re: Setting margins ....
Posted: Wed Jan 18, 2012 8:52 am
by 10050769
Hello Janne,
Sorry for the delay. I am glad that you find a solution for your problem
.
Thanks,