Graphics

 View Only
  • 1.  Line and Pie Charts

    Posted 02-28-2013 21:41
    Is there any way to create line and pie charts within Xpression? Bar charts I can do with a little scripting magic, just not sure how to make line or pie charts work.


  • 2.  RE: Line and Pie Charts

    Posted 03-01-2013 08:28
    Hi Richie,

    There is a way to create linecharts using scripting. Have a look in the SDK-helpfile where you can find an example. Look for "Using the APITexture Shader".

    For the piecharts, you can use cylinders.

    In the properties of the cylinder you will find the "Start Angle" and "End". playing around with these values will allow you to create a piechart.

    Best regards,

    Kenneth

    #XPression


  • 3.  RE: Line and Pie Charts

    Posted 03-05-2013 23:54
    Not sure why I did not think of the pie charts and cylinders. Thanks for your help.

    #XPression


  • 4.  RE: Line and Pie Charts

    Posted 03-28-2013 15:26
    Hi,

    Is there a way, with an animcontroller, to keyframe the Start and End Angle of a cylinder ?

    Thank you !

    #XPression


  • 5.  RE: Line and Pie Charts

    Posted 03-31-2013 20:20
    Hi

    Currently you cannot set the Start and End Angles, but I have created a few script samples including two for pie-charts.

    Drop me an email, and i can send them to you.

    The script for a half-pie-chart created on "OnOnline"

    ' This sample script is supplied for illustration only and should

    ' be used only as a guide to script development by end users.

    ' No warranty as to its functionality or suitability is expressed or implied.

    '

    ' By Niels Borg

    ' 2013 TV/MIDT-VEST

    'Define variables

    dim txtObj(2) as xpTextObject

    dim cylObj(2) as xpCylinderObject

    dim intValue(2) as integer

    dim intTotal as integer

    'Assign XPression objects to variables

    self.GetObjectByName("Val1", txtObj(0))

    self.GetObjectByName("Val2", txtObj(1))

    self.GetObjectByName("Val3", txtObj(2))

    self.GetObjectByName("Cylinder1", cylObj(0))

    self.GetObjectByName("Cylinder2", cylObj(1))

    self.GetObjectByName("Cylinder3", cylObj(2))

    'Assign values from the text objects to variables

    intValue(0) = strConv(txtObj(0).text, vbInteger)

    intValue(1) = strConv(txtObj(1).text, vbInteger)

    intValue(2) = strConv(txtObj(2).text, vbInteger)

    'Calculate the total sum of the values

    intTotal=intValue(0)+intValue(1)+intValue(2)

    'Convert the values to degrees (a fraction of 180 degrees)

    intValue(0)=(intValue(0)/intTotal)*180

    intValue(1)=(intValue(1)/intTotal)*180

    intValue(2)=(intValue(2)/intTotal)*180

    'Set the start angle of the first cylinder to 0

    cylObj(0).startAngle=0

    'Set the end angle to the variable intValue(0)

    cylObj(0).endAngle=intValue(0)

    'Set start angle of the second cylinder to the end angle of the first cylinder

    cylObj(1).startAngle=intValue(0)

    'Set the end angle to the sum of variable intValue(0) and intValue(1)

    cylObj(1).endAngle=intValue(0)+intValue(1)

    'set the start angle of third cylinder to the end angle of the second cylinder

    cylObj(2).startAngle=intValue(0)+intValue(1)

    'Set the end angle to the sum of variable intValue(0), intValue(1) and intValue(2)

    cylObj(2).endAngle=intValue(0)+intValue(1)+intValue(2)

    #XPression


  • 6.  RE: Line and Pie Charts

    Posted 04-02-2013 21:22
    I generate bar graphs from DataLinq info using Scale.X within our election scenes. The graph shows all election candidates and what their percentage is. The percentage comes through in simple statements (i1-9, 10-99, and 100, not 001-100), so I had to take that into account.

    Here's the code:

    dim Bar as xpBaseObject

    dim BarNum as Integer

    dim PercVal as xpTextObject

    dim i as Integer

    for i = 1 to 3

    Self.GetObjectByName("Bar" & i, Bar)

    If Self.GetObjectByName("Percent" & i, PercVal) then

    BarNum=Cint(PercVal.Text)

    End If

    If BarNum < 10 then

    Bar.ScaleX = ("0.0" & BarNum)

    ElseIf 9 < BarNum and BarNum < 100 then

    Bar.ScaleX = ("0." & BarNum)

    ElseIf BarNum = 100 then

    Bar.ScaleX = 1

    End If

    next i


    This requires that you set up your "bar" to be at 100% scale for whatever your max value is (it is 100 in this case), then just do the math to figure out how far or high to scale it after that.

    You could also go the route of it being a value of 1 to at 100% scale, then if your graph goes from 1 to 500, your scale would just need to match the number (Bar.ScaleX = BarNum. It will then grow from the smallest number to the largest. Would require a bit more math on the initial setup, is all.

    EDIT: Fixed the script, it was deleting things in between my greater than and less than tags. Edited to only use
    #XPression


  • 7.  RE: Line and Pie Charts

    Posted 04-02-2013 21:44
    Why don't you do Bar.ScaleX = BarNum / 100 ?

    #XPression


  • 8.  RE: Line and Pie Charts

    Posted 04-02-2013 21:45
    I thought I tried that first and ran into some sort of issue. Could've been a glitch or typo. Mostly likely an error somewhere between the chair and keyboard. But this worked, so I stuck with it.

    #XPression


  • 9.  RE: Line and Pie Charts

    Posted 04-02-2013 21:57
    Add a CInt... It wilk resolve all your pb ! ;)

    #XPression


  • 10.  RE: Line and Pie Charts

    Posted 04-14-2020 15:29

    Hi. I wish to share you a project that has two scenes with animated data driven line charts. It can have some errors but is usable. Feel free to use it as you want.

     

    https://github.com/nicolasjuan/xpLineChart


    #XPression