Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do Chart on Windows Phone Universal App

I'm new Windows Phone Universal App, I need to implement bar/pie chart.

Tried many dll, Metro UI, WinRtXamlToolKit and WinRtXamlToolKit.Controls.DataVisualization These dll are not working.

Give me good idea to do this on Windows Phone Universal App. How to do chart programmatically.

Thanks

like image 339
Jeeva123 Avatar asked Jun 11 '14 05:06

Jeeva123


1 Answers

I believe the Telerik has some Chart libraries that cost money ( can't link though as stackoverflow only permits me to post 2 links ( less than 10 rep) ). I have not used it and it is in Beta version at the moment. Google "Rad Chart windows universal apps" and you can read about it.

When I have needed charts for universal apps i have used the Google Chart Tools. You can use https://developers.google.com/chart/image/ even though Google is not developing on it anymore. It is is freakingly easy to use if you do not want to spend time drawing your own Charts. With the API you can request a chart just through a http request. You can setup almost everything and it's really easy to use thanks to the well documented API.

Here is an example of a bar chart i made using the API. http://chart.googleapis.com/chart?chtt=Karakterfordeling&cht=bvg&chof=png&chs=300x300&chxt=x,y&chco=0076A3&chf=bg,s,65432100&hxr=0,0,50&chxl=0:|2|4|7|10|12&chxr=1,0,20&chbh=40,0,10&chd=t:2,60,70,10,90

All the arguments are passed through the http request and you can set your Chart up using the Live Chart Playground:

These are the arguments for the http request posted above. You can use the Live Chart Playground to set up parameters like below.

chtt=Karakterfordeling
cht=bvg
chof=png
chs=300x300
chxt=x,y
chco=0076A3
chf=bg,s,65432100
hxr=0,0,50
chxl=0:
    2
    4
    7
    10
    12
chxr=1,0,20
chbh=40,0,10
chd=t:2,60,70,10,90

In code you set the http string as your ImageSource. You can manipulate the http string in your code and adapt the chart parameters/data if needed. I would recommend using a Converter that you bind to from you XAML. Pass your data to the converter and let it return a ImageSource with the http request. If you are new to Converters you can probably find a few posts about it here on stackoverflow.

like image 194
Simon Avatar answered Oct 20 '22 18:10

Simon