ASP:CHART legend check box series control - c#

I have a fully functioning Dynamic chart control( just the regular ASP.net Chart ) It works great but I've run into a problem trying to add check boxes to the legend. I'm trying to add them next to the series names so the user can hide or view the respective series data. The chart is plotting data for roughly 42 employees. So being able to select and hide data is very important. I've been researching this for a few days now and I've found examples for 3rd party chart tools but i need to do this in MSVS 2010 standard charting tool.
This is how I create the Chart.
for (int emp = 1; emp < empRowList.Length; emp++)
{
chartB.Series.Add(empRowList[emp]);
chartB.Series[empRowList[emp]].ChartType = SeriesChartType.Point;
chartB.Series[empRowList[emp]].MarkerSize = 10;
chartB.Series[empRowList[emp]].MarkerStyle = MarkerStyle.Star4;
for (int month = 1; month < 12; month++)
{
chartB.Series[empRowList[emp]].Points.AddXY(mfi.GetMonthName(month), employeeStats[month, emp]);
chartB.Series[empRowList[emp]].Points[chartB.Series[empRowList[emp]].Points.Count - 1].ToolTip = empRowList[emp] + " - " + employeeStats[month, emp];
}
}
Here is how I format the chart
chartB.DataSource = t.Tables["info"];
chartB.DataBind();
chartB.Legends.Add(new Legend("Legend"));
chartB.Legends["Legend"].Alignment = StringAlignment.Center;
chartB.Legends["Legend"].Docking = Docking.Top;
I looked through this post thinking it could be augmented to help but since his series aren't added dynamically i'm not sure if it is the right direction to pursue.
ASP .net 4 Chart Control Legend formatting is not displaying at all
I've also looked in to using custom legends but read that they aren't linked to the data so i thought that might also be that wrong direction.
If anyone could help it would be greatly appreciated i'm kind of at a stand still till I can figure this out.
Thanks in advance

Some code on this would have been wonderful as I was looking to do something similar.
I did however find a post on msdn that states custom legends are not possible.
http://msdn.microsoft.com/en-us/library/bb677428(v=sql.100).aspx

I was able to find a solution similar to what i wanted using the code from the link above but could never quite get the legend to work properly so i scrapped that idea and just dynamically created a check-box bank underneath my chart that hides/shows series. Wasn't too difficult just needed to create a class and deal with the click event verses the redraw of the graph.

Related

Creating a drilldown chart with Highcharts that contain double(multiple) columns for each column (see example for better explanation)

First question here!
I'm trying to create a chart (with drill down) in High Charts that should look like this:
https://www.dropbox.com/s/34r8cjm5urqgmh1/year.png
When you click on a year column it should drill down to the following (month view)
https://www.dropbox.com/s/2cji7a534wmwt2u/month.png
One of my problems is that each column in the drill down should, how to put it, have two (multiple) columns. For example, the month view (the drill down) should have 2 columns per month (current & previous month).
I just have no clue about how to design this chart in regards to series data etc etc.
Have looked thru just about every relevant High Charts example I have been able to dig up on the net.
Regards
Joakim
Check out this answer
Highcharts drilldown from a series
which is just a modification of the stock drilldown demo
http://www.highcharts.com/demo/column-drilldown

Asp.net chart control IsValueShownAsLabel and label will display values with $ symbol

I have set IsValueShownAsLabel to true in asp.net chart control.
I am trying to show these visible lables as $100.00 instead of showing only numerics like 100.00 or so.
Is there any way as I understand that only numerics can be visible as lables.
chartSeries.LabelFormat = "${0.00}";
solved my problem
Edit:
The most professional way with hints from prthrokz's comment to the question.
chartSeries.LabelFormat = "{0:C}";

How do I remove an Excel Chart Legend Entry with C#?

I want to remove the legend entry for some, but not all, series in my Excel chart. From my experience it seems as if SeriesCollection.Item(index) and LegendEntries.Item(index) are not related. Given a series n how can I remove only the legend for that series?
I'm using Office Interop 2010 with Visual Studio 2010. This is easily accomplished via the GUI by selecting the legend entry, then right clicking and choosing "delete".
To delete a legend entry you have to know the index of the legend you want to delete. Unfortunately, there doesn't seem to be a relationship available through the interop api that exposes the relationship between legend and series. There is one hokey workaround however. To remove a legend for a specific series the approach that worked for me was to remove the legend immediately after adding the series. This is the only time that the legend index is known.
// .
// . code to add series
// .
// remove the legend entry for the newly added series
chart.Legend.LegendEntries(chart.Legend.LegendEntries().Count).Delete();
I know the original question was about Office Interop 2010, but this seems to be a good reference point for dynamically showing and hiding series in a chart too, so I'll add the following top in case it helps others.
If you want to show/hide a series on a chartobject on a worksheet in Office 2013 (in VBA at least; not sure about interop), you can do the following:
Worksheets("MySheetName").ChartObjects("MyChartName").Chart.FullSeriesCollection("MyLedendSeriesName").IsFiltered = false
This hides the series without removing it. Set it to true to show the series again.
I needed to remove the last two legend entries from a chart because they were fake series added to create a cross-hairs effect. One series made the vertical line and the other horizontal. After the legend entry was removed, the series remained on the chart, which is what I wanted. I used the code below:
Microsoft.Office.Interop.Excel.ChartObject chartObj = null;
Microsoft.Office.Interop.Excel.Chart chart = null;
Microsoft.Office.Interop.Excel.Legend legend = null;
Microsoft.Office.Interop.Excel.LegendEntries legendEntries = null;
Microsoft.Office.Interop.Excel.LegendEntry legendItem;
int legendEntryCount = 0;
chartObj = (Microsoft.Office.Interop.Excel.ChartObject) xlws.ChartObjects("Chart 1");
chart = chartObj.Chart;
legend = chart.Legend;
legendEntries = (Microsoft.Office.Interop.Excel.LegendEntries) chart.Legend.LegendEntries();
legendEntryCount = legendEntries.Count;
if (legendEntryCount > 2)
{
legendItem = (Microsoft.Office.Interop.Excel.LegendEntry) legend.LegendEntries(legendEntryCount);
legendItem.Delete();
legendItem = (Microsoft.Office.Interop.Excel.LegendEntry) legend.LegendEntries(legendEntryCount - 1);
legendItem.Delete();
}

C# MS Chart Control - highlight today's date in Gantt Chart

The title of this question says it all.
I've got a gantt chart (RangeBar) made using the MS Chart Control, and at present I have some StripLines to highlight weekends and the start of each month, but I need one to appear on today's date only so the user can see where we are at the mo.
Is this possible with this control, or am I fishing for unicorns?
If it's possible, how?
Cheers
Nevermind, figured it out:
StripLine strpToday = new StripLine();
strpToday.IntervalOffset = DateTime.Today.ToOADate();
strpToday.StripWidth = 1;
strpToday.BackColor = Color.ForestGreen;
chtHC.ChartAreas[0].AxisY.StripLines.Add(strpToday);

How to add an image to ListView column header?

It should be easy, right?
Have a listview, add an imagelist, add images to the imagelist, assign image index to the column you want.
But, it doesn't work.
Microsoft article states that it is a known problem in .NET 1.1.
But has it been fixed since?
You still have to use Interop. I suggest you to use the example given in the article.
I did like this
1)made imagelist1
2)set the listviewlarge=imagelist1 & samallImagelist = imagelist1
3)write to form initilaize area
this.Columname0.ImageIndex = 0;
this.Columname1.ImageIndex = 1;
its work.

Categories

Resources