Category Archives: ImageMap

ImageMap

[RESOLVED]Is there a reliable way to get the X, Y position of a click on a image relative to the image?

I’ve seen a number of examples but nothing that seems reliable enough…

What I want to do is have a pie chart broken out into say 8 slices. I need to know if someone clicks on one of the slices. Since the slices are more triangular, it makes it a little more difficult.

I was thinking maybe I can use area but I’m not sure since I haven’t done this before.

Another idea was to make each of these an image button but again that leaves a lot of blank space that can be clicked on as well due to the shape.

I welcome any ideas.

Thanks,

Joe

This should be possible using jQuery / Javascript. 

According to
this StackOverflow thread
, you should be able to use the following
(or similar):

$("img").click(function(event) {
    var elOffsetX = $(this).offset().left,
        elOffsetY = $(this).offset().top,
        clickOffsetX = event.pageX - elOffsetX,
        clickOffsetY = event.pageY - elOffsetY;
    
    //Alerts the coordinates
    alert("X : " + clickOffsetX ", Y:" + clickOffsetY);
});

Working Example

ImageMap actually would be probably the best for this particular purpose since your chart has a triangular shape.

Check out this example:http://asp-net-example.blogspot.com/2008/10/imagemap-control-example.html

Then again, JQuery example shown previously is a great choice too :)

I would not draw the image in the server and then use <img>

I would rather use a client side rendering approach, such as jqPlot , which offers real interactivity

http://www.jqplot.com/tests/pie-donut-charts.php

[RESOLVED]how to create interactive map using javascript and Css

I have world map image in my website http://apolloexim.com/index.htm. with two branches. Currently this is only an image. I want to add one more location and make it interactive like this http://www.imapbuilder.com/map-templates/

How can I do this using java script? Pls provide sample code if possible.

Is there any other way to do this?

Thanks in advance.

To select the country in map, you can take a look at http://www.javascriptkit.com/howto/imagemap.shtml.

We can use <map> and <area> to define the polygon (country). You can also try to add some javascript in <area> to add the effect. (I think it should work using javascript inside area tag.)

Thanks for your reply.

Can you pls provide any sample code for this?

<html>
<body>
    <map name="FPMap0">
    <area href="http://www.lycos.com" shape="rect" coords="6, 120, 63, 137" onmouseover="alert('Mouseover Event')">
    <area href="http://www.nba.com" shape="rect" coords="5, 96, 65, 113" onclick="alert('Onclick Event')">
    <area href="http://www.yahoo.com" shape="rect" coords="6, 75, 66, 87">
    <area href="http://www.cnn.com" shape="rect" coords="8, 48, 61, 62">
    <area href="http://javascriptkit.com" shape="rect" coords="8, 24, 65, 38">
    </map>
<img rectangle=" (6,75) (66, 87)  http://www.yahoo.com" rectangle=" (8,48) (61, 62)  http://www.cnn.com" rectangle=" (8,24) (65, 38)  http://javascriptkit.com" src="http://www.javascriptkit.com/nav1.jpg" width="70" height="167" border="0" usemap="#FPMap0"></p>

</body>
</html>

In this sample, (referred link:
http://www.javascriptkit.com/howto/imagemap.shtml
), if you click "NBA" or move to "Lycos", message will be prompted.

Or this may be simpler:

<html>
<body>
    <img src="http://www.javascriptkit.com/nav1.jpg" width="70" height="167" border="0" usemap="#FPMap0">
    <map name="FPMap0">
        <area href="http://www.lycos.com" shape="rect" coords="6, 120, 63, 137" onmouseover="alert('Mouseover Event')">
        <area href="http://www.nba.com" shape="rect" coords="5, 96, 65, 113" onclick="alert('Onclick Event')">
        <area href="http://www.yahoo.com" shape="rect" coords="6, 75, 66, 87">
        <area href="http://www.cnn.com" shape="rect" coords="8, 48, 61, 62">
        <area href="http://javascriptkit.com" shape="rect" coords="8, 24, 65, 38">
    </map>

</body>
</html>

[RESOLVED]version

I have XP pro with VS2005 v 8.0.50727 with .net2.0sp2 , .net3.0sp2 and .net3.5sp1

