1
Hello, I’m having trouble finding a solution to fill my linechart with data from a query, my connection class is complete and working, but I don’t know how to apply on Chart, I don’t know how to create automatically, I just enter values.
Currently my chart is powered by data entered via code-Behind:
Wpf:
<chartingToolkit:Chart Name="lineChart" Title="Series Demo" Margin="0,10,10,54">
<chartingToolkit:LineSeries DependentValuePath="Value"
IndependentValuePath="Key" ItemsSource="{Binding}"
IsSelectionEnabled="True" />
</chartingToolkit:Chart>
Code c#:
public partial class Charts : Window
{
public Charts()
{
InitializeComponent();
showColumnChart();
}
private void showColumnChart()
{
List<KeyValuePair<string, int>> valueList = new List<KeyValuePair<string, int>>();
valueList.Add(new KeyValuePair<string, int>("oculos", 60));
valueList.Add(new KeyValuePair<string, int>("lentes prontas", 200));
valueList.Add(new KeyValuePair<string, int>("manutenção", 10));
lineChart.DataContext = valueList;
}
}
I have a table with these same values and would like to use them from the table in sql server, can add or remove later without changing the code.
I’ll try now and warn you.
– Brewerton Santos
could send an example code?
– Brewerton Santos