Using Datapoints in charts
#1
Posted 24 February 2012 - 07:54 AM
For my wpf application, i need to create month wise charts in which i have to use four datapoints for each month. four datapoints should be in bar type. how to create datapoints in simple form instead of creating 48 datapoints for all months. the datapoints value will be from web service which is used in that application. Please send some suggestion or links that would be needful.
thanks & regards,
Arun Kumar G
#2
Posted 24 February 2012 - 12:59 PM
Are you trying to create a chart where each bar will have four DataPoints? If yes then you can create a StackedColumn chart as shown below.
<vc:Chart Width="500" Height="300" >
<vc:Chart.Series>
<vc:DataSeries LegendText="ProductA" RenderAs="StackedColumn" >
<vc:DataSeries.DataPoints>
<vc:DataPoint AxisXLabel="Jan" YValue="25"/>
<vc:DataPoint AxisXLabel="Feb" YValue="24"/>
<vc:DataPoint AxisXLabel="Mar" YValue="31"/>
<vc:DataPoint AxisXLabel="Apr" YValue="34"/>
<vc:DataPoint AxisXLabel="May" YValue="32"/>
<vc:DataPoint AxisXLabel="Jun" YValue="25"/>
<vc:DataPoint AxisXLabel="Jul" YValue="24"/>
<vc:DataPoint AxisXLabel="Aug" YValue="31"/>
<vc:DataPoint AxisXLabel="Sept" YValue="34"/>
<vc:DataPoint AxisXLabel="Oct" YValue="32"/>
<vc:DataPoint AxisXLabel="Nov" YValue="34"/>
<vc:DataPoint AxisXLabel="Dec" YValue="32"/>
</vc:DataSeries.DataPoints>
</vc:DataSeries>
<vc:DataSeries LegendText="ProductB" RenderAs="StackedColumn" >
<vc:DataSeries.DataPoints>
<vc:DataPoint YValue="33"/>
<vc:DataPoint YValue="22"/>
<vc:DataPoint YValue="30"/>
<vc:DataPoint YValue="38"/>
<vc:DataPoint YValue="31"/>
<vc:DataPoint YValue="82"/>
<vc:DataPoint YValue="64"/>
<vc:DataPoint YValue="95"/>
<vc:DataPoint YValue="86"/>
<vc:DataPoint YValue="61"/>
<vc:DataPoint YValue="38"/>
<vc:DataPoint YValue="61"/>
</vc:DataSeries.DataPoints>
</vc:DataSeries>
<vc:DataSeries LegendText="ProductC" RenderAs="StackedColumn" >
<vc:DataSeries.DataPoints>
<vc:DataPoint YValue="33"/>
<vc:DataPoint YValue="22"/>
<vc:DataPoint YValue="30"/>
<vc:DataPoint YValue="38"/>
<vc:DataPoint YValue="31"/>
<vc:DataPoint YValue="82"/>
<vc:DataPoint YValue="64"/>
<vc:DataPoint YValue="95"/>
<vc:DataPoint YValue="86"/>
<vc:DataPoint YValue="61"/>
<vc:DataPoint YValue="38"/>
<vc:DataPoint YValue="61"/>
</vc:DataSeries.DataPoints>
</vc:DataSeries>
<vc:DataSeries LegendText="ProductD" RenderAs="StackedColumn" >
<vc:DataSeries.DataPoints>
<vc:DataPoint YValue="33"/>
<vc:DataPoint YValue="22"/>
<vc:DataPoint YValue="30"/>
<vc:DataPoint YValue="38"/>
<vc:DataPoint YValue="31"/>
<vc:DataPoint YValue="82"/>
<vc:DataPoint YValue="64"/>
<vc:DataPoint YValue="95"/>
<vc:DataPoint YValue="61"/>
<vc:DataPoint YValue="86"/>
<vc:DataPoint YValue="61"/>
<vc:DataPoint YValue="38"/>
</vc:DataSeries.DataPoints>
</vc:DataSeries>
</vc:Chart.Series>
</vc:Chart>
Please revert back if this does not fulfill your requirement. It will be helpful for us if you explain your requirement in detail.Regards,
Sharmila
Attached Files
#3
Posted 24 February 2012 - 01:44 PM
As for my application i have used c# code to create datapoints. so to differ datapoints i have created 48 datapoints(may be i am wrong in this part) since i have to click a datapoint using mouse click event to display a datagrid with values . Please give any reference or suggestion regarding the same.
#4
Posted 28 February 2012 - 02:03 PM
You can create StackedColumn chart in managed code as shown below.
public void CreateChart()
{
chart.Width = 500;
chart.Height = 300;
for (int k = 0; k < 4; k++)
{
DataSeries ds = new DataSeries();
ds.RenderAs = RenderAs.StackedColumn;
for (int i = 0; i < 12; i++)
{
DataPoint dp = new DataPoint();
dp.YValue = rn.Next(50, 100);
ds.DataPoints.Add(dp);
}
chart.Series.Add(ds);
}
chart.Series[0].DataPoints[0].AxisXLabel ="Jan";
chart.Series[0].DataPoints[1].AxisXLabel = "Feb";
chart.Series[0].DataPoints[2].AxisXLabel = "Mar";
chart.Series[0].DataPoints[3].AxisXLabel = "Apr";
chart.Series[0].DataPoints[4].AxisXLabel = "May";
chart.Series[0].DataPoints[5].AxisXLabel = "Jun";
chart.Series[0].DataPoints[6].AxisXLabel = "Jul";
chart.Series[0].DataPoints[7].AxisXLabel = "Aug";
chart.Series[0].DataPoints[8].AxisXLabel = "Sep";
chart.Series[0].DataPoints[9].AxisXLabel = "Oct";
chart.Series[0].DataPoints[10].AxisXLabel = "Nov";
chart.Series[0].DataPoints[11].AxisXLabel = "Dec";
LayoutRoot.Children.Add(chart);
}
Please revert back if it does not solve your problem.Regards,
Sharmila
#5
Posted 28 February 2012 - 02:50 PM
As for my issue, example for Jan month i specify four datapoints and for each datapoint i used services to get the values. so for all months i have 48 values. How to use looping function here to vary 48 values since i am using mouse click event for all datapoints.Please help me on this.
#6
Posted 29 February 2012 - 06:17 AM
#7
Posted 02 March 2012 - 10:35 AM
mac, i tried giving mouse click event for data series and where can i give the list of items to display in data grid when i click the data point item. i found some difficulty to get the result. can u please post some sample code with mouse click event.
Thanks again,
Regards
Arun
#8
Posted 05 March 2012 - 06:14 AM
Can you please answer to my query below?
On click of DataSeries whether you want to display information of all DataPoints belonging to that DataSeries or you want to display information of DataPoint clicked?
Regards,
Sharmila
#9
Posted 05 March 2012 - 12:49 PM
Arun,
Can you please answer to my query below?
On click of DataSeries whether you want to display information of all DataPoints belonging to that DataSeries or you want to display information of DataPoint clicked?
Regards,
Sharmila
Thanks for asking this query, i need to display information of datapoint since each datapoint represents list of records. so when i click a datapoint a list of records will be shown in datagrid.
Please reply if it is not clearing your query.
#10
Posted 06 March 2012 - 05:53 AM
You can attach mouse event on DataSeries. Inside the event handler, you can access information related to each clicked DataPoint as shown below and display it inside the DataGrid.
void DataSeries_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
DataPoint dp = sender as DataPoint;
String label = dp.AxisXLabel;
Double yValue = dp.YValue;
}
Regards,
Vivek
Team Visifire
#11
Posted 06 March 2012 - 06:18 AM
Arun,
You can attach mouse event on DataSeries. Inside the event handler, you can access information related to each clicked DataPoint as shown below and display it inside the DataGrid.void DataSeries_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { DataPoint dp = sender as DataPoint; String label = dp.AxisXLabel; Double yValue = dp.YValue; }
Thanks for the reply vivek. What will be the simpler way if i am using four charts with month wise data and i want to use mouse click event for each datapoint. Please refer this whole post and suggest me reg the same.
Regards,
Arun
#12
Posted 06 March 2012 - 06:23 AM
Regards,
Vivek
Team Visifire
#13
Posted 06 March 2012 - 07:45 AM
In that case you have to attach event on each series and get the data from the clicked DataPoint as shown above.
As from your reply i have to mention each data point within that series, if i am having 12 datapoint within a series then i have to add 12 dp inside the data series event. Please help me if i am not clear.
#14
Posted 06 March 2012 - 12:48 PM
Regards,
Vivek
Team Visifire
#15
Posted 06 March 2012 - 01:11 PM
Whether you want to display information for a clicked DataPoint only or for all DataPoints in that series? Also, please tell me which chart type you are working with?
Vivek,
I need to display information for a clicked data point only. Each data point represents some record count and i have to display the list of records using data grid when i click it. I have four charts includes 3 of type Line charts, one of type Stacked column.
#16
Posted 07 March 2012 - 04:27 AM
Regards,
Vivek
Team Visifire
#17
Posted 12 March 2012 - 06:58 AM
Thanks for your kind reply. As per your suggestion, if i want to add list values to datapoints to display in grid how can we attach list values to datapoints. in your example we are getting datapoint yValue by code
Double yValue = dp.yValue;
But i have to show list values which will be get from service method inside the application. Here is the sample code which i used to display the list values in data grid in data point mouse click event.
void datapoint1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
SampleList={some service method to get list values}
datagrid1.Itemssource= SampleList;
datagrid1.Visibility=Visibility.Visible;
}
Here my difficulty is how can i attach distinct list values to each datapoints if i use mouse click event on data series. Need help on same.
Thanks again.
#18
Posted 12 March 2012 - 09:17 AM
Can you please tell me the purpose of the list values in DataSeries? Where exactly you are using those list values?
Regards,
Vivek
Team Visifire
#19
Posted 12 March 2012 - 09:26 AM
Arun,
Can you please tell me the purpose of the list values in DataSeries? Where exactly you are using those list values?
The data points in my charts represents the count of records. A record comprises of like empId, empName, empAge & empSalary. So when i click the data point, a data grid opens and shows the number of records with above said columns. I am getting the counts and record details bu creating service methods in my WPF-XBAP application. And my difficulty is i have to use four month wise charts and how to minimize the code part efficiently instead of creating 48 data points and using its mouse click events.
Thanks for asking this query.
#20
Posted 12 March 2012 - 11:42 AM
If you want to display information for all DataPoints on a single click, you can set a Tag property of DataSeries to SampleList.
Example:
dataSeries.Tag = SampleList;
Then inside the mouse event handler of DataSeries or DataPoint, get the SampleList from DataSeries's Tag as shown below:
void dataSeries_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
SampleList=(sender as DataPoint).Parent.Tag;
datagrid1.Itemssource= SampleList;
datagrid1.Visibility=Visibility.Visible;
}
Regards,
Vivek
Team Visifire
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users












