diogobernardino / williamchart Goto Github PK
View Code? Open in Web Editor NEWAndroid Library to rapidly develop attractive and insightful charts in android applications.
Android Library to rapidly develop attractive and insightful charts in android applications.
I want to set YAxis label to right.
How can I do?
Thank You
Hi Diogo,
It looks like it is a very nice library, however I am not sure of what kind of features are available. The current demo app does not provide enough examples. It would be great to provide a demo app with various customizations and features. For example, is the chart scrollable, zoomable, can the data be added dynamically etc. It would be very useful for the future visitors.
Hi Diogo,
Thanks for the awesome library! I am curious, are you planning to implement a zooming feature too? How difficult would that be to implement?
Hi, I want to show toolbar tip all the corresponding values in bar chart without clicking bar.
Are there plans to include a legend?
Trying to implement a LineChart in my app. However, the following line gives me trouble.
.show(getAnimation(true).setEndAction(mEnterEndAction))
The error thrown is as follows:
Cannot resolve method 'getAnimation(boolean)'
Any ideas?
UPDATE:
facepalm nvm, forgot to add the private getAnimation method.
Is it possible to add a target line to the line graph?
I have a bar chart with variable number of bars. I enabled animations:
mBarChart.show(new Animation())
After that I noticed that it crashes when showing a chart with more bars than the previous one. It happens only if the previous animation hasn't ended yet.
The exception says:
java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
at com.db.chart.view.animation.Animation.getUpdate(Animation.java:349)
at com.db.chart.view.animation.Animation.access$100(Animation.java:33)
at com.db.chart.view.animation.Animation$1.run(Animation.java:90)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Using the debuger I observed that nEntries
was 4 (3rd chart has 4 bars) while mInitTime
had only 3 elements (2nd chart has 3 bars).
Hi.Thanks a lot.
I've set Persian labels and it become question marks.
and this my labels in code:
private String[] lineLabels = new String[7];
private void intitLineLables() {
String[] dayTitle={"یکشنبه","دوشبه","سه شنبه","چهارشنبه","پنجشبه","جمعه","شنبه"};
Calendar cal = Calendar.getInstance();
Calendar calendar = Calendar.getInstance();
int day = calendar.get(Calendar.DAY_OF_WEEK);
for (int i=6;i>=0;--i){
--day;
if(day==-1)
day=6;
lineLabels[i]=dayTitle[day];
}
}
Hi,
in my opinion, you should add function to hide/remove single set(by passing index as argument).
Best regards
shalastra
Is it possible to make horizontal Labels (String[]) from 1 to 30 AND set the points to 2, 10, 12, 20 (e.g.)?
Or do i have to set the same String[]-Lenght for the Points and the Labels?
Or maybe i can set @Null-Values to Skip the Points?
This library looks great and I would be glad to use it! But after more than 2 hours of trying to import/inlcude the library into Android Studio, I gave up.
Probably it is fault on my side as it seems other people made it work.
I managed to get the library into my local maven repository, but anyway, Android Studio always ended up throwing an error at me.
Error:A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not find com.db.williamchart:williamchart:1.0.0.
Required by:
MyAppName:app:unspecified
No matter what repositories or dependencies I specify in the build.gradle files, it won't work for me :(
Perhaps describe more specifically what goes where in the 'Grade Build' section of README.md?
Thank you 😃
Hi there,
I'm finding I'm getting NPE exceptions with bar charts that only have one Bar in a single BarSet.
The exception is coming from onPreDrawChart(ArrayList data) in BarChartView.java:
calculateBarsWidth(data.size(), data.get(0).getEntry(0).getX(),
data.get(0).getEntry(1).getX());
This code assumes that there is at least 2 entries.
Hi!
I like so much this library!! :) But I would suggest to enhance a compiled dependencies for Android Studio (Gradle)...
for example:
dependencies {
compile 'com.diogobernardino.williamchart:+'
}
It is very useful for the developers! :)
Filling up BarChartView
with BarSet
composed of Bar
s that have empty label String and trying to show the chart fires an error.
...
bar = new Bar("", 64);
...
java.lang.IndexOutOfBoundsException
at android.graphics.Paint.getTextBounds(Paint.java:2525)
at com.db.chart.view.YController.init(YController.java:141)
at com.db.chart.view.ChartView$1.onPreDraw(ChartView.java:138)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:888)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2199)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6632)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:814)
at android.view.Choreographer.doCallbacks(Choreographer.java:614)
at android.view.Choreographer.doFrame(Choreographer.java:584)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:800)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5487)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Is it possible to toggle the visibility of the line between points in the line chart - I would love to see that?!
I'm using Android Studio 1.1.0. I've been having some issues with building my project with this library. I added my ANDROID_HOME environment variable using the terminal in Android Studio.
set ANDROID_HOME=C:\...\Android\android-sdk
So using the terminal I navigate to C:...\WilliamChart-master which contains the library source code I downloaded from github (the root directory where the gradlew file is).
And I managed to do installDebug properly.
gradlew installDebug
But install doesn't seem to work
gradlew install
I get the following errors:
2 errors
58 warnings
:library:androidJavadocs FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':library:androidJavadocs'.
> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): 'C:\...\WilliamChart-master\library\build\tmp\androidJavadocs\javadoc.options'
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Here's my build.gradle (app)
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.doomonafireball.betterpickers:library:1.5.3'
compile 'com.db.williamchart:library:1.7.0'
}
Here's my build.gradle (Project)
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenLocal()
}
}
I noticed that adding empty label (empty string) in the X axis labels helps to avoid overlapping of X and Y labels, however this does not work if I have a lot of data. Then this moves the X labels just a little bit, and I don't always know the amount of data to be plotted.
Is there a way to avoid this overlapping? I thought of adding some space between the Y axis labels and the chart, but I couldn't find such a method implemented...
Hey,
I experienced some issues with the onClickListener and onChartClickListener.
It seems that the clickListeners work (just sometimes) only when the chart is drawn with an animation. Without an animation the listeneres does not always get called.
Any recommendations?
Best regards,
froder1k
Any plans for scatter plot with log normal scale? Thanks!
One of the commonest data representations are through pie charts. It would be a very nice feature.
Hi,
can you add setter for mMaxLabelValue in YController? It has default value 0(defined in controller). Some graphs might have custom Y axis labels, currently it creates labels from 0 to max setted value in setMaxAxisValue(int, int).
Best regards
shalastra
PS. Great work doing this library.
If I create BarChartView in .xml file like this:
<com.db.chart.view.BarChartView
xmlns:chart="http://schemas.android.com/apk/res-auto"
android:id="@+id/chart_BarChartView"
android:layout_width="match_parent"
android:layout_height="128dp"
/>
Then get the view with findViewById(R.id.chart_BarChartView);
and try to show barChartView.show();
, an OutOfBoundsException
always fire.
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at com.db.chart.view.YController.init(YController.java:141)
at com.db.chart.view.ChartView$1.onPreDraw(ChartView.java:138)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:888)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2199)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6632)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:814)
at android.view.Choreographer.doCallbacks(Choreographer.java:614)
at android.view.Choreographer.doFrame(Choreographer.java:584)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:800)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5487)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
It seems to lack support for negative bar chart. When I setup the widget with negative values, I get unexpected results.
Nice library!
Is there a way to change the text color of the labels?
Hi, how to change single dots color in line chart? I want the start point and end point have different color. What i am already do
private void updateLineChart() {
mLineChart.reset();
LineSet dataSet = new LineSet();
for (int i = 0; i < lineLabels.length; i++) {
dataSet.addPoint(lineLabels[i], lineValues[0][i]);
dataSet.setDots(true);
if (i == 0) {
dataSet.setDots(true);
dataSet.setDotsColor(this.getResources().getColor((R.color.horbar_grid)));
Log.d("TAG", "masuk 3");
}
else
{
dataSet.setDotsColor(this.getResources().getColor((R.color.horbar_fill)));
dataSet.beginAt(1);
}
}
mLineChart.addData(dataSet);
Hi,
let's say you have two data sets, first starts from 0 to 4 X axel, and second from 0 to 6. After adding that kind of sets, graph crashes with
java.lang.IndexOutOfBoundsException: Invalid index 5, size is 5.
Is there any solution for adding sets with different X axel lengths?
Best regards
shalastra
I have spend much time in making the demo run. I use eclipse for that.
Finally, I use Activity taking place of ActionBarActivity. The demo just starts to run.
It would be great component if it will support candles. Even as "pro" version.
Hello,
I was trying to put the dependency on Android Studio in the gradle file:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.db.williamchart:williamchart:1.0.0'
}
And it gives me this error:
Error:Failed to find: com.db.williamchart:williamchart:1.0.0
Can you help on this?
Obrigado ;)
i tryed your example , when set height to 300dp, it not work
<com.db.chart.view.LineChartView
xmlns:chart="http://schemas.android.com/apk/res-auto"
android:layout_height="300dp"
android:id="@+id/linechart"
android:layout_width="match_parent"
android:layout_marginTop="7dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginBottom="2dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="#00BBA7"
chart:chart_axisColor="@color/axis"
chart:chart_typeface="Roboto-Regular.ttf"
chart:chart_labelColor="@color/label"
chart:chart_axisBorderSpacing="0dp">
</com.db.chart.view.LineChartView>
<com.db.chart.view.BarChartView
xmlns:chart="http://schemas.android.com/apk/res-auto"
android:id="@+id/barchart"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".22"
android:layout_marginTop="2dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginBottom="2dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="#F67743"
chart:chart_axisColor="@color/axis"
chart:chart_typeface="Roboto-Regular.ttf"
chart:chart_labelColor="@color/label"
chart:chart_axisBorderSpacing="25dp"
/>
<com.db.chart.view.HorizontalBarChartView
xmlns:chart="http://schemas.android.com/apk/res-auto"
android:id="@+id/horbarchart"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".22"
android:layout_marginTop="2dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginBottom="2dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="#9e9d24"
chart:chart_axisColor="@color/axis"
chart:chart_typeface="Roboto-Regular.ttf"
chart:chart_labelColor="@color/label"
chart:chart_axisBorderSpacing="25dp"
/>
<com.db.chart.view.StackBarChartView
xmlns:chart="http://schemas.android.com/apk/res-auto"
android:id="@+id/stackbarchart"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".22"
android:layout_marginTop="2dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginBottom="7dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="#00BAD3"
chart:chart_axisColor="@color/axis"
chart:chart_typeface="Roboto-Regular.ttf"
chart:chart_labelColor="@color/label"
chart:chart_axisBorderSpacing="25dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".10"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/alpha"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".17"
android:src="@drawable/alpha"
android:background="@drawable/button"
android:contentDescription="@string/alpha_str"/>
<View android:layout_width=".5dp"
android:layout_height="match_parent"
android:background="#1f3133"/>
<ImageButton
android:id="@+id/enter"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".17"
android:src="@drawable/enterb"
android:background="@drawable/button"
android:contentDescription="@string/enter_str"/>
<View android:layout_width=".5dp"
android:layout_height="match_parent"
android:background="#1f3133"/>
<ImageButton
android:id="@+id/order"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".17"
android:src="@drawable/ordere"
android:background="@drawable/button"
android:contentDescription="@string/order_str"/>
<View android:layout_width=".5dp"
android:layout_height="match_parent"
android:background="#1f3133"/>
<ImageButton
android:id="@+id/ease"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".17"
android:src="@drawable/ease_cubic"
android:background="@drawable/button"
android:contentDescription="@string/ease_str"/>
<View android:layout_width=".5dp"
android:layout_height="match_parent"
android:background="#1f3133"/>
<ImageButton
android:id="@+id/play"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".30"
android:src="@drawable/play"
android:background="@color/button_hey"
android:contentDescription="@string/play_str"/>
</LinearLayout>
It would be great to publish at maven central
Trying my best to implement a linechart in my app, however, no matter what I do I cant seem to get it to show at all. I am probably doing something wrong or missing some essential line of code, but here is my current code -> https://gist.github.com/Zyg0te/78921bc90c532b5cd3b8
Any input on what's missing would be most appreciated. The library seems awesome.
I'm going to try and narrow down @ what point the barchart broke, to identify the commit, but just wanted to bring up that as of 9/23's commit, my graphs look like this:
After pulling the latest commit, my chart looks like this:
I've made no changes to my code, I would be happy to paste my entire .java file, or the relevant code if necessary. I'll update this as i pull each commit to find where it breaks. The last working commit was 8671e62 on 9/23.
Progress:
82cfda8 working
050fa6d broken
so it appears the tooltips update did something, and the problem is in:
-public abstract class ChartView extends View{
+public abstract class ChartView extends RelativeLayout{
By changing RelativeLayout back to View, and commenting out all tooltip code, the graph works again.
I want to divide my LineChart into different sections, like below:
I tried using setHorizontalGrid and setVerticalGrid methods, but they just draw lines. And also, they draw lines for each entry (In my case, I would like to draw grid for multiple entries). And what would make it even better is adding an option to set the line labels on X axis for each Grid, centered, like in the picture.
How can I achieve such kind of result (or something close to that)? Any suggestions? Thanks!
I have IndexOutOfBoundsException when I'm trying add several Points(" ", 0) to lineSet and trying to show LineChartView
java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
at java.util.ArrayList.get(ArrayList.java:304)
at com.db.chart.view.YController.parseYPos(YController.java:282)
at com.db.chart.view.ChartView$1.onPreDraw(ChartView.java:135)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:671)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1818)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Hello, I was wondering if it is possible to change the color of a particular dot on the line chart.
private final static String[] lineLabels = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL"};
private final static float[][] lineValues = { {201f, 202f, 210f, 220f, 222.5f, 222.5f, 230f},
{-9f, -2f, -4f, -3f, -7f, -5f, -3f}};
private final static int LINE_MAX = 240;
private final static int LINE_MIN = 200;
private final static int[] beginOrder = {0, 1, 2, 3, 4, 5, 6};
@AfterViews
public void setup(){
Paint mLineGridPaint = new Paint();
mLineGridPaint.setColor(this.getResources().getColor(R.color.primary_light));
mLineGridPaint.setPathEffect(new DashPathEffect(new float[] {5,5}, 0));
mLineGridPaint.setStyle(Paint.Style.STROKE);
mLineGridPaint.setAntiAlias(true);
mLineGridPaint.setStrokeWidth(Tools.fromDpToPx(.75f));
mainChart.reset();
mainChart.setOnEntryClickListener(lineEntryListener);
LineSet dataSet = new LineSet();
dataSet.addPoints(lineLabels, lineValues[0]);
dataSet.setDots(true)
.setDotsColor(this.getResources().getColor(R.color.light_green_200))
.setDotsRadius(Tools.fromDpToPx(5))
.setDotsStrokeThickness(Tools.fromDpToPx(2))
.setDotsStrokeColor(this.getResources().getColor(R.color.light_green_400))
.setLineColor(this.getResources().getColor(R.color.light_green_400))
.setLineThickness(Tools.fromDpToPx(3));
mainChart.addData(dataSet);
mainChart.setBorderSpacing(Tools.fromDpToPx(4))
.setHorizontalGrid(mLineGridPaint)
.setXAxis(true)
.setXLabels(XController.LabelPosition.OUTSIDE)
.setYAxis(true)
.setYLabels(YController.LabelPosition.OUTSIDE)
.setAxisBorderValues(LINE_MIN, LINE_MAX, 10)
.setLabelsMetric("kg")
.show()
//.show()
;
}
<com.db.chart.view.LineChartView
xmlns:chart="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainChart"
android:layout_below="@+id/sectionPrograms"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="7dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginBottom="2dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="#00FFFFFF"
chart:chart_axisColor="@color/primary"
chart:chart_labelColor="@color/secondary_text"
chart:chart_axisBorderSpacing="0dp"></com.db.chart.view.LineChartView>
If I set LINE_MIN = 0 all values displayed correctly
What I'm doing wrong?
Thanks for the help!
I updated the code in drawBackground in the LineChartView class to be this instead to fix it
private void drawBackground(Canvas canvas, Path path, LineSet set, float minDisplayY) {
float innerChartBottom = super.getInnerChartBottom();
mStyle.mFillPaint.setAlpha((int) (set.getAlpha() * 255));
if (set.hasFill())
mStyle.mFillPaint.setColor(set.getFillColor());
if (set.hasGradientFill())
mStyle.mFillPaint.setShader(
new LinearGradient(
super.getInnerChartLeft(),
minDisplayY,
super.getInnerChartLeft(),
innerChartBottom,
set.getGradientColors(),
set.getGradientPositions(),
Shader.TileMode.MIRROR));
//Check if we have changed end with EndAt, in that case reduce gradient and set it there
if (set.getEnd() != set.size()) {
path.lineTo(set.getEntry(set.getEnd() - 1).getX(), innerChartBottom);
} else {
path.lineTo(set.getEntry(set.size() - 1).getX(), innerChartBottom);
}
path.lineTo(set.getEntry(0).getX(), innerChartBottom);
path.close();
canvas.drawPath(path, mStyle.mFillPaint);
}
If this is not a wanted feature, I think it should be an option atleast in WilliamChart, needless to say, I love WilliamChart :)
I am trying to plot measurements taken on different days (not equidistant). However, I could not figure out how to plot the data based on time (or value). Please see the example below:
As you can see, all the values on the X axis are displayed with the same distance between them.
It would be great to create distance between the values on the X axis, based on their values. Are you planning to implement this support? Or any suggestions to to make this work? Thanks!
One a LineChartView
I am essentially trying to draw a data set like:
{0, 1}
{0, 2}
{0, 4}
Which should normally be a vertical line. This what I tried in code.
LineSet dataSet = new LineSet();
dataSet.addPoint("F", 1.0f);
dataSet.addPoint("F", 2.0f);
dataSet.addPoint("F", 4.0f);
But that doesn't have the desired effect. It ends up creating a new value for F on the x-axis for each point.
Values in Y axis are not plotted properly when they are high.
For example the following values are plotted like this:
{90f, 99f, 91f, 93f, 95f, 97f, 92f}
And these are plotted as:
{115f, 99f, 91f, 100f, 101f, 130f, 105f}
However, plotting low values works just fine:
{10, 3f, 1f, -1f, 11f, 8f, 1f}
Is this a bug? Or am I doing something wrong?
Hey. I am trying out your library, looks cool =)
I am currently trying to use the Line Chart.
Im wondering if it is possible to add the line chart to a horizontal scrollview and make the spacing between each point fixed.
I was just looking over the code I've got to generate a set of bars..
BarSet wins = new BarSet();
List<Integer> wins2 = null;
try {
wins2 = new GetHistoryArray().execute("wins").get();
for (int j = 0; j < wins2.size(); j++) {
Bar bar = new Bar(mMonths.get(j), wins2.get(j));
wins.addBar(bar);
}
mBarChart.addData(wins);
This would be a heck of a lot easier to implement, if there was a method such as:
BarSet wins = BarSetFromArray(wins2);
One line to generate the entire set. I'm not super familiar with git, but I could probably fork the project, add this as a function in BarSet, but Java isn't my strength still, so maybe someone else can comment?
Is there any way to have 1:00 1:30 ... etc. for y labels? For now I'm forced to use seconds and setmetric as "s", but I'd love to get a real time reading.
Maybe there is a string override labels for y that I overlooked :) ?
I'm using a bar graph and this happens whenever I set all the values for the bars to zero. I'm not trying to update the graph while it still animating or anything like that. It is just that my user generated data will be retrieved as all zeroes.
Here's the stack trace I get:
java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at com.db.chart.view.YController.parsePos(YController.java:97)
at com.db.chart.view.ChartView$1.onPreDraw(ChartView.java:143)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:847)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1956)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:550)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
And this is a simplified version of my code:
BarChartView chart = (BarChartView) this.getView().findViewById(R.id.barchart);
BarSet barSet = new BarSet();
Bar bar;
float[] barValues = {0.0f, 0.0f};
int[] barColors = { R.color.bar1, R.color.bar2};
String[] labels = {"A","B"};
// Creating bars
for(int i = 0; i < barValues.length; i++){
bar = new Bar(labels[i], barValues[i]);
bar.setColor(this.getResources().getColor(barColors[i]));
barSet.addBar(bar);
}
chart.addData(barSet);
chart.setYAxis(false)
.setYLabels(AxisController.LabelPosition.NONE)
.show(new Animation()
.setEasing(new ElasticEaseOut()));
As long as I change one of the values to something different than zero the graph displays just fine.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.