Visual studio c# pie chart will not redraw - c#

I am using winforms and attempting to create a pie chart which will update on a button click. I have added two points to the charts series via the designer. I am sure the values of the points are being changed however the chart itself is not updating to show this.
chart1.Series["Series1"].Points[0].SetValueY(results["TimeFrame1"].Count);
chart1.Series["Series1"].Points[1].SetValueY(results["TimeFrame2"].Count);
This updates the two points. I have tried calling chart1.update() however it did not redraw the chart. Is there some method I am not aware of to make the chart redraw. Thanks

Instead of manually setting your points inside your series, why not use databinding? That way whenever the underlying data source changes, your chart will change too. Here is another SO answer with some additional info:
How to bind data to chart in winforms and refresh chart?
Alternatively, try calling chart1.Refresh() instead of chart1.Update().

Related

Infragistics data chart C# WPF highlight part of a series

I have a listview box which contains my data, it is loaded when selected into a infragistics data chart, it is all loaded into a single stacked bar series. What I now need to be able to do is click one segment of the bar series and be able to highlight and zoom in.
Does anyone have any advice?
Thanks in advance.
I suppose you are using Bar/ColumnSeries to display single stacked bars.
To highlight you can make use of ChartAnnotationLayers to highlight a particular value & hence the bar by setting the MarkerTemplate property.
Also you can set a default value or override it on hover.
The documentation here can help.

How to make dynamic grid layout in WinRT?

I want a grid in my page to have a single column in portrait mode and have two columns in Landscape mode. Some of the content should move to the second column when the device is Landscape. I've tried to do this but couldn't.
I'm doing everything from code behind. Generating the grid, adding children etc. When Orientation changes, I destroy the current layout and create a new one. The problem with this approach is, any entered data will be gone. It's a huge code and not possible to put here. I want this layout change to happen automatically. So, any data that is entered is preserved after the orientation change.
Any help would be appreciated.
The trick is to have one grid that accommodates both states. You can use VisualStates to assign different Grid.Row, Grid.Column, Grid.RowSpan and Grid.ColumnSpan values to controls. This is done using Blend and is declarative in XAML. you give each state a name. In the code you detect size change of the window to trigger the different states using the VisualStateManager.
You can also do this without VisualStates. In that case in the event handler of the SizeChanged you have to set the appropriate values for all the controls yourself.
In Windows 10 UWP it got much simpler using RelativePanel. You can position controls in a more flexible way then with grids.
Martin

DevExpress Charts Question

Is it possible to create chart (as shown on screenshot) in DevExpress Chart control?
I have developed something similiar, already. I learned that it is better to use XtraGrid instead of the chart, as pattern matrix. The I used CustomCell drawing feature to draw colored bars according values in the cell.
Avoid DevExpress charts if you are rendering anything more than 100 data points. At least in v14 and v15, the charting controls are very, very slow compared to most things out there. Every time it redraws, you have to wait seconds for it to redraw.
This does not detract from how awesome the rest of DevExpress is (its my library of choice for everything else).
I think a different component (Pivot Table) is a more suitable solution here.
For instance, DevExpress PivotGridControl supports in-place editors such as Progress Bar (see the following example).
In addition, you can hide cells with zero values by handling the CustomCellDisplayText event and setting the e.DisplayText property to an empty string.
The simple answer is YES, it is possible

Can I make the .NET Chart control display data when mouse hovers over?

I am trying to do some charting in my of my C#.NET applications using the .NET Chart Control.
Is there a way to make a popup that shows the exact data point that the cursor is over when it is hovering over the chart?
Check the MapArea class: http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.maparea.aspx
It'll let you create maps that apply to different areas of the chart and contain their own tooltip.

Programming a Location Grid Map in C#

I would like to know if there are any inbuilt controls in C# with which I can program location grid maps on a X/Y Plane.
The only thing that comes to mind is the grid view. You could arrange the columns and rows into a regular grid.
Besides that, .Net makes it very easy to place controls dynamically into containers. You could also do manual drawing which is very straightforward.
Here is an example of grid painting.
And here's an example of dynamically adding controls to a form.

Categories

Resources