add an image map to generated image

P

phoenix.cbe

Hello all,
I would like to add a dynamic image map to an image that I create
using OWC11. For example I have created a pie chart and I want to add a
hyperlink to the various sections of the chart. Has anyone done that?

This is what I have done
on the .aspx page i have defined the image(imgDataChart) and on the
..aspx.cs this is the code

OWC11.ChartSpaceClass oChartSpace = new OWC11.ChartSpaceClass ();
OWC11.ChartChartTypeEnum chartType;
chartType = ChartChartTypeEnum.chChartTypePie;

oChartSpace.HasChartSpaceLegend = true;
oChartSpace.ChartSpaceLegend.Position =
ChartLegendPositionEnum.chLegendPositionBottom;

oChartSpace.Border.Color = "white";
oChartSpace.Charts.Add(0);
oChartSpace.Charts[0].HasTitle = true;
oChartSpace.Charts[0].Type = chartType;
oChartSpace.Charts[0].ChartDepth = 125;
oChartSpace.Charts[0].AspectRatio = 80;
oChartSpace.Charts[0].Title.Caption = "Number of Cases";
oChartSpace.Charts[0].Title.Font.Bold = true;

oChartSpace.Charts[0].SeriesCollection.Add(0);
oChartSpace.Charts[0].SeriesCollection[0].DataLabelsCollection.Add ();

oChartSpace.Charts[0].SeriesCollection[0].DataLabelsCollection[0].HasPercentage
= true;
oChartSpace.Charts[0].SeriesCollection[0].DataLabelsCollection[0].HasValue
= false;


//
------------------------------------------------------------------------
// Pick your favorite image format
//
------------------------------------------------------------------------
byte[] byteArr = (byte[]) oChartSpace.GetPicture ("gif", 400, 400);

//
------------------------------------------------------------------------
// Store the chart image in Session to be picked up by an HttpHandler
later
//
------------------------------------------------------------------------
HttpContext ctx = HttpContext.Current;
string chartID = Guid.NewGuid ().ToString ();

ctx.Session [chartID] = byteArr;
imgDataChart.ImageUrl = string.Concat ("chart.ashx?", chartID);

GetPicture returns a byte array and can we identify the regions for
this image and make an imagemap out of this.

Thanks
Raj
 
A

Alvin Bruney [MVP]

That approach may not work for you because once the chart is sent to the
client, it is not available on the server. You may have to stream javascript
out to impose a link on the chart surface. That part is easy, use custom
events to do that. The hard part is determining what area you want to hyper
link to from the codebehind before you stream the script out. very doable,
requires some thought and planning.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


Hello all,
I would like to add a dynamic image map to an image that I create
using OWC11. For example I have created a pie chart and I want to add a
hyperlink to the various sections of the chart. Has anyone done that?

This is what I have done
on the .aspx page i have defined the image(imgDataChart) and on the
.aspx.cs this is the code

OWC11.ChartSpaceClass oChartSpace = new OWC11.ChartSpaceClass ();
OWC11.ChartChartTypeEnum chartType;
chartType = ChartChartTypeEnum.chChartTypePie;

oChartSpace.HasChartSpaceLegend = true;
oChartSpace.ChartSpaceLegend.Position =
ChartLegendPositionEnum.chLegendPositionBottom;

oChartSpace.Border.Color = "white";
oChartSpace.Charts.Add(0);
oChartSpace.Charts[0].HasTitle = true;
oChartSpace.Charts[0].Type = chartType;
oChartSpace.Charts[0].ChartDepth = 125;
oChartSpace.Charts[0].AspectRatio = 80;
oChartSpace.Charts[0].Title.Caption = "Number of Cases";
oChartSpace.Charts[0].Title.Font.Bold = true;

oChartSpace.Charts[0].SeriesCollection.Add(0);
oChartSpace.Charts[0].SeriesCollection[0].DataLabelsCollection.Add ();

oChartSpace.Charts[0].SeriesCollection[0].DataLabelsCollection[0].HasPercentage
= true;
oChartSpace.Charts[0].SeriesCollection[0].DataLabelsCollection[0].HasValue
= false;


//
------------------------------------------------------------------------
// Pick your favorite image format
//
------------------------------------------------------------------------
byte[] byteArr = (byte[]) oChartSpace.GetPicture ("gif", 400, 400);

//
------------------------------------------------------------------------
// Store the chart image in Session to be picked up by an HttpHandler
later
//
------------------------------------------------------------------------
HttpContext ctx = HttpContext.Current;
string chartID = Guid.NewGuid ().ToString ();

ctx.Session [chartID] = byteArr;
imgDataChart.ImageUrl = string.Concat ("chart.ashx?", chartID);

GetPicture returns a byte array and can we identify the regions for
this image and make an imagemap out of this.

Thanks
Raj
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top