How can I find out what version of ASP.NET I am using 1.0 , 2.0 , 3.0 , 3.5

 

In the VStoolbox and intellisense there are only 3 image related controls.

ButtonImage , Image and ImageMap

I have been reading  about DynamicImage and ImageGenerator

How can I get these controls/classes working?

What is the best way to approach dynamic images in asp.net?

PeterRod

 From what I remember DynamicImage and ImageGenerator were cut out of ASP.NET 2.0 so they were only available for v1.x

Saying that there is something about a ASP.NET Generated Image component on CodePlex,
not sure what it does mind you.

whighfield

 From what I remember DynamicImage and ImageGenerator were cut out of ASP.NET 2.0 so they were only available for v1.x

Saying that there is something about a ASP.NET Generated Image component on CodePlex,
not sure what it does mind you.

 

William, thanks for the assistance. I checked out the link.

I am still troubled by how do I find out for certain what version number of ASP.NET I am using?

In vs2005 its easy to know but I dont know how to do it in ASP.NET?

Also, whats a good place to start as far as building dynamic images in asp.net?

Thanks

 

For the verson number

http://digitalcolony.com/2007/06/detect-aspnet-version-running-on-server.aspx 

As for building dynamic images in asp.net I am not sure what you mean or want, you can always try searching Google.

Thanks on version number.

 

Image Questio:

As you can tell I am very new to asp.net  I have done some programming in Windows Forms VB language and MASM32. Actually I have written 3-4 quite large apps.

I recently built a website using html and php scripts. That site is up. 

Then I figured why not try building a site in asp.net as I already have vs2005.

One of the features I would like on the asp site is to be able to display  6 .jpg images each one for about 20 secs without any client interaction and to have the display continue repeating the images. Do I use AdRotator or some code in the pageLoad event
handler or what about UpdatePanel in the Ajax Extensions?

I just wanted to get some advice on the best approach.

Thanks

  

 

There are probably Flash or Silverlight based slide shows for images as well there are a few JavaScript based slide shows out there.  I would not bother building something like that myself.

[RESOLVED]ASP.NET Chart Control ImageMap not displaying

I have a page with several asp images set to the address of the binarystreaming chart, but they all show the "red X" instead of the chart image. If I right-click on the red X images and choose properties and copy the address into a browser window the chart
image (built from an aspx imagemap page) displays. I am combining a binarystreaming and imagemap chart to allow for tooltips to display to the end-user. Here is the html for the image: <asp:image id="imgLOC_04&" runat="server" width="500px" height="300px"></asp:image>
The url is set at run-time: imgName.ImageUrl = "~/WebCharts/PieChart.aspx?LOC=" & objDR.Item("LOC") & "&LINE=" & objDR.Item("LINE") & "MODEL=" & ddlMonth.SelectedItem.Value On the PieChart.aspx page I have a chart control with a rendertype set to "ImageMap".
The ImageLocation is set at run-time: chtLINE.ImageLocation = "~/WebCharts/PieChartIM.aspx?LOC=" & sLOC & "&LINE=" & sLINE & "&MODEL=" & sMODEL On the PieChartIM.aspx page I have a chart control with a RenderType set to "BinaryStreaming". I’ve tried to implement
the solution suggested by MS: http://msdn.microsoft.com/en-us/library/vstudio/dd456682(v=vs.100).aspx But, I must be missing something. Can someone help me with what I may be missing?

hi  bmd174s,

From what I understand you want to show the chart image instead of red X in
Chart
Control.

I think that  the settings in Web.config for the HTTP Handler are ignored. Regardless of your settings, the Microsoft Chart Controls stores the chart images in memory. You can circumvent this behavior by adding the following to the ChartImageHandler configuration
string:

< configuration>

   ...

   <appSettings>

      <add key="ChartImageHandler" value="storage=file;dir=C:ChartImages;WebDevServerUseConfigSettings=true;"/>

   </appSettings>

   ...

< /configuration>

I would suggest that you read this reference below:

http://forums.asp.net/t/1643271.aspx/1

http://www.4guysfromrolla.com/articles/081909-1.aspx

      If you need more assistance ,please let me know.

