Search Unity

[Released] Graph Maker - UGUI - NGUI - DFGUI (line graphs, bar graphs, pie graphs, etc)

Discussion in 'Assets and Asset Store' started by rorakin3, Sep 26, 2013.

  1. Snipe3000

    Snipe3000

    Joined:
    Aug 31, 2013
    Posts:
    7
    That fixed it. I was using the prefab from the old version.
    Thanks
     
  2. Maverick

    Maverick

    Joined:
    Dec 18, 2009
    Posts:
    58
    Hi, a quick question.

    How can I decrease the space marked in the image with red?

    Screenshot at Jan 28 08-40-59.png

    Thanks
     
  3. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    Hey, I think you want to use the padding variables. In the "Core" tab on the axis graph inspector, increase the y value of "Padding Left Right"
     
    Last edited: Jan 28, 2016
  4. Snipe3000

    Snipe3000

    Joined:
    Aug 31, 2013
    Posts:
    7
    I have a very basic question. I have a line graph setup and I'm trying to use this data to create a straight line:

    r1Data.Add(new Vector2(0, 82));
    r1Data.Add(new Vector2(6, 82));
    r1Data.Add(new Vector2(12, 82));
    r1Data.Add(new Vector2(18, 82));
    r1Data.Add(new Vector2(24, 82));
    r1Data.Add(new Vector2(30, 82));
    r1Data.Add(new Vector2(36, 82));

    Y axis is 0 to 100 with 11 ticks total.
    I noticed that (6, 82) is the only point that shows up. It seems that the max value of the X axis is set to the total number of points or something like that; its basicly graphing to the number of ticks and completely ignoring the x value. How do I get the graph to scale to the highest number instead while maintaining only 7 ticks, because I have 7 values?
    Also, (0, anything) never shows up on the graph.

    Thanks
     
    Last edited: Feb 3, 2016
  5. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    Hey, I think you have grouping enabled. Uncheck "Use Grouping" in the "Core" tab options of the graph's inspector. When grouping is enabled the x-value corresponds with the index of the "Groups" list. You can check out the tutorial video / scene for more info.
     
  6. WalterBoyd

    WalterBoyd

    Joined:
    Sep 25, 2015
    Posts:
    13
    Hi Rorakin,

    I'm still liking Graph Maker! I'm having some performance issues, hoping you can give me some tips. I have a line graph with several lines, each 200-300 points. My app allows users to pick various datasets, and I want the graph to update real time as they do this. But removing a line series is very slow - several seconds - and adding a new series can also take several seconds on some devices. I've stepped through code, and seems to be lots of loops-within-loops when removing a series. Animations are disabled. Any thoughts?

    -Walter
     
  7. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    Hey, glad to hear it!
    When adding a new series with 200-300 points for a line graph the performance shouldn't be much different than if you were to have a for loop that looped 400-600 times and instantiated a gameobject with a UI image component each time.

    I would recommend trying to reuse series instead of create and destroy them. For example, you could have a couple series with 250 points created in the beginning and hidden with the hide points / hide lines enabled. Then when you need a new series with different data you can set the point data list, and uncheck the hide points / hide lines. If your new series is 300 points and the current series is 250 points, only 50 points should get created which should not be too bad performance wise.
     
  8. ymassuot

    ymassuot

    Joined:
    Aug 1, 2013
    Posts:
    28
    Hi
    How to load data from excel files?
     
  9. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    Hey there,

    I would probably use SQL lite database, import the excel files as tables into the SQL lite database. You can check asset store for various SQL lite packages. From those packages it should be easy to query the database to get Lists of the things you want to graph in Graph Maker.

    If this is more of a one-off thing, I would probably just export excel file to CSV file, and then write a simple script to read the CSV file. From the file loading you should be able to construct the datastructures Graph Maker expects (List<vector2>, List<string>, List<float>)
     
    Last edited: Feb 29, 2016
  10. jvadri

    jvadri

    Joined:
    Mar 9, 2015
    Posts:
    1
    Hi rorakin3,

    I have seen a tutorial in youtube ( Unity - Graph Maker Tutorial 1 ) that you are working with point and lines creating your own layout. I see that this scene is depecrated and now it doesn’t exist in new version of the plugin.

    I need a scene that user can create his own polygons (squares, triangles, etc.) with your GUI system, do you have some come like in the youtube tutorial to create these forms in “play”?

    Thanks!
     
  11. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    Hey there,

    Have you checked out the X_Dynamic scene? In that scene, at one point a triangle is generated, which animates into a circle. Using the GenCircular() API function used in that scene you can generate anything from a line segment to a circle, you just pass in for example 5 as one of the parameters and it will give a pentagon. So you can make a scene that just calls this function with different parameter depending on the shape you want. Each shape would just be a series in the graph, and you can add as many series as you want. And then since your not using it as a typical line graph, can just hide the axes / background grid.
     
  12. bjornrun

    bjornrun

    Joined:
    Oct 29, 2013
    Posts:
    87
    Where is the color of the background for the whole graph set?
     
  13. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    What do you mean, whole graph set?
     
  14. bjornrun

    bjornrun

    Joined:
    Oct 29, 2013
    Posts:
    87
    The background with rounded corners is dark grey. I have not seen any attribute that changes the color.
    I also want to screen coordinates for this, so a screen shot of only the graph can be made.
     
  15. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    Ah, I see. The gameobject for this is under graph->Background->Sprite. You can change the color from the Image component. The object can also be accessed via code (Axis_Graph.graphBackground). The coordinates are based on the rect transform
     
    bjornrun likes this.
  16. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    Hey all,
    Graph Maker 1.5.4 is coming soon, and features some improvements to pie / doughnut graphs. You can add click / hover events to the pie slices, and there is a new example scene to demonstrate this.
     
  17. ArseneySorokin

    ArseneySorokin

    Joined:
    Jan 23, 2013
    Posts:
    51
    Hi Rorakin3,

    I've bought the Graph Maker resource and I'm trying to make a dynamic graph, just like the one in your demo.
    I want to add points to it in real time and I want these points to animate nicely on the graph (The demo seems to show this is possible).

    However, your pdf file doesn't seem to explain how to do that very well at all. All I've managed to figure out was that I need to use the WMG_Data_Source script and put it as a "realTimeDataSource" parameter of my series.
    When I try and figure out how to populate the list of points in real time all the pdf is telling me is "use reflection".

    Could you please post an example on how to populate a graph in real time like you do in your demo?

    Thanks in advance,

    Arseney
     
  18. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    Hey,

    Yes, the PDF is lacking here. You are trying to replicate the first demo scene linked on the asset store where the points animate nicely one after another ?

    If so, in this case there isn't anything special (Graph Maker wise), that you need to do. You don't need to use WMG_Data_Source, that demo uses standard Unity Coroutine to add 1 point after another point. I recommend to pretty much just copy paste that scene / that scene example code. You will need to change example scene code to pull from your own List<float> of data instead of what it does now (which is generate a random float using Random.Range())
     
    Last edited: Mar 28, 2016
  19. toppps

    toppps

    Joined:
    Jan 21, 2016
    Posts:
    3
    I'm looking to do something similar to this, I'll be having a graph with 3 series of data on it, updating in real time depending on the value of a slider. I'd prefer to have the series of data separate as well, so that they can easily be updated individually as this is an ongoing project.

    I'm still in the process of learning as much as I can about c sharp so I'm a little stuck on how to get started on this. Any help in the right direction would be awesome.

    Thanks
     
  20. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    The slider controls which one of the 3 series is displayed, or something else? The x-axis is time for all 3 series? Feel free to send me email with more info / details.

    In general I recommend to first get a simple script going that populates the 3 series with your custom data, then modify that script to plot it overtime using Unity Coroutine, then once that's working you can look to animate plot the data overtime. For this, I recommend looking over the code in WMG_X_Sample_1.cs.
     
  21. EyePD

    EyePD

    Joined:
    Feb 26, 2016
    Posts:
    35
    Sorry to ask but one of my projects is still in Unity 4; Is there a similar "point by point" scene for Graph Maker 1.4? I was trying to use the 1.5.3 script but I had problems with the graph.addSeries() call; there seemed to be some null pointers related to the legend (I had mine set to the standard legend prefab). Perhaps it would be better to pre-define some empty series in the Inspector and then add to them from a Coroutine?

    Are there any advantages performance wise to using reflection over adding points individually?

    I was able to get reflection working (in 1.5.3) based on the X_Dyanmic.unity scene; the realTimeTests Coroutine is a really good example and you should link to it from the documentation which covers reflection.

    I'm new to reflection but based on what I've read it seems that it would be difficult to setup reflection from a float[] array where for example array would be the provider for series 1 and array[j] would provide for series 2. I tried some different combinations based on different WMG_VariableTypes but I couldn't find one that worked. It seems like WMG_Reflection would have to be modified to deal with the array indexing.
     
  22. toppps

    toppps

    Joined:
    Jan 21, 2016
    Posts:
    3
    The X axis is time, so the slider controls which of the points are shown/hidden, if it has not happened along the timeline, then there is no need to show it yet. I'll send you an email with more details.
     
  23. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    It's been awhile since I looked at the 1.4x version, but if I had to guess the issue probably has to do with code in one Start() method having expecting code in another Start() method to have been called. As you said, creating an empty series via inspector should work.

    Performance wise, I would expect adding points manually instead of via reflection to be slightly better. The calls to the reflection API will have some overhead, and in Graph Maker 1.5+ all lists were changed to be observable. Meaning, adding the points manually incurs no overhead until the points are actually added (previously Update() would check the lists against cached versions of the lists). The reflection method requires using Update() to poll the data from the data providers. If the data from the data providers doesn't match the cache, then the graph will update.

    If you are using float[] array, and you have 2 series with different indices, I think this will work-
    Create 2 float properties for your 2 series that have a getter method that pull from an index in the float[] array. For example:
    Code (csharp):
    1.  
    2. public float series1Data {
    3. get {return myArray[0];}
    4. }
    5.  
    You would then use a WMG_VariableType of property with variable name series1Data.
     
  24. Vorren

    Vorren

    Joined:
    Oct 24, 2014
    Posts:
    18
    Hey! I'm looking to build a graph (vertices and edges structure that is) editor with UGUI. Is it something that is possible to do with that asset? Adding/removing and linking/unlinking nodes. I know that there is a sample for NGUI, but no idea whether you got around to implementing it with UGUI.
     
  25. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    Hey, no sorry not yet. I'm considering making a simpler version of that scene for the next update though.
     
  26. EyePD

    EyePD

    Joined:
    Feb 26, 2016
    Posts:
    35
    In Graph Maker 1.4 I don't get any space between the Y axis and the start of the data but in the latest version I'm getting a space about 30% of my overall width (the rest of the graph was clipped to make the image below smaller). My x axis is time and I have the graph scrolling along nicely with auto shrink & grow set.
    graph.png

    From what I understand in some of the previous replies the various padding values are just to add space outside the graph area so I don't think that's what I need. Can someone point me in the right direction?
     
  27. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    Your series' have "use x dist between to space" checked? Is the beginning of the graph supposed to move? If no, try turning off auto shrink / grow for the x-axis minimum, and instead set the x-axis minimum to the first data point's x.
     
  28. fBrazao

    fBrazao

    Joined:
    Feb 3, 2016
    Posts:
    1
    Hi

    Nice work !
    I would like to know how to update the series with data read from a file? if you can give me some direction. thank you
     
  29. Al-

    Al-

    Joined:
    Jun 5, 2015
    Posts:
    20
    Hi

    Congratz for your wonderful asset!. I was interested in using the features of Graph Editor, but I can't find it in the packet and it says it's deprecated. How can I do a graphic of this kind -like those created with WMG_Editor- now?. Thank you!
     
  30. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    Hey there,

    It mostly depends on the kind of file, but if it's CSV / excel file(s), then I would probably use SQL lite database, or G2U (google spreadsheets to unity). From those packages it should be easy to get Lists of the things you want to graph in Graph Maker. Graph Maker ultimately needs a list of strings for labels, and list of floats or vector2s depending on the type of graph you are making.
     
    fBrazao likes this.
  31. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    Hey there,

    That example scene I discontinued / deprecated with the move to Unity's UI system, but I may consider adding a similar example scene for Unity UI. What sorts of features are you looking to have or what kind of graph are you making?
     
  32. EyePD

    EyePD

    Joined:
    Feb 26, 2016
    Posts:
    35
    I want the graph to move as the x-axis is time. I tried "use x dist between to space" but then the lines seem to get compressed all the way down and are only displayed on the y-axis:
    y-axis.png
     
  33. Al-

    Al-

    Joined:
    Jun 5, 2015
    Posts:
    20
    I love the tool to create organizative schemas like the structure in the departments of a company, and I loved the easiness to change symbols... I'm exploring your package and all the features and a tool like that would be very useful to me and an added value to graphs drawing, I think.

    Thank you
     
  34. ymassuot

    ymassuot

    Joined:
    Aug 1, 2013
    Posts:
    28
    Hi
    Is there any way to connect an XML reader method to your Pie_Chart script? I successfully have implemented this method to your bar chart and line chart scripts but the same technique didn't work for the Pie Chart. How can I define a string array to catch slice values from an XML file instead of its default public list for user input?
     
  35. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    No need to use "x dist to space". For this case I recommend to not use auto grow/shrink for the X axis, and change the x-axis max / min manually overtime, as is done in the demo 1 scene (first link on store page).

    Sounds good, I'll try to get an example scene with this soon.

    Ah, you overrode the labeling function like was done in the demo 1 scene (first link on store) ? I can add a label override function for pie graph next update. In the meantime I recommend to just set the List<string> for the slice labels.
     
  36. Ricoo77

    Ricoo77

    Joined:
    Jun 18, 2014
    Posts:
    2
    Hello, i think it would be a cool feature to implement Béziers curves into line graphs, to get a smooth graph instead of getting a divided line (i'm asking because i need it actually and i have to recode the smoothing myself)
    By the way thank you for your awesome work on this package !
     
  37. Xan-Ko

    Xan-Ko

    Joined:
    Apr 12, 2016
    Posts:
    14
    Hello i have a question how can get te max and min value form a WMG_Series? I want to adjust the scale of the y axis to the max and min value form the series, in the x axis i have the time. The y axis have positive and negative values.

    Thanks.
     
  38. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    810
    about WMG_Hierarchical_Tree sample any get execute in editor real time
    and select node by link for exemple if i got node 0 node 1 is active etc
     
  39. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    That would be cool indeed. I would probably go about it by modifying texture data. The tricky part would be making it work without performance issues. If you figure out a good solution, let me know!

    Hey, you can just loop through the points and check the values like so:
    Code (csharp):
    1.  
    2. float maxY = Mathf.NegativeInfinity;
    3. float minY = Mathf.Infinity;
    4. for (int i = 0; i < series1.pointValues.Count; i++) {
    5.     if (series1.pointValues[i].y > maxY) {
    6.         maxY = series1.pointValues[i].y;
    7.     }
    8.     if (series1.pointValues[i].y < minY) {
    9.         minY = series1.pointValues[i].y;
    10.     }
    11. }
    12.  
    Hey sorry, I don't quite understand the question.
     
    manpower13 likes this.
  40. Ricoo77

    Ricoo77

    Joined:
    Jun 18, 2014
    Posts:
    2
    I haven't been encountering big performance issues with my Béziers functions, but i think it depends on the amount of points you are adding, in my case i'm subdividing 10 or 100 times at most, and i'm not really encountering issues. Maybe with dynamic point loading it could lag a bit... A Coroutine might do the trick maybe ?

    Should i send you my code in a private message for you to think about integrating it inside the plugin ?
     
  41. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    Sure, feel free to email me (my email first page of thread) your approach. Yeah I was thinking it being able to handle dynamic (during run-time) changes to the graph, but I would still be interested to see what you came up with.
     
  42. Xan-Ko

    Xan-Ko

    Joined:
    Apr 12, 2016
    Posts:
    14
    Thanks!! it works like a charm.

    I have another question.

    I have a bar graph with realtime update but only want the Y axis of the bar change, the bar must go up and down as the data changes, but not move in the X axis.
     
    Last edited: Apr 19, 2016
  43. manpower13

    manpower13

    Joined:
    Dec 22, 2013
    Posts:
    104
    Hey Rorakin3,

    I just wanted to say thanks for the great update! I love the fact I can handle the tooltip's label. I already implemented that by myself earlier, but this is way better :).

    Thank you and keep it going!
     
  44. dansolhan2

    dansolhan2

    Joined:
    Feb 4, 2015
    Posts:
    3
    Hi!

    First wanted to say that this is tremendously useful software which we are using a fair bit in our project.

    But! I am suffering from something I suspect to be a bug. I at least can see no other reason for the code to react this way:

    In the hierarchial tree, when I try to make a link to any other invisible node than element 0 (-1), I get an argument out of range error. Am I missing something vital, or is this a bug?
     
  45. EyePD

    EyePD

    Joined:
    Feb 26, 2016
    Posts:
    35
    That works great, thanks!
     
  46. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    450
    If you are using real-time update, the x-axis acts as time and will move forward. Don't use real-time update, enable auto-animations, and auto grow / shrink for the y-axis. When you set the data the bars will animate to the new values that you set.

    Awesome, thanks for the kind words, and glad you like the updates!

    Hmm, yes I took a look and it looks like a bug, not sure how that happened! I will include the fix in the next update for sure, in the meantime, to fix it you can replace CreatedLinks() function in WMG_Hierarchical_tree.cs with this:

    Code (csharp):
    1.  
    2.     public void CreatedLinks() {
    3.         // Create links based on numLinks
    4.         for (int i = 0; i < numLinks; i++) {
    5.             if (treeLinks.Count <= i) {
    6.                 GameObject fromNode = null;
    7.                 if (linkNodeFromIDs[i] > 0) { // Regular node
    8.                     fromNode = treeNodes[linkNodeFromIDs[i]-1];
    9.                 }
    10.                 else { // Invisible node
    11.                     fromNode = treeInvisibleNodes[-linkNodeFromIDs[i]-1];
    12.                 }
    13.                 GameObject toNode = null;
    14.                 if (linkNodeToIDs[i] > 0) { // Regular node
    15.                     toNode = treeNodes[linkNodeToIDs[i]-1];
    16.                 }
    17.                 else { // Invisible node
    18.                     toNode = treeInvisibleNodes[-linkNodeToIDs[i]-1];
    19.                 }
    20.                 treeLinks.Add(CreateLinkNoRepos(fromNode.GetComponent<WMG_Node>(), toNode, linkPrefab, linkParent));
    21.             }
    22.         }
    23.     }
    24.  
    Awesome!
     
  47. Xan-Ko

    Xan-Ko

    Joined:
    Apr 12, 2016
    Posts:
    14
    Thanks rorakin3 i made it and works great.

    Thank you for the hard work and answer our questions, your extension is a must have for graphs in Unity!!
     
  48. dansolhan2

    dansolhan2

    Joined:
    Feb 4, 2015
    Posts:
    3
    You, sir, are a godsend! Thank you very much :)

    Quick update: Worked like a charm!
     
  49. YossiElimelech

    YossiElimelech

    Joined:
    Feb 12, 2016
    Posts:
    26
    I'm having a problem after upgrading from v1.4 to the latest version I get NullReferenceException WMG_Axis_Graph_E.OnInspectorGUI() The script is showing only the header
     
  50. ymassuot

    ymassuot

    Joined:
    Aug 1, 2013
    Posts:
    28
    Hi
    How can I add 2 different titles to the bar chart and avoiding the title strings for being on top of each other?