Currently i am looking into making a bar chart in my WPF application.
Although i am not sure what exactly sure what the best way would be for handling this:
- WPF Toolkit (last update seems ages ago, dated since 2010)
- List control and style / display it as a bar chart
- …?
The layout will be pretty basic, but it would be nice if the bar charts could actually be updated at run time.
The values of the bar charts are being generated trough SQL server database values.
The bar char values will always be times (HH:mm:ss).
Also the 4-5 bars that will be displayed are related to each other (so bar 1 cannot for example exceed 100% if there is a other bar if this makes any sense).
The bar are shown within a 24 hour time frame.
With each bar there has to be also a timer that actually times how long the certain activity is running (in a separate textbox, it does not require to be included in the chart itself).
So to sum it up 1 bar will include its name and it value (hh:mm:ss) in separate labels / textblocks. Unless there is a better solution suggested.
Currently i have the layout, but it only consists out of a grid, labels and retangles.
Thanks.
That’s how I would do it:
I’d use a simple ItemsControl as it is the most lightweight control for this, and for ListView etc. you would have to turn off a lot of stuff.
Then I would create a list of items where each item represents one of the bars, and those items (in a list) are the bound to the items control. Each item will contain the properties needed to display it (actual value, etc.).
The ItemsControl then gets a Datatemplate where height and width are bound to the properties of the items (using a converter) to display them properly.
If you want to change a bit how things are displayed, I’d use a Canvas as ItemsPanel which allows you to freely position the items.
If you use for the list of items an ObservableCollection and each item implements INotifyPropertyChanged, you can easily update the display of the bars.