[RESOLVED]Rotating ASP Label

Hi there, first time posting on this forum so this seemed like the best spot for this question.

I have a label that is essentially an auto-filler for a service number for an invoice. The service number is automatically generated and put in this label. The label is mapped over an image right now and that image is in a table. I need to roate the label
90 degrees and have had no success after looking into various techniques. As well, if there’s a better way to put a label over an image then I am open to suggestions. I don’t have much experience with using ASP and this is my current solution to putting a
label over an image. Any help would be greatly appreciated

<table align="left" border="0" width="200">
            <td align ="left" class="style2" width = "0">
                    <asp:Label ID="lblCaseIDVert" runat="server"
                    style="z-index: 100; left: 33px; position: relative; top: 98px"
                    Font-Names="StoneSansStd-Semibold" Font-Size="100px" ForeColor="#8dc63f" Height="1px"
                    Width="192px"></asp:Label>
                    
                    <asp:ImageMap ID="ImageMap1" runat="server" Height="100%" ImageUrl="../images/customeragreement/CaseID.jpg"
                    Style="z-index: 99; left: 0px; position: relative; top: 10px" Width="101.5%" HotSpotMode="PostBack">
                    
                    </asp:ImageMap>
            </td>
        </table>

Try following:

1. Make Position: absolute in style of both label and image.

2. Set  Label z-index higher than Image

3. Set top and left styles of both as per your requirement

Hello,

Try by setting the following CSS class to your label

<style>
.test
{
-moz-transform: rotate(90deg); /* FF3.5+ */
-o-transform: rotate(90deg); /* Opera 10.5 */
-webkit-transform: rotate(90deg); /* Saf3.1+, Chrome */
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=90); /* IE6,IE7 */
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=90)"; /* IE8 */
-sand-transform: rotate(90deg);
}
</style>
<asp:Label ID="lblCaseIDVert" runat="server"
                    style="z-index: 100; left: 33px; position: relative; top: 98px"
                    Font-Names="StoneSansStd-Semibold" Font-Size="100px" ForeColor="#8dc63f" Height="1px"
                    Width="192px" CssClass="test"></asp:Label>

My hero! This worked perfectly. Thanks so much.

[RESOLVED]Design a image map

Hello All

Actually I am not a developer, i just saw this webiste http://www.boconcept.as/inspiration.aspx?ID=71977 and i want to do similar image where somethings pop ups when i move the mouse over an object

is it possible?I tried google i found a software called imapbuilder and it is kind of expensive. I am an engineer and i can code that!

thank you

Hello,

therealabdo

Actually I am not a developer, i just saw this webiste http://www.boconcept.as/inspiration.aspx?ID=71977 and i want to do similar image where somethings pop ups when i move the mouse over an object

Yes this is totally possible and very simple. They have positioned divs on the image. Nothing more than that. :) You can achieve the same by setting the
position:absoulte for the ‘hotspot’ divs and by setting margin to position them. Check the sample app I’ve created for you

<html>
<head>
<style type="text/css">
#mainImage
{
    background-image: url('Untitled.jpg');
    width:100px;
    height:100px;
    float:left;
}
</style>
    <title></title>
</head>
<body>
 <form id="form1">
  <div id="mainImage">
  </div>
  <div style="position:absolute; margin-left:10px; margin-top:10px">
    Hotspot
  </div>
 </form>
</body>
</html>

Thank you for your reply

This div stays on the page I couldn’t make it to pop up

I was trying (since I am not an HTML developer) on dreamweaver and here is what i have done

- added the main image (the room)

-added image map areas on the image

-added an image which contains the description

-to each one of the image map areas i have added a ‘show-hide element’ behavior to description image

- test it

accomplished

