I am using jjoe64 Graph View in my android application.
and I am trying to show dynamic values in graph but first time it contains no values but graph is not appearing.
give me solution.
http://www.android-graphview.org/
https://github.com/jjoe64/GraphView
Can you show us your code?
Have you tried something like
graph = (GraphView) findViewById(R.id.graph);
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>();
graph.addSeries(series);
graph.getViewport().setXAxisBoundsManual(true);
graph.getViewport().setYAxisBoundsManual(true);
graph.getViewport().setMinX(0);
graph.getViewport().setMaxX(0);
graph.getViewport().setMinY(0);
graph.getViewport().setMaxY(4);
graph.onDataChanged(true, true);
There's a bug report logged for this one, and it appears the issue will be fixed in the next release (4.0.1).Anyway I simply coded around the issue, by displaying some text, indicating there's no data at that point eg.
// If there is no data, let the user know, else blank the textBox.
TextView fragmentText = (TextView) v.findViewById(R.id.history_text);
if ( xLabels.size() < 2 ){
fragmentText.setTextSize(24);
fragmentText.setText(getString(R.string.history_graph_no_data));
} else {
// Remove the "No Data" text
fragmentText.setText("");
LinearLayout layout = (LinearLayout) v.findViewById(R.id.history_graph);
addGraphToLayout(layout);
}
Related
Am using AndroidPlot on my project and it's just great so far. This is what i got.
Now am trying to remove one of the series indicators from the legend. Actually i want to keep only the first one (the blue one) cause the others are self explanatory.
Am not asking how to remove the legend it self (see https://stackoverflow.com/a/13413758/665823 for that issue).
If someone can help me i'll be great. Thanks in advance.
I finally found a tweek that allows me to do what i need. To achieve this the series that i need to be shown must be added to the plot first over the ones i need to hide :
// I add the blue serie first
LineAndPointFormatter mFormat = new LineAndPointFormatter();
mFormat.configure(context, R.xml.plot_blue);
graphView.addSeries(serieMesures, mFormat);
// I add the other colors after
for (XYSeries serie : seriesSeuils) {
LineAndPointFormatter sFormat = new LineAndPointFormatter();
if (serie.getTitle().equals("RED") {
sFormat.configure(context, R.xml.plot_red);
}
else if (serie.getTitle().equals("ORANGE")) {
sFormat.configure(context, R.xml.plot_orange);
}
else if (serie.getTitle().equals("YELLOW")) {
sFormat.configure(context, R.xml.plot_yellow);
}
graphView.addSeries(serie, sFormat);
}
Then i just created a legend where there is only enough space to show the series i need (in my case just the first one).
// This is what does the trick! A Table with 1 line and 1 column
// so the other series can't be rendered in the LegendWidget
graphView.getLegendWidget().setTableModel(new DynamicTableModel(1, 1));
// Other customizations (size and position)
graphView.getLegendWidget().setSize(new SizeMetrics(55, SizeLayoutType.ABSOLUTE, legendWith, SizeLayoutType.ABSOLUTE));
graphView.getLegendWidget().setPositionMetrics(
new PositionMetrics(20,
XLayoutStyle.ABSOLUTE_FROM_RIGHT,
20,
YLayoutStyle.ABSOLUTE_FROM_TOP,
AnchorPosition.RIGHT_TOP));
graphView.getLegendWidget().setBackgroundPaint(bgPaint);
graphView.getLegendWidget().setTextPaint(txPaint);
graphView.getLegendWidget().setBorderPaint(brPaint);
graphView.getLegendWidget().setPadding(10, 1, 10, 1);
And voila!
Cannot find any documentation on how to config ShowcaseView.
This is from ShowcaseView GitHub pages:
Usage
To use ShowcaseView, use one of the insertShowcaseView(..) calls. These take:
A Target which represents what should be showcased. See the wiki for more details.
An Activity
Optional title and detail strings (or resource ids) which show on the ShowcaseView
Optional a ConfigOptions which can alter the behaviour of ShowcaseView. See the wiki for more details
The only working link is the wiki one, where i cannot find anything about ConfigOptions and how to use it, other links are broken.
I'm trying to write down a little tutorial for my app, here's what I deduced by studying the source code:
ShowcaseView.ConfigOptions co = new ShowcaseView.ConfigOptions();
co.hideOnClickOutside = false;
//show only first one once?!
co.shotType = ShowcaseView.TYPE_ONE_SHOT;
co.showcaseId=1;
co.centerText=true;
co.noButton=false;
co.block = true;
RelativeLayout.LayoutParams lps = new RelativeLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT);
lps.addRule(RelativeLayout.CENTER_IN_PARENT);
lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
int margin = 10;
lps.setMargins(margin, margin, margin, margin);
co.buttonLayoutParams = lps;
ShowcaseViews svs = new ShowcaseViews(this);
ShowcaseViews.ItemViewProperties ivp;
ivp= new ItemViewProperties(
R.id.target1,
R.string.target1_tit,
R.string.target1_desc,
0.4f,
co
);
svs.addView(ivp);
co.showcaseId=2;
ivp= new ItemViewProperties(
R.id.target2,
R.string.target2_tit,
R.string.target2_desc,
0.4f,
co
);
svs.addView(ivp);
co.showcaseId=3;
ivp= new ItemViewProperties(
R.id.target3,
R.string.target3_tit,
R.string.target3_desc,
0.4f,
co
);
svs.addView(ivp);
svs.show();
but i cannot figure out many things:
how to place title and message strings at the center of the screen (ConfigOption.centerText has no effect?)
how to resize text (i would like it bigger)
how to place the OK button elsewhere (ConfigOption.buttonLayoutParams has no effect)
how to dismiss showcase (or display next one) when user touches the target view
thanx.
how to place the OK button elsewhere (ConfigOption.buttonLayoutParams has no effect)
This is the only thing I know of:
svs.setButtonPosition( LAYOUTPARAMS OBJECT HERE );
I am working on a project that will display math problems to the screen such as:
10 + 5 =
and then the user will need to guess the answer. I am doing this as more of way for me to learn how android ticks.
I have images from 0 to 9 saved in the drawable folder for each of the dpi setting I need to account. I also have the operators (+,-,*,/,=) also saved.
My questions:
How easy is this to do?
How would I go about doing the above dynamically?
Thanks
--EDIT--
The images and operators are stored as .9.png files in my drawable folder. I have string-array contain my problems that I will randomly pull from and then display them to the screen.
In the past I would do the following:
public View buildProblem()
{
LinearLayout rtnView = new LinearLayout(ctx);
rtnView.setOrientation(LinearLayout.HORIZONTAL);
rtnView.setLayoutParams(new GridLayout.LayoutParams());
// Build LeftSide
Iterator<Integer> itor = buildLeftSide();
ImageView iv;
// loop through of iterator
while(itor.hasNext())
{
iv = new ImageView(ctx);
iv.setScaleType(ImageView.ScaleType.FIT_CENTER);
iv.setImageResource(itor.next());
itor.remove();
rtnView.addView(iv);
}
// Space
rtnView.addView(space);
// Operator
rtnView.addView(plusSign);
// Build LeftSide
itor = buildRightSide();
// another loop
while(itor.hasNext())
{
iv = new ImageView(ctx);
iv.setScaleType(ImageView.ScaleType.FIT_CENTER);
iv.setImageResource(itor.next());
itor.remove();
rtnView.addView(iv);
}
// Space
rtnView.addView(space);
// Equal Sign
rtnView.addView(equalSign);
// Space
rtnView.addView(space);
// return the view
return rtnView;
}
I was thinking of using ImageViews for the numbers to be displayed to the screen which I have used in the past but not sure if that is the best way to do it.
https://github.com/barakisbrown/MathTest -- Is one attempt at doing the above but I have now started to rewrite it from scratch so which is why I am asking for help.
New to Starling-Feathers, before I start to develop my mobile app, I would like to know what are the best practice to develop the following features using Feathers:
Partial view slide - A part of the next view is shown and the user can drag to see it all. Could this be done with Feathers ScreenNavigator?
Sliding menu from the top
Dragging text elements with title pushing the last items
Since it is hard to describe I've added an animated gif to describe my goals. Thanks for all your advices
I would like to maximize the use of Feathers built in widgets and will appreciate code examples :)
I think these are not that much hard to do in core flash or you can also do it in Starling feathers too. YOu can use list item to do the third point (Dragging text elements with title pushing the last items) .
First and second you can use it with tweening effect i think.
For the third one using feathers list.
(re formated post)
private function addFeatherList():void{
Flist = new List();
Flist.width = 250;
Flist.height = 300;
Flist.x = GAME_W/2 - Flist.width/2;
Flist.y = sampText.height + 5;
this.addChild( Flist );
fontArr = Font.enumerateFonts(true);
for (var i:int=0; i<fontArr.length; i++){
ListArr[i] = { text:Font(fontArr[i]).fontName }
}
var groceryList:ListCollection = new ListCollection( ListArr );
Flist.dataProvider = groceryList;
Flist.itemRendererProperties.labelField = "text";
FeathersControl.defaultTextRendererFactory=function():ITextRenderer{
var render:TextFieldTextRenderer=new TextFieldTextRenderer();
render.textFormat = new TextFormat("Verdana",8,0xFFFFFF,false);
return render;
}
Flist.itemRendererFactory = function():IListItemRenderer //list.itemRendererProperties.accessorySourceField list.itemRendererFactory
{
var renderer:DefaultListItemRenderer = new DefaultListItemRenderer();
renderer.addEventListener(Event.TRIGGERED, onListTriggered);
return renderer;
}
}
Basically i want to draw a graph where x-axis gives you the date and y axis gives u the count
I am getting data from server and parsing it in my two array's one is for count and other is for date
i am getting values in two array like this
SoapObject o=(SoapObject)p2.getProperty(xx);
UserCallStatusBean ld=new UserCallStatusBean();
if(o.getProperty("Month").toString().equals("anyType{}")){
ld.setDuration("");
}
else{
ld.setDuration(o.getProperty("Month").toString());
}
ld.setCount(Integer.parseInt(o.getProperty("Count").toString()));
CallStatus.add(ld);
GraphViewData o1=new GraphViewData(_iLoopCounter,Double.parseDouble(o.getProperty("Count").toString()));
String o2=new String(o.getProperty("Month").toString());
//String o2=new String(String.valueOf(_iLoopCounter));
arrData[xx]=o1;
arrXaxis[xx]=o2;
_iLoopCounter++;
After Getting the Value in two array i use Graph View Demo to create a grapg like
setContentView(R.layout.graphs);
// init example series data
exampleSeries = new GraphViewSeries(arrData);
// graph with dynamically genereated horizontal and vertical labels
GraphView graphView;
graphView = new BarGraphView(
this,"");
graphView.addSeries(exampleSeries); // data
graphView.setScalable(true);
graphView.setScrollable(true);
graphView.setViewPort(2,6);
graphView.setScrollable(true);
graphView.setHorizontalLabels(arrXaxis);
graphView.setGravity(Gravity.CENTER);
graphView.setBaselineAlignedChildIndex(4);
//graphView.setHorizontalLabels(labels);
LinearLayout layout = (LinearLayout) findViewById(R.id.graph1);
layout.addView(graphView);
Now My issue of concern is i am getting value of count on y-axis but i am also getting count of date on x-axis instead i want to show the date on x-axis
I Have read various articles to get string value on x-axis ,finded one to use Cutom lavel formatter , But didnt knw how to use so what i can do to get x-axis ? (Date Value)
I hope u understands ,Expecting Answer Pleasue will b aLl Mine
Thanks in advance