But it needs too much load of work and it is not flexible :(

Hi,

therealabdo

- added the main image (the room)

-added image map areas on the image

-added an image which contains the description

-to each one of the image map areas i have added a ‘show-hide element’ behavior to description image

- test it

Other than this procedure, I really don’t know any easier way to accomplish this. Since you have to define the position of hotspots manually, this can’t be automated. 

therealabdo

But it needs too much load of work and it is not flexible :(

I’m sorry. May be, you will be interested on below addon. But it’s a commercial product.

http://www.topdreamweaverextensions.com/hotspot-image-highlight

I will do it manually then :D

I found a software called  iMapbuilder, it is very expensive!! and the trial version is too commercial

Thank you :)

[RESOLVED]ImageMapster plugin is not working when I am rendering image , map and area tag through jquery

Hai,

<div>       I am trying to use ImageMapster plugin for my application. It works fine when using static imagemap in html. But my problem is that, when am rendering image and area tag through jquery, it is not working.</div> <div></div> <div>Here is my code </div>
<div>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Select Image</title>
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
	<script type="text/javascript" src="../src/jquery.imagemapster.js"></script>
	<script>
		$(document).ready(function(){
				
		     var iiim="";
				var url = 'http://xxxxx.azurewebsites.net/api/HomeApiImage';
				$.get(url, function(data) {
					iiim=data["BgImg"];
					var url = 'http://xxxxx.azurewebsites.net/api/HomeApi';
					$.get(url, function(data) {
						
						
						$('#map_demo').prepend('<img  src="'+iiim+'" usemap="#usa" id="myimage" style="margin-top:43px;"/>')
						for(var i=0;i<data.length;i++)
						{
							
							$('#usa_image_map').append('<area href="#" coords="'+data[i].Node_Location+'" state="n'+i+'" shape="rect" title="'+data[i].Node_Title+'" />')
						

						}
					}, "jsonp");
					 
				}, "jsonp");
		
		
		 $('#myimage').mapster({
		    	   
        fillColor: 'ff0000',
        fillOpacity: 0.3
    });
	  });
	</script>
</head>
<body>
	<div id="map_demo">
	</div>
<map id="usa_image_map" name="usa">
    </map>
	
	
</body>
</html>

</div> <div></div> <div>Please help me,</div> <div>Thanks.</div> <div></div>

Hello

After jQuery retrieves the data remotely, you’ll consider to build a DOM, something like

var $a = $(‘<area … />’);

$(‘#usa_image_map’).append($a);

See if it works.

Delegate for dynamic chart control not triggering

Hi,

The chart control is not loaded properly in toolbox in VS 2010.So i had created dynamic chart.

I had create a dynamic chart in VS 2010 as seen in the code below.

protected void DeviceChartChange(object sender, ImageMapEventArgs args)
        {
            int sliceindex = int.Parse(args.PostBackValue);
        }



in button click i load the chart
Chart chrt = new Chart();
                chrt.Visible = true;
                chrt.Click += DeviceChartChange;

But the delegate event is not firing ie Chart click On click of this chart another chart will load. The DeviceChartChange event is not firing.

need help

Regards

Guhananth.S

 

 

Hi guhan,

Please try to refer to the following code:

Chart1.Series["SeriesName"].PostBackValue = "Value";
chrt.Click += new ImageMapEventHandler(DeviceChartChange);

protected void Chart1_Click(object sender, ImageMapEventArgs e)

 {
     //process your business..
 }

If your problem still exists, please let me know.

Best Regards,
Terry Guo

Will this click event work in Share point 2007 visual web part? The click event is not firing?

Using VS 2010 charts. Dependent chart how to implement

Hi,

I have a bar or a pie chart. On click of bar or pie region the next chart say Bar chart should load . How to implement it?

Please provide url or examples.

protected void BuildLineChart()
        {
            try
            {
                Chart chrt = new Chart();
                chrt.Visible = true;

                chrt.Series.Add("consumption");
                chrt.Legends.Add("TestLegend");
                DataTable dt = new DataTable();
                if (ddlSite.SelectedItem.Text.Trim() == "ABAN-I")
                {
                    DateTime frmDate = DateTime.Parse(txtDate.Text.Trim());

                    String strfrmDate = frmDate.ToString("dd/MM/YYYY");

                    DateTime tDate = DateTime.Parse(toDate.Text.Trim());
                    String strtoDate = tDate.ToString("dd/MM/YYYY");
                    if (strfrmDate.Trim() == strtoDate.Trim())
                    {
                        //query = string.Format("select c_department, siteid,CAST(SUM(linecost) as decimal (8,1))As Consumption from matusetrans , item where item.itemnum=matusetrans.itemnum and item.capitalized=0 and matusetrans.storeloc not like ('%VRPRJ%') and matusetrans.transdate='" + txtDate.Text.Trim() + "'and matusetrans.transdate='" + toDate.Text.Trim() + "' and matusetrans.siteid='" + ddlSite.SelectedItem.Text.Trim() + "' group by matusetrans.c_department, matusetrans.siteid, matusetrans.storeloc  order by matusetrans.siteid, matusetrans.storeloc, matusetrans.c_department ");
                        query = string.Format("select c_department,siteid,CAST(SUM(linecost) as decimal (18,1)) As Consumption from matusetrans,item where item.itemnum=matusetrans.itemnum and item.capitalized=0 and matusetrans.storeloc not like ('%VRPRJ%') and matusetrans.transdate='" + txtDate.Text.Trim() + "' and matusetrans.siteid='" + ddlSite.SelectedItem.Text.Trim() + "' group by matusetrans.c_department, matusetrans.siteid, matusetrans.storeloc  order by matusetrans.siteid, matusetrans.storeloc, matusetrans.c_department");
                    }
                    else
                    {
                        query = string.Format("select c_department,siteid,CAST(SUM(linecost) as decimal (18,1)) As Consumption from matusetrans,item where item.itemnum=matusetrans.itemnum and item.capitalized=0 and matusetrans.storeloc not like ('%VRPRJ%') and matusetrans.transdate>='" + txtDate.Text.Trim() + "' and matusetrans.transdate<='" + toDate.Text.Trim() + "' and matusetrans.siteid='" + ddlSite.SelectedItem.Text.Trim() + "' group by matusetrans.c_department, matusetrans.siteid, matusetrans.storeloc  order by matusetrans.siteid, matusetrans.storeloc, matusetrans.c_department");
                    }
                    // chrt.DataSource = sqlObj.GetTable(query);
                    dt = sqlObj.GetTable(query);
                    if (dt.Rows.Count > 0)
                    {
                        lblMessage.Text = "Maximo" + " " + ddlSite.SelectedItem.Text.Trim() + " " + "from" + " " + txtDate.Text.Trim() + " " + "to" + " " + toDate.Text.Trim();
                        lblMessage.Visible = true;
                        chrt.DataSource = sqlObj.GetTable(query);

                        chrt.Series["consumption"].XValueMember = "c_department";
                        chrt.Series["consumption"].YValueMembers = "Consumption";


                        chrt.Legends["TestLegend"].Enabled = true;
                        chrt.Legends["TestLegend"].Alignment = StringAlignment.Far;
                        chrt.Legends["TestLegend"].Docking = Docking.Bottom;
                        chrt.ChartAreas.Add("TestArea");


                        chrt.Series["consumption"].ChartArea = "TestArea";
                        chrt.ChartAreas["TestArea"].Area3DStyle.Enable3D = true;


                        chrt.ChartAreas["TestArea"].AxisY.TitleAlignment = StringAlignment.Center;
                        chrt.ChartAreas["TestArea"].AxisX.LabelStyle.Angle = -90;
                        chrt.ChartAreas["TestArea"].AxisY.LabelStyle.Font = new Font("Arial", 9, GraphicsUnit.Pixel);
                        chrt.ChartAreas["TestArea"].AxisX.LabelStyle.ForeColor = Color.Red;
                        chrt.ChartAreas["TestArea"].AxisY.LabelStyle.ForeColor = Color.DarkBlue;

                        chrt.ChartAreas["TestArea"].AxisX.TitleAlignment = StringAlignment.Near;
                        chrt.ChartAreas["TestArea"].AxisX.TextOrientation = TextOrientation.Horizontal;
                        chrt.Series["consumption"].Color = System.Drawing.Color.MediumSeaGreen;
                        //chrt.Series["consumption"].BorderColor = System.Drawing.Color.Yellow;
                        chrt.Series["consumption"].MarkerColor = System.Drawing.Color.Firebrick;

                        chrt.Series["consumption"].IsValueShownAsLabel = true;

                        chrt.Series["consumption"].ChartType = SeriesChartType.Pie;


                        chrt.ChartAreas["TestArea"].AxisX.Title = "Department";
                        chrt.ChartAreas["TestArea"].AxisY.Title = "Consumption ins Rs";

                        chrt.DataBind();

                        this.Controls.Add(chrt);
                        //chrt.Controdd(pnlScattered);
                        chrt.Series["consumption"].ToolTip = "Device= #VALXnConsumption= Rs#VALY";
                    }
                    else
                    {

                        lblValidate.Visible = true;
                        lblValidate.Text = "No Records Are Found";
                    }
                }

            }


            catch (Exception Ex)
            {
                lblGreen.Visible = true;
                lblValidate.Visible = true;
                lblValidate.Text = Ex.Message;
                lblGreen.Text = "";

            }
        }

Here i have pie chart.On click of 1 region in Pie chart i should create another Bar or pie chart.

 

 

Hi,

Please refer the below link

Hi guhan,

From my understanding, is that you would like to add click event to chart.

If so, please try to refer to the following code:

Chart1.Legends[0].CustomItems[0].Cells[0].Image = "./cleared.png";
Chart1.Legends[0].CustomItems[0].Cells[0].PostBackValue = "item 1";

this.Chart1.Click += new ImageMapEventHandler(this.Chart1_Click);


private void Chart1_Click(object sender, System.Web.UI.WebControls.ImageMapEventArgs e)
{
   if (e.PostBackValue == "item 1")
   {
      LegendCell cell = Chart1.Legends[0].CustomItems[0].Cells[0];
      cell.Image = (cell.Image == "./cleared.png") ? "./selected.png" : "./cleared.png";
   }

You can also refer to the link below:
http://forums.asp.net/t/1906374.aspx?Does+Chart+Properties+have+any+OnClick+events+in+MSChart+.

Hope it can help you.

Best Regards,
Terry Guo

Will this click event working in Share point 2007 visual web part? The click event is not firing?

Will this click event working in Share point 2007 visual web part? The click event is not firing?

Will this click event work in Share point 2007 visual web part? The click event is not firing?

MS Chart Click event is not working…….

Hi,

I had created a dynamic chart control in VS 2010. On click of 1 chart (Piechart)other chart should load.

Here chart is the 1st chart shown.But on click of this chart event is not firing.

 

So I have

{
            base.OnPreRender(e);
            Chart chrt = new Chart();
            chrt.Click += new ImageMapEventHandler(chrt_click);

          
        }


protected void chrt_click(object sender, ImageMapEventArgs args)
        {
            int sliceindex = int.Parse(args.PostBackValue);
        }

protected void btnViewChart_Click(object sender, EventArgs e)
        {
   BuildPieChart(words);
               }

  protected void BuildPieChart(string[] strRig)
        {
            try
            {
                Chart chrt = new Chart();
                chrt.Visible = true;
                //chrt.Click += new ImageMapEventHandler(chrt_click);
                //chk.CheckedChanged += txtChanged;
                chrt.Series.Add("consumption");
                chrt.Legends.Add("TestLegend");
                 str="";
                foreach (string value in strRig)
                {
                    str += value + ",";
                }

                strRigString = str.Remove(str.Length-1);
                 strRemove = strRigString.Remove(strRigString.Length - 1, 1);
                 strRigToPass = strRemove = strRemove.Remove(0, 1);
               // Response.Write(str);
                DataTable dt = new DataTable();
           
                    DateTime frmDate = DateTime.Parse(txtDate.Text.Trim());

                    String strfrmDate = frmDate.ToString("dd/MM/YYYY");

                    DateTime tDate = DateTime.Parse(toDate.Text.Trim());
                    String strtoDate = tDate.ToString("dd/MM/YYYY");
                      
                    if (strfrmDate.Trim() == strtoDate.Trim())
                    {
                        //query = string.Format("select c_department, siteid,CAST(SUM(linecost) as decimal (8,1))As Consumption from matusetrans , item where item.itemnum=matusetrans.itemnum and item.capitalized=0 and matusetrans.storeloc not like ('%VRPRJ%') and matusetrans.transdate='" + txtDate.Text.Trim() + "'and matusetrans.transdate='" + toDate.Text.Trim() + "' and matusetrans.siteid='" + ddlSite.SelectedItem.Text.Trim() + "' group by matusetrans.c_department, matusetrans.siteid, matusetrans.storeloc  order by matusetrans.siteid, matusetrans.storeloc, matusetrans.c_department ");
                        //query = string.Format("select c_department,siteid,CAST(SUM(linecost) as decimal (18,1)) As Consumption from matusetrans,item where item.itemnum=matusetrans.itemnum and item.capitalized=0 and matusetrans.storeloc not like ('%VRPRJ%') and matusetrans.transdate='" + txtDate.Text.Trim() + "' group by matusetrans.c_department, matusetrans.siteid, matusetrans.storeloc  order by matusetrans.siteid, matusetrans.storeloc, matusetrans.c_department");
                        //Commented on Sept 25th 2013.
                       // query = string.Format("select siteid,CAST(SUM(linecost) as decimal (18,1)) As Consumption from matusetrans,item where item.itemnum=matusetrans.itemnum and item.capitalized=0 and matusetrans.storeloc not like ('%VRPRJ%') and matusetrans.transdate='" + txtDate.Text.Trim() + "' group by matusetrans.c_department, matusetrans.siteid, matusetrans.storeloc  order by matusetrans.siteid, matusetrans.storeloc, matusetrans.c_department");
                        query = string.Format("select siteid,CAST(SUM(linecost) as decimal (18,1)) As Consumption, matusetrans.currencycode from matusetrans , item where item.itemnum=matusetrans.itemnum and matusetrans.siteid IN ('" + strRigToPass.Trim() + "') and item.capitalized=0 and matusetrans.storeloc not like ('%VRPRJ%') and matusetrans.transdate='" + txtDate.Text.Trim() + "' group by  matusetrans.siteid, matusetrans.currencycode");

                    }
                    else
                    {
                        //query = string.Format("select c_department,siteid,CAST(SUM(linecost) as decimal (18,1)) As Consumption from matusetrans,item where item.itemnum=matusetrans.itemnum and item.capitalized=0 and matusetrans.storeloc not like ('%VRPRJ%') and matusetrans.transdate>='" + txtDate.Text.Trim() + "' and matusetrans.transdate<='" + toDate.Text.Trim() + "' group by matusetrans.c_department, matusetrans.siteid, matusetrans.storeloc  order by matusetrans.siteid, matusetrans.storeloc, matusetrans.c_department");
                        //Commented on Sept 25th 2013.
                       // query = string.Format("select siteid,CAST(SUM(linecost) as decimal (18,1)) As Consumption from matusetrans,item where item.itemnum=matusetrans.itemnum and item.capitalized=0 and matusetrans.storeloc not like ('%VRPRJ%') and matusetrans.transdate>='" + txtDate.Text.Trim() + "' and matusetrans.transdate<='" + toDate.Text.Trim() + "' group by matusetrans.c_department, matusetrans.siteid, matusetrans.storeloc  order by matusetrans.siteid, matusetrans.storeloc, matusetrans.c_department");
                        query = string.Format("select siteid,CAST(SUM(linecost) as decimal (18,1)) As Consumption, matusetrans.currencycode from matusetrans, item where item.itemnum=matusetrans.itemnum and item.capitalized=0 and matusetrans.siteid IN ('" + strRigToPass.Trim() + "') and matusetrans.storeloc not like ('%VRPRJ%') and matusetrans.transdate>='" + txtDate.Text.Trim() + "' and matusetrans.transdate<='" + toDate.Text.Trim() + "'  group by  matusetrans.siteid, matusetrans.currencycode ");
                    }
                    // chrt.DataSource = sqlObj.GetTable(query);
                    dt = sqlObj.GetTable(query);
                    if (dt.Rows.Count > 0)
                    {
                        lblMessage.Text = "Daily Consumption of Rig" + " " + "from" + " " + txtDate.Text.Trim() + " " + "to" + " " + toDate.Text.Trim();
                        lblMessage.Visible = true;
                        chrt.DataSource = sqlObj.GetTable(query);

                        //chrt.Series["consumption"].XValueMember = "c_department";
                        chrt.Series["consumption"].XValueMember = "siteid";
                        chrt.Series["consumption"].YValueMembers = "Consumption";


                        chrt.Legends["TestLegend"].Enabled = true;
                        chrt.Legends["TestLegend"].Alignment = StringAlignment.Far;
                        chrt.Legends["TestLegend"].Docking = Docking.Bottom;
                        chrt.ChartAreas.Add("TestArea");


                        chrt.Series["consumption"].ChartArea = "TestArea";
                        chrt.ChartAreas["TestArea"].Area3DStyle.Enable3D = true;


                        chrt.ChartAreas["TestArea"].AxisY.TitleAlignment = StringAlignment.Center;
                        chrt.ChartAreas["TestArea"].AxisX.LabelStyle.Angle = -90;
                        chrt.ChartAreas["TestArea"].AxisY.LabelStyle.Font = new Font("Arial", 9, GraphicsUnit.Pixel);
                        chrt.ChartAreas["TestArea"].AxisX.LabelStyle.ForeColor = Color.Red;
                        chrt.ChartAreas["TestArea"].AxisY.LabelStyle.ForeColor = Color.DarkBlue;

                        chrt.ChartAreas["TestArea"].AxisX.TitleAlignment = StringAlignment.Near;
                        chrt.ChartAreas["TestArea"].AxisX.TextOrientation = TextOrientation.Horizontal;
                        chrt.Series["consumption"].Color = System.Drawing.Color.MediumSeaGreen;
                        //chrt.Series["consumption"].BorderColor = System.Drawing.Color.Yellow;
                        chrt.Series["consumption"].MarkerColor = System.Drawing.Color.Firebrick;

                        chrt.Series["consumption"].IsValueShownAsLabel = true;

                        chrt.Series["consumption"].ChartType = SeriesChartType.Pie;


                        //chrt.ChartAreas["TestArea"].AxisX.Title = "Department";
                        chrt.ChartAreas["TestArea"].AxisX.Title = "Rig";
                       // chrt.ChartAreas["TestArea"].AxisY.Title = "Consumption ins Rs";
                        if (dt.Rows[0]["currencycode"].ToString().Trim()=="INR")
                        {
                            chrt.ChartAreas["TestArea"].AxisY.Title = "Consumption in Rs";
                        }
                        else if (dt.Rows[0]["currencycode"].ToString().Trim()=="$")
                        {
                            chrt.ChartAreas["TestArea"].AxisY.Title = "Consumption in $";
                        }
                        chrt.DataBind();

                        this.Controls.Add(chrt);
                        //chrt.Controdd(pnlScattered);
                       // chrt.Series["consumption"].ToolTip = "Rig= #VALXnConsumption= Rs#VALY";

                        if (dt.Rows[0]["currencycode"].ToString().Trim()=="INR")
                        {
                            chrt.Series["consumption"].ToolTip = "Rig= #VALXnConsumption= Rs #VALY";
                        }
                        else if (dt.Rows[0]["currencycode"].ToString().Trim()=="$")
                        {
                            chrt.Series["consumption"].ToolTip = "Rig= #VALXnConsumption= $ #VALY";
                        }
                    }
                    else
                    {

                        lblValidate.Visible = true;
                        lblValidate.Text = "No Records Are Found";
                    }
                }

           


            catch (Exception Ex)
            {
                lblGreen.Visible = true;
                lblValidate.Visible = true;
                lblValidate.Text = Ex.Message;
                lblGreen.Text = "";

            }
        }

But this is not called on chart click . Any idea?

Hi guhan,

If you want to call the MSChart’s click event, I suggest you to setup the PostBackValue’s value.

Please try to refer to the following code:

Chart1.Series["SeriesName"].PostBackValue = "item";
Chart1.Click += new ImageMapEventHandler(Chart1_Click);

Hope it can help you.

Best Regards,
Terry Guo

Will this click event working in Share point 2007 visual web part? The click event is not firing?

 

 

Will this click event work in Share point 2007 visual web part? The click event is not firing?