B4J Tutorial Hansolo Charts

Hansolo Charts have some very nice looking charts. Download the Jars from the link below and copy the jars into your B4J additional library folder.
A sample project is attached ( draws 8x charts). You need to study the code in the classes within the B4J project and then add inline java code and b4j code (getters / setters) to use it in a B4J project. I have just added some samples (via inline java code in B4J classes) from the 11.2 posting here:


Link to Jars....

See Post #7 onwards to make use of the charts in a B4J project.

Some of the charts are controlled by timers - run the B4J project and see the animations


1667648982025.png
 

Attachments

  • HansoloCharts.zip
    13.9 KB · Views: 337
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
Have added 5 more charts and some changes to the inline java code to return the chart objects rather than the panes. This is where I will leave it for now.

1667728843855.png
 

Attachments

  • HansoloCharts.zip
    33.3 KB · Views: 204
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
A minor update to the Main module code.

B4X:
#Region Project Attributes
    #MainFormWidth: 1200
    #MainFormHeight: 800
#End Region

#AdditionalJar: charts-11.2
#AdditionalJar: javafx-graphics-11
#AdditionalJar: javafx-base-11


Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    
    Dim nb As NestedBar
    Dim pc As ParallelCoord
    Dim cp As CircularPlot
    Dim sb As Sunburst
    Dim rc As RadarChart
    Dim crc As ComparisonRingChart
    Dim conrc As ConcentricRingChart
    Dim ccc As CoxcombChart
    Dim pfc As PlayfairChart
    Dim lc As LineChart
    Dim mp As MatrixPlot
    Dim sp As SankeyPlot
    Dim rl As RidgeLine
    Dim sc As StreamChart
    Dim mhm As MatrixHeatMap
    Dim ahm As AreaHeatMap
    Dim logc As LogChart
    Dim ta As TimeAxis
    Dim hc As HorizonChart
    Dim polar As PolarChart
    
    Private Pane1 As Pane
    Private Pane2 As Pane
    Private Pane3 As Pane
    Private Pane4 As Pane
    Private Pane5 As Pane
    Private Pane6 As Pane
    Private Pane7 As Pane
    Private Pane8 As Pane
    Private Pane9 As Pane
    Private Pane10 As Pane
    Private Pane11 As Pane
    Private Pane12 As Pane
    Private Pane13 As Pane
    Private Pane14 As Pane
    Private Pane15 As Pane
    Private Pane16 As Pane
    Private Pane17 As Pane
    Private Pane18 As Pane
    Private Pane19 As Pane
    Private Pane20 As Pane
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    
    nb.Initialize
    pc.Initialize
    cp.Initialize
    sb.Initialize
    rc.Initialize
    crc.Initialize
    conrc.Initialize
    ccc.Initialize
    pfc.Initialize
    lc.Initialize
    mp.Initialize
    sp.Initialize
    rl.Initialize
    sc.Initialize
    mhm.Initialize
    ahm.Initialize
    logc.Initialize
    ta.Initialize
    hc.Initialize
    polar.Initialize

    Pane1.AddNode(nb.drawGraph,Pane1.Width*0.025,Pane1.Height*0.025,Pane1.Width*0.95,Pane1.Height*0.95)
    Pane2.AddNode(pc.buildGraph,Pane2.Width*0.025,Pane2.Height*0.025,Pane2.Width*0.95,Pane2.Height*0.95)
    Pane3.AddNode(cp.buildGraph,Pane3.Width*0.025,Pane3.Height*0.025,Pane3.Width*0.95,Pane3.Height*0.95)
    Pane4.AddNode(sb.buildGraph,Pane4.Width*0.025,Pane4.Height*0.025,Pane4.Width*0.95,Pane4.Height*0.95)
    Pane5.AddNode(rc.buildGraph,Pane5.Width*0.025,Pane5.Height*0.025,Pane5.Width*0.95,Pane5.Height*0.95)
    Pane6.AddNode(crc.buildGraph,Pane6.Width*0.025,Pane6.Height*0.025,Pane6.Width*0.95,Pane6.Height*0.95)
    Pane7.AddNode(conrc.buildGraph,Pane7.Width*0.025,Pane7.Height*0.025,Pane7.Width*0.95,Pane7.Height*0.95)
    Pane8.AddNode(ccc.buildGraph,Pane8.Width*0.025,Pane8.Height*0.025,Pane8.Width*0.95,Pane8.Height*0.95)
    Pane9.AddNode(pfc.buildGraph,Pane9.Width*0.025,Pane9.Height*0.025,Pane9.Width*0.95,Pane9.Height*0.95)
    Pane10.AddNode(lc.buildGraph,Pane10.Width*0.025,Pane10.Height*0.025,Pane10.Width*0.95,Pane10.Height*0.95)
    Pane11.AddNode(mp.buildGraph,Pane11.Width*0.025,Pane11.Height*0.025,Pane11.Width*0.95,Pane11.Height*0.95)
    Pane12.AddNode(sp.buildGraph,Pane12.Width*0.025,Pane12.Height*0.025,Pane12.Width*0.95,Pane12.Height*0.95)
    Pane13.AddNode(rl.buildGraph,Pane13.Width*0.025,Pane13.Height*0.025,Pane13.Width*0.95,Pane13.Height*0.95)
    Pane14.AddNode(sc.buildGraph,Pane14.Width*0.025,Pane14.Height*0.025,Pane14.Width*0.95,Pane14.Height*0.95)
    Pane15.AddNode(mhm.buildGraph,Pane15.Width*0.025,Pane15.Height*0.025,Pane15.Width*0.95,Pane15.Height*0.95)
    Pane16.AddNode(ahm.buildGraph,Pane16.Width*0.025,Pane16.Height*0.025,Pane16.Width*0.95,Pane16.Height*0.95)
    Pane17.AddNode(logc.buildGraph,Pane17.Width*0.025,Pane17.Height*0.025,Pane17.Width*0.95,Pane17.Height*0.95)
    Pane18.AddNode(ta.buildGraph,Pane18.Width*0.025,Pane18.Height*0.025,Pane18.Width*0.95,Pane18.Height*0.95)
    Pane19.AddNode(hc.buildGraph,Pane19.Width*0.025,Pane19.Height*0.025,Pane19.Width*0.95,Pane19.Height*0.95)
    Pane20.AddNode(polar.buildGraph,Pane20.Width*0.025,Pane20.Height*0.025,Pane20.Width*0.95,Pane20.Height*0.95)

End Sub
 

Attachments

  • HansoloCharts.zip
    33.5 KB · Views: 209

Johan Schoeman

Expert
Licensed User
Longtime User
I thought that I would give the NestedBarChart a go using JavaObject rather than inline Java code. Attached my attempt. You still need the Jar referred to in post #1 (charts-11.2.jar).
Have added an event to it (SelectionEventListener). See the B4J logs when you click on the "summary bars" or the individual item bars.
Args(0) contains a JSON object when clicking on any of the "summary bars" or individual bars.
Can probably reduce the number of variables used in the code but have done it this way for now to try and make sense of using JavaObject and not inline Java code
I guess the code in the event can be simplified but best way I could figure it out for now:
B4J event:
Sub nbctouch_Event (MethodName As String, Args() As Object) As Object

    Dim errorCheck As String = Args(0)
    If errorCheck.Contains("eu.hansolo") Then     'ignore data in Args(0) if it starts with "eu.hansolo"
           'ignore the line containing "eu.hansolo"
    Else

        Dim s As String = Args(0)
        Log(s)
        Log(" ")
        Dim m As Map = s.As(JSON).ToMap           'Args(0) is a JSON object -> convert it to a Map
        Log(m.Get("series"))                      'get the "series name from the Map
        Log(m.Get("sum"))                         'Get the series sum from the Map
        Log(m.Get("item"))                        'Get the item clicked on from the Map
        Log(m.Get("value"))                       'get the value of the item clicked on from the Map
        Log(" ")
   
    End If

End Sub

....but you can now add as many items and series as what you want.


Sample Code:
B4J:
#Region Project Attributes
    #MainFormWidth: 1200
    #MainFormHeight: 800
#End Region

#AdditionalJar: charts-11.2
'#AdditionalJar: javafx-graphics-11
'#AdditionalJar: javafx-base-11


Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form

    Private Pane1 As Pane
   
    Dim chart As JavaObject
    Dim j As JSONParser

End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
   
    Dim matcolor As JavaObject
    matcolor.InitializeStatic("eu.hansolo.fx.charts.color.MaterialDesignColors")                     'public enum MaterialDesignColors implements Colors
   
    Dim col1 As JavaObject = matcolor.GetField("CYAN_700")                                           'get the RGB value of CYAN_700
    Dim col2 As JavaObject = matcolor.GetField("CYAN_500")
    Dim col3 As JavaObject = matcolor.GetField("CYAN_300")
    Dim col4 As JavaObject = matcolor.GetField("CYAN_100")
    Dim col5 As JavaObject = matcolor.GetField("CYAN_900")
   
    Dim col6 As JavaObject = matcolor.GetField("PURPLE_700")
    Dim col7 As JavaObject = matcolor.GetField("PURPLE_500")
    Dim col8 As JavaObject = matcolor.GetField("PURPLE_300")
    Dim col9 As JavaObject = matcolor.GetField("PURPLE_100")
    Dim col10 As JavaObject = matcolor.GetField("PURPLE_900")
   
    Dim col11 As JavaObject = matcolor.GetField("PINK_700")
    Dim col12 As JavaObject = matcolor.GetField("PINK_500")
    Dim col13 As JavaObject = matcolor.GetField("PINK_300")
    Dim col14 As JavaObject = matcolor.GetField("PINK_100")
    Dim col15 As JavaObject = matcolor.GetField("PINK_900")
   
    Dim col16 As JavaObject = matcolor.GetField("AMBER_700")
    Dim col17 As JavaObject = matcolor.GetField("AMBER_500")
    Dim col18 As JavaObject = matcolor.GetField("AMBER_300")
    Dim col19 As JavaObject = matcolor.GetField("AMBER_100")
    Dim col20 As JavaObject = matcolor.GetField("AMBER_900")


    Dim value1, value2, value3, value4 As Double                         'the values for each item need to be double
    value1 = 16.0                                                        'value for series 1, item 1
    value2 = 8.0                                                         'value for series 1, item 2
    value3 = 4.0                                                         'value for series 1, item 3
    value4 = 2.0                                                         'value for series 1, item 4

    Dim value5, value6, value7, value8 As Double
    value5 = 12.0                                                        'value for series 2, item 1
    value6 = 5.0                                                         'value for series 2, item 2
    value7 = 3.0                                                         'value for series 2, item 3
    value8 = 1.0                                                         'value for series 2, item 4

    Dim value9, value10, value11, value12 As Double
    value9 = 14.0                                                        'value for series 3, item 1
    value10 = 7.0                                                        'value for series 3, item 2
    value11 = 3.5                                                        'value for series 3, item 3
    value12 = 1.75                                                       'value for series 3, item 4

    Dim value13, value14, value15, value16 As Double
    value13 = 18.0                                                       'value for series 4, item 1
    value14 = 9.0                                                        'value for series 4, item 2
    value15 = 4.5                                                        'value for series 4, item 3
    value16 = 2.25                                                       'value for series 4, item 4
   
    Dim p1Q1, p2Q1, p3Q1, p4Q1 As JavaObject                             'we need to create ChartItems using an item description, item value, item color
    p1Q1.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Product 1", value1, col1.RunMethod("get", Null)))   '....col1.RunMethod("get", Null) - the rgb value of CYAN_700
    p2Q1.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Product 2", value2, col2.RunMethod("get", Null)))
    p3Q1.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Product 3", value3, col3.RunMethod("get", Null)))
    p4Q1.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Product 4", value4, col4.RunMethod("get", Null)))
   
    Dim p1Q2, p2Q2, p3Q2, p4Q2 As JavaObject
    p1Q2.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Product 1", value5, col6.RunMethod("get", Null)))
    p2Q2.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Product 2", value6, col7.RunMethod("get", Null)))
    p3Q2.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Product 3", value7, col8.RunMethod("get", Null)))
    p4Q2.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Product 4", value8, col9.RunMethod("get", Null)))

    Dim p1Q3, p2Q3, p3Q3, p4Q3 As JavaObject
    p1Q3.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Product 1", value9, col11.RunMethod("get", Null)))
    p2Q3.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Product 2", value10, col12.RunMethod("get", Null)))
    p3Q3.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Product 3", value11, col13.RunMethod("get", Null)))
    p4Q3.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Product 4", value12, col14.RunMethod("get", Null)))

    Dim p1Q4, p2Q4, p3Q4, p4Q4 As JavaObject
    p1Q4.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Product 1", value13, col16.RunMethod("get", Null)))
    p2Q4.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Product 2", value14, col17.RunMethod("get", Null)))
    p3Q4.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Product 3", value15, col18.RunMethod("get", Null)))
    p4Q4.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Product 4", value16, col19.RunMethod("get", Null)))
   
   
    Dim chartType As JavaObject                                                'we are gouning to select the type of chart i.e NESTED_BAR in this case
    chartType.InitializeStatic("eu.hansolo.fx.charts.ChartType")
    chartType.GetField("NESTED_BAR")                                           'get the type of chart from the Enum class (public enum ChartType)
   
    Dim l1, l2, l3, l4 As List                                                 'we need to pass lists of ChartItems to ChartItemSeries
    l1.Initialize
    l1.Add(p1Q1)
    l1.Add(p2Q1)
    l1.Add(p3Q1)
    l1.Add(p4Q1)
   
    l2.Initialize
    l2.Add(p1Q2)
    l2.Add(p2Q2)
    l2.Add(p3Q2)
    l2.Add(p4Q2)
   
    l3.Initialize
    l3.Add(p1Q3)
    l3.Add(p2Q3)
    l3.Add(p3Q3)
    l3.Add(p4Q3)
   
    l4.Initialize
    l4.Add(p1Q4)
    l4.Add(p2Q4)
    l4.Add(p3Q4)
    l4.Add(p4Q4)
   
    Dim q1, q2, q3, q4 As JavaObject                     'going to initialize new ChartItemSeries using JavaObject
    q1.InitializeNewInstance("eu.hansolo.fx.charts.series.ChartItemSeries", Array(l1, chartType.GetField("NESTED_BAR"), "1st Quarter", col5.RunMethod("get", Null), fx.Colors.TRANSPARENT))
    q2.InitializeNewInstance("eu.hansolo.fx.charts.series.ChartItemSeries", Array(l2, chartType.GetField("NESTED_BAR"), "2nd Quarter", col10.RunMethod("get", Null), fx.Colors.TRANSPARENT))
    q3.InitializeNewInstance("eu.hansolo.fx.charts.series.ChartItemSeries", Array(l3, chartType.GetField("NESTED_BAR"), "3rd Quarter", col15.RunMethod("get", Null), fx.Colors.TRANSPARENT))
    q4.InitializeNewInstance("eu.hansolo.fx.charts.series.ChartItemSeries", Array(l4, chartType.GetField("NESTED_BAR"), "4th Quarter", col20.RunMethod("get", Null), fx.Colors.TRANSPARENT))


   
    Dim chartlist As List                       'we need to pass a list of ChartItemSeries to the constructor of NestedBarChart
    chartlist.Initialize                        'initialize and empty list
    chartlist.Add(q1)                           'add the 1st ChartItemSeries to the list
    chartlist.Add(q2)                           'add the 2nd ChartItemSeries to the list
    chartlist.Add(q3)                           'add the 3rd ChartItemSeries to the list
    chartlist.Add(q4)                           'add the 4th ChartItemSeries to the list
    chart.InitializeNewInstance("eu.hansolo.fx.charts.NestedBarChart", Array(chartlist))                            'initialize a new instance of the NestedBarChart
   
    Dim e As JavaObject = chart.createEvent("eu.hansolo.fx.charts.event.SelectionEventListener","nbctouch", False)  'create a SelectionEventListener
    chart.RunMethod("setOnSelectionEvent", Array As Object(e))                                                      'run method setOnSelectionEvent in NestedBarChart                                                    '
   

    'add the chart to Pane1
    Pane1.AddNode(chart,Pane1.Width*0.025,Pane1.Height*0.025,Pane1.Width*0.95,Pane1.Height*0.95)
   
End Sub

Sub nbctouch_Event (MethodName As String, Args() As Object) As Object

    Dim errorCheck As String = Args(0)
    If errorCheck.Contains("eu.hansolo") Then     'ignore data in Args(0) if it starts with "eu.hansolo"
           'ignore the line containing "eu.hansolo"
    Else

        Dim s As String = Args(0)
        Log(s)
        Log(" ")
        Dim m As Map = s.As(JSON).ToMap           'Args(0) is a JSON object -> convert it to a Map
        Log(m.Get("series"))                      'get the "series nme from the Map
        Log(m.Get("sum"))                         'Get the series sum from the Map
        Log(m.Get("item"))                        'Get the item clicked on from the Map
        Log(m.Get("value"))                       'get the value of the itme clicked on from the Map
        Log(" ")
   
    End If

End Sub

See attached MaterialDesignColors.zip for MaterialDesignColors that are available to choose from.

1668246316173.png
 

Attachments

  • HansoloNestedBarChart.zip
    3.5 KB · Views: 195
  • MaterialDesignColors.zip
    6.5 KB · Views: 195

Johan Schoeman

Expert
Licensed User
Longtime User
Here is the Hansolo AreaHeatMap using JavaObject in place of inline Java code:

areaHeatMap.gif

Sample code:
AreaHeatMap:
#Region Project Attributes
    #MainFormWidth: 1200
    #MainFormHeight: 800
#End Region

#AdditionalJar: charts-11.2
'#AdditionalJar: javafx-graphics-11
'#AdditionalJar: javafx-base-11


Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form

    Private Pane1 As Pane
    
    Dim chart As JavaObject
    Dim dataPoints As JavaObject
    Dim val1, val2, val3 As Double
    Dim dataPointList As List
    
    
    Dim t As Timer

End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    t.Initialize("t", 1000)
    
    dataPointList.Initialize
    
    For i = 0 To 24
        val1 = Rnd(0, 501)
        val2 = Rnd(0, 501)
        val3 = Rnd(0, 501)
        dataPointList.add(dataPoints.InitializeNewInstance("eu.hansolo.fx.charts.data.DataPoint", Array(val1, val2, val3)))
    Next

    Dim areaHeatMapBuilder As JavaObject
    Dim width As Double  = 400.0
    Dim height As Double = 400.0
    Dim colorMapping As JavaObject
    colorMapping.InitializeStatic("eu.hansolo.fx.charts.tools.ColorMapping")
    
    Dim color As JavaObject = colorMapping.GetField("BLUE_CYAN_GREEN_YELLOW_RED")
    
    Dim qual As JavaObject
    qual.InitializeStatic("eu.hansolo.fx.charts.areaheatmap.AreaHeatMap.Quality")
    Dim quality As JavaObject = qual.GetField("FINE")
        
    areaHeatMapBuilder.InitializeStatic("eu.hansolo.fx.charts.areaheatmap.AreaHeatMapBuilder")
    chart = areaHeatMapBuilder.RunMethodJO("create", Null) _
                              .RunMethodJO("prefSize", Array(width, height)) _
                              .RunMethodJO("colorMapping", Array(color)) _
                              .RunMethodJO("dataPoints", Array(dataPointList)) _
                              .RunMethodJO("heatMapOpacity", Array(0.5)) _
                              .RunMethodJO("useColorMapping", Array(True)) _
                              .RunMethodJO("dataPointsVisible", Array(True)) _
                              .RunMethodJO("noOfCloserInfluentPoints", Array(5)) _
                              .RunMethodJO("quality", Array(quality)) _
                              .RunMethodJO("build", Null)

    'add the chart to Pane1
    Pane1.AddNode(chart,Pane1.Width*0.025,Pane1.Height*0.025,Pane1.Width*0.95,Pane1.Height*0.95)
    
    t.Enabled = True
    
End Sub


Sub t_tick
    
    dataPointList.Clear
    
    For i = 0 To 24
        val1 = Rnd(0, 501)
        val2 = Rnd(0, 501)
        val3 = Rnd(0, 501)
        dataPointList.add(dataPoints.InitializeNewInstance("eu.hansolo.fx.charts.data.DataPoint", Array(val1, val2, val3)))
    Next
    
    chart.RunMethod("setDataPoints", Array(dataPointList))
    
    
End Sub
 

Attachments

  • HansoloAreaHeatMap.zip
    2.3 KB · Views: 180

Johan Schoeman

Expert
Licensed User
Longtime User
Hansolo FairPlayChart using mostly JavaObject and a bit of inline Java code (change it to your liking):

FairPlayChart.gif


sample code:

Hansolo PlayFairChart:
#Region Project Attributes
    #MainFormWidth: 1200
    #MainFormHeight: 800
#End Region

#AdditionalJar: charts-11.2
'#AdditionalJar: javafx-graphics-11
'#AdditionalJar: javafx-base-11


Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form

    Private Pane1 As Pane
    
    Dim chart As JavaObject
    
    Dim NO_OF_X_VALUES As Double = 5
    Dim AXIS_WIDTH As Double  = 25
    
    Dim xySeries1, xySeries2 As JavaObject
    
    Dim tmr As Timer
    Dim nativeMe As JavaObject
    
    
    
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    nativeMe = Me
        
    tmr.Initialize("tmr", 1000)
    
    Dim chartType As JavaObject
    chartType.InitializeStatic("eu.hansolo.fx.charts.ChartType")

    Dim xyData1, xyData2 As List
    xyData1.Initialize
    xyData2.Initialize
    
    Dim xyChartItem As JavaObject
    xyData1.Add(xyChartItem.InitializeNewInstance("eu.hansolo.fx.charts.data.XYChartItem", Array(0.0, 12.0, "P0")))
    xyData1.add(xyChartItem.InitializeNewInstance("eu.hansolo.fx.charts.data.XYChartItem", Array(1.0, 7.0, "P1")))
    xyData1.Add(xyChartItem.InitializeNewInstance("eu.hansolo.fx.charts.data.XYChartItem", Array(2.0, 9.0, "P2")))
    xyData1.Add(xyChartItem.InitializeNewInstance("eu.hansolo.fx.charts.data.XYChartItem", Array(3.0, 3.0, "P3")))
    xyData1.Add(xyChartItem.InitializeNewInstance("eu.hansolo.fx.charts.data.XYChartItem", Array(4.0, 5.0, "P4")))
    xyData1.Add(xyChartItem.InitializeNewInstance("eu.hansolo.fx.charts.data.XYChartItem", Array(5.0, 4.0, "P5")))
    
    xyData2.Add(xyChartItem.InitializeNewInstance("eu.hansolo.fx.charts.data.XYChartItem", Array(0.0, 5.0, "P0")))
    xyData2.add(xyChartItem.InitializeNewInstance("eu.hansolo.fx.charts.data.XYChartItem", Array(1.0, 9.0, "P1")))
    xyData2.Add(xyChartItem.InitializeNewInstance("eu.hansolo.fx.charts.data.XYChartItem", Array(2.0, 5.0, "P2")))
    xyData2.Add(xyChartItem.InitializeNewInstance("eu.hansolo.fx.charts.data.XYChartItem", Array(3.0, 4.0, "P3")))
    xyData2.Add(xyChartItem.InitializeNewInstance("eu.hansolo.fx.charts.data.XYChartItem", Array(4.0, 7.0, "P4")))
    xyData2.Add(xyChartItem.InitializeNewInstance("eu.hansolo.fx.charts.data.XYChartItem", Array(5.0, 5.0, "P5")))
    
    
    xySeries1.InitializeNewInstance("eu.hansolo.fx.charts.series.XYSeries", Array(xyData1, chartType.GetField("SMOOTH_LINE_DELTA"), True))
    xySeries2.InitializeNewInstance("eu.hansolo.fx.charts.series.XYSeries", Array(xyData2, chartType.GetField("SMOOTH_LINE_DELTA"), True))


    Dim symbol1FillColor, symbol2FillColor As JavaObject
    Dim symbolFillColor As JavaObject
    symbolFillColor.InitializeStatic("javafx.scene.paint.Color")
    
    symbol1FillColor = symbolFillColor.RunMethod("rgb", Array(0, 200, 0))
    xySeries1.RunMethod("setSymbolFill", Array(symbol1FillColor))
    xySeries1.RunMethod("setSymbolStroke", Array(symbol1FillColor.RunMethod("darker", Null)))

    symbol2FillColor = symbolFillColor.RunMethod("rgb", Array(200, 0, 0))
    xySeries2.RunMethod("setSymbolFill", Array(symbol2FillColor))
    xySeries2.RunMethod("setSymbolStroke", Array(symbol2FillColor.RunMethod("darker", Null)))


    xySeries1.RunMethod("setStroke", Array(symbol1FillColor))
    xySeries2.RunMethod("setStroke", Array(symbol2FillColor))
    
    Dim gradientColor As JavaObject
    
    Dim gradSeries1ColorStart, gradSeries2ColorStart As JavaObject
    Dim gradSeries1ColorStop, gradSeries2ColorStop As JavaObject
    gradientColor.InitializeStatic("javafx.scene.paint.Color")
    gradSeries1ColorStart = gradientColor.RunMethod("rgb", Array(0, 200, 0, 0.75))
    gradSeries1ColorStop = gradientColor.RunMethod("rgb", Array(0, 200, 0, 0.25))
    
    Dim cycleMethod As JavaObject
    cycleMethod.InitializeStatic("javafx.scene.paint.CycleMethod")
    Dim stp1, stp2 As JavaObject
    stp1.InitializeNewInstance("javafx.scene.paint.Stop", Array(0.0, gradSeries1ColorStart))
    stp2.InitializeNewInstance("javafx.scene.paint.Stop", Array(1.0, gradSeries1ColorStop))

    Dim l, t, w, h As Double
    l = 0
    t = 0
    w = 0
    h = 1
    
    Dim stparray As JavaObject
    stparray.InitializeArray("javafx.scene.paint.Stop", Array(stp1, stp2))
    Dim linearGradient As JavaObject
    linearGradient.InitializeNewInstance("javafx.scene.paint.LinearGradient", Array(l, t, w, h, True, cycleMethod.GetField("NO_CYCLE"), stparray))
    xySeries1.RunMethod("setFill", Array(linearGradient))

    gradSeries2ColorStart = gradientColor.RunMethod("rgb", Array(200, 0, 0, 0.75))
    gradSeries2ColorStop = gradientColor.RunMethod("rgb", Array(200, 0, 0, 0.25))
    
    stp1.InitializeNewInstance("javafx.scene.paint.Stop", Array(0.0, gradSeries2ColorStart))
    stp2.InitializeNewInstance("javafx.scene.paint.Stop", Array(1.0, gradSeries2ColorStop))
    
    stparray.InitializeArray("javafx.scene.paint.Stop", Array(stp1, stp2))
    linearGradient.InitializeNewInstance("javafx.scene.paint.LinearGradient", Array(l, t, w, h, True, cycleMethod.GetField("NO_CYCLE"), stparray))
    xySeries2.RunMethod("setFill", Array(linearGradient))

    Dim axisBottom As JavaObject
    Dim minimum As Double = 0.0
    Dim autoScale As Boolean = True
    axisBottom = createBottomAxis(minimum, NO_OF_X_VALUES, autoScale)

    Dim decimals As Int = 1
    axisBottom.RunMethod("setDecimals", Array(decimals))
    
    Dim axisLeft As JavaObject
    axisLeft = createLeftAxis(minimum - 10.0, 20.0, autoScale)
    
    Dim xyPane As JavaObject
    
    Dim xyseriesobject As JavaObject
    xyseriesobject.InitializeArray("eu.hansolo.fx.charts.series.XYSeries", Array(xySeries1,xySeries2))

    xyPane.InitializeNewInstance("eu.hansolo.fx.charts.XYPane", Array(xyseriesobject))
    
    Dim axisarrayobject As JavaObject
    axisarrayobject.InitializeArray("eu.hansolo.fx.charts.Axis", Array(axisLeft,axisBottom))

    chart.InitializeNewInstance("eu.hansolo.fx.charts.XYChart", Array(xyPane, axisarrayobject))
    
    Dim grid As JavaObject
    grid.InitializeNewInstance("eu.hansolo.fx.charts.Grid", Array(axisBottom,axisLeft))

    chart.RunMethod("setGrid", Array(grid))

    Pane1.AddNode(chart,Pane1.Width*0.025,Pane1.Height*0.025,Pane1.Width*0.95,Pane1.Height*0.95)
    tmr.Enabled = True
    
End Sub


Sub createLeftAxis (minimum As Double, maximum As Double, autoScale As Boolean) As JavaObject
    
    Dim orientation As JavaObject
    orientation.InitializeStatic("javafx.geometry.Orientation")
    Dim position As JavaObject
    position.InitializeStatic("eu.hansolo.fx.charts.Position")
    
    Dim axisLeft As JavaObject
    axisLeft.InitializeNewInstance("eu.hansolo.fx.charts.Axis", Array(orientation.GetField("VERTICAL"), position.GetField("LEFT")))
    
    axisLeft.RunMethod("setMinValue", Array(minimum))
    axisLeft.RunMethod("setMaxValue", Array(maximum))
    axisLeft.RunMethod("setPrefWidth", Array(AXIS_WIDTH))
    axisLeft.RunMethod("setAutoScale", Array(autoScale))
    
    Dim anchorPane As JavaObject
    anchorPane.InitializeStatic("javafx.scene.layout.AnchorPane")
    anchorPane.RunMethod("setTopAnchor", Array(axisLeft, 0.0))
    anchorPane.RunMethod("setBottomAnchor", Array(axisLeft, 25.0))
    anchorPane.RunMethod("setLeftAnchor", Array(axisLeft, 0.0))

    Return axisLeft
    
End Sub


Sub createBottomAxis (minimum As Double, maximum As Double, autoScale As Boolean) As JavaObject
    
    Dim orientation As JavaObject
    orientation.InitializeStatic("javafx.geometry.Orientation")
    Dim position As JavaObject
    position.InitializeStatic("eu.hansolo.fx.charts.Position")
    
    Dim axisBottom As JavaObject
    axisBottom.InitializeNewInstance("eu.hansolo.fx.charts.Axis", Array(orientation.GetField("HORIZONTAL"), position.GetField("BOTTOM")))
    
    axisBottom.RunMethod("setMinValue", Array(minimum))
    axisBottom.RunMethod("setMaxValue", Array(maximum))
    axisBottom.RunMethod("setPrefHeight", Array(AXIS_WIDTH))
    axisBottom.RunMethod("setAutoScale", Array(autoScale))
    
    Dim anchorPane As JavaObject
    anchorPane.InitializeStatic("javafx.scene.layout.AnchorPane")
    anchorPane.RunMethod("setBottomAnchor", Array(axisBottom, 0.0))
    anchorPane.RunMethod("setLeftAnchor", Array(axisBottom, 25.0))
    anchorPane.RunMethod("setRightAnchor", Array(axisBottom, 25.0))

    Return axisBottom
    
End Sub


Sub tmr_tick
    
    nativeMe.RunMethod("setData", Array(xySeries1, xySeries2))

End Sub

#if Java

import javafx.collections.ObservableList;
import eu.hansolo.fx.charts.data.XYChartItem;
import eu.hansolo.fx.charts.series.XYSeries;
import java.util.Random;

private static final Random  RND = new Random();

    public static void setData(XYSeries xySeries1, XYSeries xySeries2) {
        ObservableList<XYChartItem> xyItems = xySeries1.getItems();
        xyItems.forEach(item -> item.setY(RND.nextDouble() * 20));

        xyItems = xySeries2.getItems();
        xyItems.forEach(item -> item.setY(RND.nextDouble() * 15));

        xySeries1.refresh();
        xySeries2.refresh();
    }

#End If
 

Attachments

  • HansoloPlayFairChart.zip
    3.4 KB · Views: 181

Johan Schoeman

Expert
Licensed User
Longtime User
Hansolo LineChart using JavaObject (change it to your liking):

linechart.png


Sample Code:

Hansolo LineChart:
#Region Project Attributes
    #MainFormWidth: 1200
    #MainFormHeight: 800
#End Region

#AdditionalJar: charts-11.2
'#AdditionalJar: javafx-graphics-11
'#AdditionalJar: javafx-base-11


Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form

    Private Pane1 As Pane
    
    Dim chart As JavaObject

    Dim xyChartItemList1, xyChartItemList2 As List
    Dim xyChartItem As JavaObject
    
    Dim xAxisBottom, xAxisBottomBuilder As JavaObject
    Dim axisType As JavaObject
    Dim orientation As JavaObject
    Dim position As JavaObject
    Dim axisColor As JavaObject
    Dim chartType As JavaObject
    Dim xySeries1, xySeries2 As JavaObject
    Dim xySeriesBuilder As JavaObject
    Dim prefHeight As Double = 25
    Dim prefWidth As Double = 25
    Dim axisWidth As Double = 25


End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    
    xyChartItemList1.Initialize
    xyChartItemList2.Initialize

    axisType.InitializeStatic("eu.hansolo.fx.charts.AxisType")
    orientation.InitializeStatic("javafx.geometry.Orientation")
    position.InitializeStatic("eu.hansolo.fx.charts.Position")
    chartType.InitializeStatic("eu.hansolo.fx.charts.ChartType")

    
    Dim number() As Double = Array As Double(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
    Dim description() As String = Array As String("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
    Dim value() As Double = Array As Double(600, 760, 585, 410, 605, 825, 595, 300, 515, 780, 570, 620)
    
    addXYChartItem(number, description, value, xyChartItemList1)

    Dim number() As Double = Array As Double(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
    Dim description() As String = Array As String("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
    Dim value() As Double = Array As Double(700, 860, 685, 510, 705, 925, 695, 400, 615, 880, 670, 720)

    addXYChartItem(number, description, value, xyChartItemList2)



    Dim fillColor As JavaObject
    fillColor.InitializeStatic("javafx.scene.paint.Color")
    Dim stringFillColor1 As String = "#00AEF520"
    
    Dim strokeColor As JavaObject
    strokeColor.InitializeStatic("javafx.scene.paint.Color")
    Dim stringStrokeColor1 As String = "#00AEF5"
    
    Dim symbolStrokeColor As JavaObject
    symbolStrokeColor.InitializeStatic("javafx.scene.paint.Color")
    Dim stringSymbolStrokeColor1 As String = "#293C47"
    
    Dim symbolSize As Double = 10
    Dim strokeWidth As Double = 3
    
    
    xySeriesBuilder.InitializeStatic("eu.hansolo.fx.charts.series.XYSeriesBuilder")
    
    xySeries1.InitializeNewInstance("eu.hansolo.fx.charts.series.XYSeries", Null)
    xySeries2.InitializeNewInstance("eu.hansolo.fx.charts.series.XYSeries", Null)
    
    xySeries1 = xySeriesBuilder.RunMethodJO("create", Null) _
                               .RunMethodJO("items", Array(xyChartItemList1)) _
                               .RunMethodJO("chartType", Array(chartType.GetField("SMOOTH_AREA"))) _
                               .RunMethodJO("fill", Array(fillColor.RunMethod("web", Array(stringFillColor1)))) _
                               .RunMethodJO("stroke", Array(strokeColor.RunMethod("web", Array(stringStrokeColor1)))) _
                               .RunMethodJO("symbolFill", Array(strokeColor.RunMethod("web", Array(stringStrokeColor1)))) _
                               .RunMethodJO("symbolStroke", Array(symbolStrokeColor.RunMethod("web", Array(stringSymbolStrokeColor1)))) _                               
                               .RunMethodJO("symbolSize", Array(symbolSize)) _
                               .RunMethodJO("strokeWidth", Array(strokeWidth)) _
                               .RunMethodJO("symbolsVisible", Array(True)) _
                               .RunMethodJO("build", Null)
                              
    
    Dim stringFillColor2 As String = "#00BEF520"
    
    Dim stringStrokeColor2 As String= "#00FEF5"
    
    Dim stringSymbolStrokeColor2 As String = "#593C47"
                              
    xySeries2 = xySeriesBuilder.RunMethodJO("create", Null) _
                               .RunMethodJO("items", Array(xyChartItemList2)) _
                               .RunMethodJO("chartType", Array(chartType.GetField("SMOOTH_AREA"))) _
                               .RunMethodJO("fill", Array(fillColor.RunMethod("web", Array(stringFillColor2)))) _
                               .RunMethodJO("stroke", Array(strokeColor.RunMethod("web", Array(stringStrokeColor2)))) _
                               .RunMethodJO("symbolFill", Array(strokeColor.RunMethod("web", Array(stringStrokeColor2)))) _
                               .RunMethodJO("symbolStroke", Array(symbolStrokeColor.RunMethod("web", Array(stringSymbolStrokeColor2)))) _                               
                               .RunMethodJO("symbolSize", Array(symbolSize)) _
                               .RunMethodJO("strokeWidth", Array(strokeWidth)) _
                               .RunMethodJO("symbolsVisible", Array(True)) _
                               .RunMethodJO("build", Null)                               
                              
    


    xAxisBottom.InitializeNewInstance("eu.hansolo.fx.charts.Axis", Null)
    xAxisBottomBuilder.InitializeStatic("eu.hansolo.fx.charts.AxisBuilder")

    

    


    
    Dim categories As List
    categories.Initialize
    categories.AddAll(Array As String("","Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))
    Dim minvalue As Double = 1
    Dim maxvalue As Double = 13
    


    axisColor.InitializeStatic("javafx.scene.paint.Color")
    Dim stringAxisColor As String = "#85949B"
    
    Dim tickLabelColor As JavaObject
    tickLabelColor.InitializeStatic("javafx.scene.paint.Color")
    Dim stringTickLabelColor As String = "#85949B"
    
    Dim tickMarkColor As JavaObject
    tickMarkColor.InitializeStatic("javafx.scene.paint.Color")
    Dim stringTickMarkColor As String = "#85949B"


    xAxisBottom = xAxisBottomBuilder.RunMethodJO("create", Array(orientation.GetField("HORIZONTAL"), position.GetField("BOTTOM"))) _
                             .RunMethodJO("type", Array(axisType.GetField("TEXT"))) _
                             .RunMethodJO("prefHeight", Array(prefHeight)) _
                             .RunMethodJO("categories", Array(categories)) _
                             .RunMethodJO("minValue", Array(minvalue)) _
                             .RunMethodJO("maxValue", Array(maxvalue)) _
                             .RunMethodJO("autoScale", Array(True)) _
                             .RunMethodJO("axisColor", Array(strokeColor.RunMethod("web", Array(stringAxisColor)))) _
                             .RunMethodJO("tickLabelColor", Array(strokeColor.RunMethod("web", Array(stringTickLabelColor)))) _
                             .RunMethodJO("tickMarkColor", Array(strokeColor.RunMethod("web", Array(stringTickMarkColor)))) _
                             .RunMethodJO("build", Null)
    
    
    Dim anchorPane As JavaObject
    anchorPane.InitializeStatic("javafx.scene.layout.AnchorPane")
    anchorPane.RunMethod("setBottomAnchor", Array(xAxisBottom, 0.0))
    anchorPane.RunMethod("setLeftAnchor", Array(xAxisBottom, axisWidth))
    anchorPane.RunMethod("setRightAnchor", Array(xAxisBottom, axisWidth))
    
    Dim yAxisLeft, yAxisLeftBuilder As JavaObject
    yAxisLeft.InitializeNewInstance("eu.hansolo.fx.charts.Axis", Null)
    yAxisLeftBuilder.InitializeStatic("eu.hansolo.fx.charts.AxisBuilder")

    yAxisLeft = yAxisLeftBuilder.RunMethodJO("create", Array(orientation.GetField("VERTICAL"), position.GetField("LEFT"))) _
                                .RunMethodJO("type", Array(axisType.GetField("LINEAR"))) _
                                .RunMethodJO("prefWidth", Array(prefWidth)) _
                                .RunMethodJO("minValue", Array(0.0)) _
                                .RunMethodJO("maxValue", Array(1000.0)) _
                                .RunMethodJO("autoScale", Array(True)) _
                                .RunMethodJO("axisColor", Array(strokeColor.RunMethod("web", Array(stringAxisColor)))) _
                                .RunMethodJO("tickLabelColor", Array(strokeColor.RunMethod("web", Array(stringTickLabelColor)))) _
                                .RunMethodJO("tickMarkColor", Array(strokeColor.RunMethod("web", Array(stringTickMarkColor)))) _
                                .RunMethodJO("build", Null)
            
    anchorPane.RunMethod("setTopAnchor", Array(yAxisLeft, 0.0))
    anchorPane.RunMethod("setBottomAnchor", Array(yAxisLeft, axisWidth))
    anchorPane.RunMethod("setLeftAnchor", Array(yAxisLeft, 0.0))
    
    Dim grid, gridBuilder As JavaObject
    grid.Initializestatic("eu.hansolo.fx.charts.Grid")
    gridBuilder.InitializeStatic("eu.hansolo.fx.charts.GridBuilder")
    
    Dim gridLinePaintColor As JavaObject
    gridLinePaintColor.InitializeStatic("javafx.scene.paint.Color")
    Dim stringGridLinePaintColor As String = "#384C57"
    
    Dim gridLineDashes(2) As Double
    gridLineDashes(0) = 4
    gridLineDashes(1) = 4
    
    
    grid = gridBuilder.RunMethodJO("create", Array(xAxisBottom, yAxisLeft)) _
                      .RunMethodJO("gridLinePaint", Array(gridLinePaintColor.RunMethod("web", Array(stringGridLinePaintColor)))) _
                      .RunMethodJO("minorHGridLinesVisible", Array(False)) _
                      .RunMethodJO("mediumHGridLinesVisible", Array(False)) _
                      .RunMethodJO("minorVGridLinesVisible", Array(False)) _
                      .RunMethodJO("mediumVGridLinesVisible", Array(False)) _
                      .RunMethodJO("gridLineDashes", Array(gridLineDashes)) _
                      .RunMethodJO("build", Null)
    
    Dim javaobjectarray As JavaObject
    javaobjectarray.InitializeArray("eu.hansolo.fx.charts.series.XYSeries", Array(xySeries1, xySeries2))
    Dim lineChartPane As JavaObject
    lineChartPane.InitializeNewInstance("eu.hansolo.fx.charts.XYPane", Array(javaobjectarray))
    
    Dim axisjavaobject As JavaObject
    axisjavaobject.InitializeArray("eu.hansolo.fx.charts.Axis", Array(yAxisLeft, xAxisBottom))
    
    chart.InitializeNewInstance("eu.hansolo.fx.charts.XYChart", Array(lineChartPane, grid, axisjavaobject))
    
    'add the chart to Pane1
    Pane1.AddNode(chart,Pane1.Width*0.025,Pane1.Height*0.025,Pane1.Width*0.95,Pane1.Height*0.95)
    
    

End Sub


Sub addXYChartItem(number() As Double, description() As String, value() As Double, xyChartItemList As List)

    For i = 0 To number.Length - 1
 
        xyChartItemList.add(xyChartItem.InitializeNewInstance("eu.hansolo.fx.charts.data.XYChartItem", Array(number(i), value(i), description(i))))

    Next

End Sub
 

Attachments

  • HansoloLineChart.zip
    3.4 KB · Views: 161

Johan Schoeman

Expert
Licensed User
Longtime User
Hansolo ConcentricRingChart using JavaObject (change it to your liking):

ConcentricRingChart.gif


Sample Code:

B4J Sample Code:
#Region Project Attributes
    #MainFormWidth: 1200
    #MainFormHeight: 800
#End Region

#AdditionalJar: charts-11.2
'#AdditionalJar: javafx-graphics-11
'#AdditionalJar: javafx-base-11


Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form

    Private Pane1 As Pane
  
    Dim chart As JavaObject
    Dim chartData1, chartData2, chartData3, chartData4, chartData5, chartData6, chartData7, chartData8 As JavaObject
  
    Dim newval As Double
  
    Dim t As Timer
  
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
  
    t.Initialize("t", 1000)

    chartData1.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Null)
    chartData2.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Null)
    chartData3.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Null)
    chartData4.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Null)
    chartData5.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Null)
    chartData6.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Null)
    chartData7.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Null)
    chartData8.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Null)
  
    Dim chartItemBuilder As JavaObject
    chartItemBuilder.InitializeStatic("eu.hansolo.fx.charts.data.ChartItemBuilder")
      
    chartData1 = chartItemBuilder.RunMethodJO("create", Null).RunMethodJO("name", Array("Item 1")).RunMethodJO("fill", Array(fx.Colors.RGB(0x35, 0x52, 0xa0))).RunMethodJO("textFill", Array(fx.Colors.White)).RunMethodJO("animated", Array(True)).RunMethodJO("build",Null)
    chartData2 = chartItemBuilder.RunMethodJO("create", Null).RunMethodJO("name", Array("Item 2")).RunMethodJO("fill", Array(fx.Colors.RGB(0x45, 0xa1, 0xcf))).RunMethodJO("textFill", Array(fx.Colors.White)).RunMethodJO("animated", Array(True)).RunMethodJO("build",Null)
    chartData3 = chartItemBuilder.RunMethodJO("create", Null).RunMethodJO("name", Array("Item 3")).RunMethodJO("fill", Array(fx.Colors.RGB(0x45, 0xcf, 0x6d))).RunMethodJO("textFill", Array(fx.Colors.White)).RunMethodJO("animated", Array(True)).RunMethodJO("build",Null)
    chartData4 = chartItemBuilder.RunMethodJO("create", Null).RunMethodJO("name", Array("Item 4")).RunMethodJO("fill", Array(fx.Colors.RGB(0xe3, 0xeb, 0x4f))).RunMethodJO("textFill", Array(fx.Colors.Black)).RunMethodJO("animated", Array(True)).RunMethodJO("build",Null)
    chartData5 = chartItemBuilder.RunMethodJO("create", Null).RunMethodJO("name", Array("Item 5")).RunMethodJO("fill", Array(fx.Colors.RGB(0xef, 0xb7, 0x50))).RunMethodJO("textFill", Array(fx.Colors.White)).RunMethodJO("animated", Array(True)).RunMethodJO("build",Null)
    chartData6 = chartItemBuilder.RunMethodJO("create", Null).RunMethodJO("name", Array("Item 6")).RunMethodJO("fill", Array(fx.Colors.RGB(0xef, 0x98, 0x50))).RunMethodJO("textFill", Array(fx.Colors.White)).RunMethodJO("animated", Array(True)).RunMethodJO("build",Null)
    chartData7 = chartItemBuilder.RunMethodJO("create", Null).RunMethodJO("name", Array("Item 7")).RunMethodJO("fill", Array(fx.Colors.RGB(0xef, 0x60, 0x50))).RunMethodJO("textFill", Array(fx.Colors.White)).RunMethodJO("animated", Array(True)).RunMethodJO("build",Null)
    chartData8 = chartItemBuilder.RunMethodJO("create", Null).RunMethodJO("name", Array("Item 8")).RunMethodJO("fill", Array(fx.Colors.RGB(0xa5, 0x42, 0x37))).RunMethodJO("textFill", Array(fx.Colors.White)).RunMethodJO("animated", Array(True)).RunMethodJO("build",Null)
  
    Dim concentricRingChartBuilder As JavaObject
    concentricRingChartBuilder.InitializeStatic("eu.hansolo.fx.charts.ConcentricRingChartBuilder")
  
    Dim chartDataItems As JavaObject
    chartDataItems.InitializeArray("eu.hansolo.fx.charts.data.ChartItem", Array(chartData1, chartData2, chartData3, chartData4, chartData5, chartData6, chartData7, chartData8))

    Dim width, height As Double
    width = 400
    height = 400
  
    Dim order As JavaObject
    order.InitializeStatic("eu.hansolo.fx.charts.tools.Order")
  
    Dim numFormat As JavaObject
    numFormat.InitializeStatic("eu.hansolo.fx.charts.tools.NumberFormat")
  
    chart = concentricRingChartBuilder.RunMethodJO("create", Null) _
                                      .RunMethodJO("prefSize", Array(width, height)) _
                                      .RunMethodJO("items", Array(chartDataItems)) _
                                      .RunMethodJO("sorted", Array(False)) _
                                      .RunMethodJO("order", Array(order.GetField("DESCENDING"))) _
                                      .RunMethodJO("numberFormat", Array(numFormat.GetField("PERCENTAGE_1_DECIMAL"))) _
                                      .RunMethodJO("itemLabelFill", Array(fx.Colors.Black)) _
                                      .RunMethodJO("build", Null)

    Pane1.AddNode(chart,Pane1.Width*0.025,Pane1.Height*0.025,Pane1.Width*0.95,Pane1.Height*0.95)
  
    t.Enabled = True

End Sub

Sub t_tick
  
    newval = Rnd(0, 101)
    chartData1.RunMethod("setValue",Array(newval))
    newval = Rnd(0, 101)
    chartData2.RunMethod("setValue",Array(newval))
    newval = Rnd(0, 101)
    chartData3.RunMethod("setValue",Array(newval))
    newval = Rnd(0, 101)
    chartData4.RunMethod("setValue",Array(newval))
    newval = Rnd(0, 101)
    chartData5.RunMethod("setValue",Array(newval))
    newval = Rnd(0, 101)
    chartData6.RunMethod("setValue",Array(newval))
    newval = Rnd(0, 101)
    chartData7.RunMethod("setValue",Array(newval))
    newval = Rnd(0, 101)
    chartData8.RunMethod("setValue",Array(newval))
  
End Sub

Change this line:

B4X:
.RunMethodJO("numberFormat", Array(numFormat.GetField("FLOAT_2_DECIMALS"))) _

to one of the following that will suite your requirements:
B4X:
    NUMBER
    FLOAT_1_DECIMAL
    FLOAT_2_DECIMALS
    FLOAT
    PERCENTAGE
    PERCENTAGE_1_DECIMAL
 

Attachments

  • HansoloConcentricRingChart.zip
    2.6 KB · Views: 166
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
Hansolo ComparisonRingChart using JavaObject (change it to your liking):



ComparisonRingChart.gif


Sample Code:
B4J Sample Code:
#Region Project Attributes
    #MainFormWidth: 1200
    #MainFormHeight: 800
#End Region

#AdditionalJar: charts-11.2
'#AdditionalJar: javafx-graphics-11
'#AdditionalJar: javafx-base-11


Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form

    Private Pane1 As Pane
    
    Dim chart As JavaObject
    
    Dim chart1Data1, chart1Data2, chart1Data3, chart1Data4, chart1Data5, chart1Data6, chart1Data7, chart1Data8 As JavaObject
    Dim chart2Data1, chart2Data2, chart2Data3, chart2Data4, chart2Data5, chart2Data6, chart2Data7, chart2Data8 As JavaObject

    Dim t As Timer

End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    
    t.Initialize("t", 700)
    
    chart1Data1.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Item 1"))
    chart1Data2.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Item 2"))
    chart1Data3.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Item 3"))
    chart1Data4.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Item 4"))
    chart1Data5.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Item 5"))
    chart1Data6.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Item 6"))
    chart1Data7.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Item 7"))
    chart1Data8.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Item 8"))
    
    Dim chartDataItems1 As JavaObject
    chartDataItems1.InitializeArray("eu.hansolo.fx.charts.data.ChartItem", Array(chart1Data1, chart1Data2, chart1Data3, chart1Data4, chart1Data5, chart1Data6, chart1Data7, chart1Data8))
    
    Dim series1 As JavaObject
    series1.InitializeNewInstance("eu.hansolo.fx.charts.series.ChartItemSeries", Null)
    
    Dim chartItemSeriesBuilder As JavaObject
    chartItemSeriesBuilder.InitializeStatic("eu.hansolo.fx.charts.series.ChartItemSeriesBuilder")
    
    Dim animationDuration As Long = 1000
    series1 = chartItemSeriesBuilder.RunMethodJO("create", Null) _
                                    .RunMethodJO("name", Array("Series 1")) _
                                    .RunMethodJO("items", Array(chartDataItems1)) _
                                    .RunMethodJO("fill", Array(fx.Colors.RGB(0x2E, 0xDD, 0xAE))) _
                                    .RunMethodJO("textFill", Array(fx.Colors.White)) _
                                    .RunMethodJO("animated", Array(True)) _
                                    .RunMethodJO("animationDuration", Array(animationDuration)) _
                                    .RunMethodJO("build", Null)
                                    
    
    chart2Data1.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Item 1"))
    chart2Data2.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Item 2"))
    chart2Data3.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Item 3"))
    chart2Data4.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Item 4"))
    chart2Data5.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Item 5"))
    chart2Data6.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Item 6"))
    chart2Data7.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Item 7"))
    chart2Data8.InitializeNewInstance("eu.hansolo.fx.charts.data.ChartItem", Array("Item 8"))

    Dim chartDataItems2 As JavaObject
    chartDataItems2.InitializeArray("eu.hansolo.fx.charts.data.ChartItem", Array(chart2Data1, chart2Data2, chart2Data3, chart2Data4, chart2Data5, chart2Data6, chart2Data7, chart2Data8))
    
    Dim series2 As JavaObject
    series2.InitializeNewInstance("eu.hansolo.fx.charts.series.ChartItemSeries", Null)
    
    Dim chartItemSeriesBuilder As JavaObject
    chartItemSeriesBuilder.InitializeStatic("eu.hansolo.fx.charts.series.ChartItemSeriesBuilder")
    
    Dim animationDuration As Long = 500
    series2 = chartItemSeriesBuilder.RunMethodJO("create", Null) _
                                    .RunMethodJO("name", Array("Series 1")) _
                                    .RunMethodJO("items", Array(chartDataItems2)) _
                                    .RunMethodJO("fill", Array(fx.Colors.RGB(0x1A, 0x9F, 0xF9))) _
                                    .RunMethodJO("textFill", Array(fx.Colors.White)) _
                                    .RunMethodJO("animated", Array(True)) _
                                    .RunMethodJO("animationDuration", Array(animationDuration)) _
                                    .RunMethodJO("build", Null)


    Dim comparisonRingChartBuilder As JavaObject
    comparisonRingChartBuilder.InitializeStatic("eu.hansolo.fx.charts.ComparisonRingChartBuilder")
    
    
    Dim w, h As Double
    w = 400
    h = 400
    
    Dim order As JavaObject
    order.InitializeStatic("eu.hansolo.fx.charts.tools.Order")
    
    Dim nmbrFormat As JavaObject
    nmbrFormat.InitializeStatic("eu.hansolo.fx.charts.tools.NumberFormat")
        
    chart = comparisonRingChartBuilder.RunMethodJO("create", Array(series1, series2)) _
                                      .RunMethodJO("prefSize", Array(w,h)) _
                                      .RunMethodJO("sorted", Array(True)) _
                                      .RunMethodJO("numberFormat", Array(nmbrFormat.GetField("NUMBER"))) _
                                      .RunMethodJO("order", Array(order.GetField("DESCENDING"))) _
                                      .RunMethodJO("build", Null)
    '                 
    Pane1.AddNode(chart,Pane1.Width*0.025,Pane1.Height*0.025,Pane1.Width*0.95,Pane1.Height*0.95)
    
    t.Enabled = True


End Sub


Sub t_tick
    
    Dim num As JavaObject
    num.InitializeNewInstance("java.util.Random", Null)
    
    Dim value As Double = 0
    
    value = num.RunMethod("nextDouble", Null)
    value = value * 20
    chart1Data1.RunMethod("setValue", Array(value))
    value = num.RunMethod("nextDouble", Null)
    value = value * 20
    chart1Data2.RunMethod("setValue", Array(value))
    value = num.RunMethod("nextDouble", Null)
    value = value * 20
    chart1Data3.RunMethod("setValue", Array(value))
    value = num.RunMethod("nextDouble", Null)
    value = value * 20
    chart1Data4.RunMethod("setValue", Array(value))
    value = num.RunMethod("nextDouble", Null)
    value = value * 20
    chart1Data5.RunMethod("setValue", Array(value))
    value = num.RunMethod("nextDouble", Null)
    value = value * 20
    chart1Data6.RunMethod("setValue", Array(value))
    value = num.RunMethod("nextDouble", Null)
    value = value * 20
    chart1Data7.RunMethod("setValue", Array(value))
    value = num.RunMethod("nextDouble", Null)
    value = value * 20
    chart1Data8.RunMethod("setValue", Array(value))
    
    value = num.RunMethod("nextDouble", Null)
    value = value * 20
    chart2Data1.RunMethod("setValue", Array(value))
    value = num.RunMethod("nextDouble", Null)
    value = value * 20
    chart2Data2.RunMethod("setValue", Array(value))
    value = num.RunMethod("nextDouble", Null)
    value = value * 20
    chart2Data3.RunMethod("setValue", Array(value))
    value = num.RunMethod("nextDouble", Null)
    value = value * 20
    chart2Data4.RunMethod("setValue", Array(value))
    value = num.RunMethod("nextDouble", Null)
    value = value * 20
    chart2Data5.RunMethod("setValue", Array(value))
    value = num.RunMethod("nextDouble", Null)
    value = value * 20
    chart2Data6.RunMethod("setValue", Array(value))
    value = num.RunMethod("nextDouble", Null)
    value = value * 20
    chart2Data7.RunMethod("setValue", Array(value))
    value = num.RunMethod("nextDouble", Null)
    value = value * 20
    chart2Data8.RunMethod("setValue", Array(value))
    
End Sub
 

Attachments

  • HansoloComparisonRingChart.zip
    2.7 KB · Views: 153
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
Hansolo CircularPlot using JavaObject (change it to your liking):

circularplot.png


Sample code:

B4J Code:
#Region Project Attributes
    #MainFormWidth: 800
    #MainFormHeight: 800
#End Region

#AdditionalJar: charts-11.2
'#AdditionalJar: javafx-graphics-11
'#AdditionalJar: javafx-base-11


Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form

    Private Pane1 As Pane
    
    Dim chart As JavaObject
    
    Dim australia As JavaObject
    Dim india As JavaObject
    Dim china As JavaObject
    Dim japan As JavaObject
    Dim thailand As JavaObject
    Dim singapore As JavaObject
    
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    
    Dim ausdata As Double = 1250000
    Dim inddata As Double = 750000
    Dim chindata As Double = 920000
    Dim japdata As Double = 1060000
    Dim thaidata As Double = 720000
    Dim singdata As Double = 800000
    
    australia.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("AUSTRALIA", ausdata, fx.Colors.RGB(255, 51, 51)))
    india.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("INDIA", inddata, fx.Colors.rgb(255, 153, 51)))
    china.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("CHINA", chindata, fx.Colors.rgb(255, 255, 51)))
    japan.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("JAPAN", japdata, fx.Colors.rgb(153, 255, 51)))
    thailand.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("THAILAND", thaidata, fx.Colors.rgb(51, 255, 51)))
    singapore.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("SINGAPORE", singdata, fx.Colors.rgb(51, 255, 153)))
    
    Dim val1, val2, val3, val4, val5 As Double
    val1 = 150000
    val2 = 90000
    val3 = 180000
    val4 = 15000
    val5= 10000
    
    australia.RunMethod("addToOutgoing", Array(india, val1))
    australia.RunMethod("addToOutgoing", Array(china, val2))
    australia.RunMethod("addToOutgoing", Array(japan, val3))
    australia.RunMethod("addToOutgoing", Array(thailand, val4))
    australia.RunMethod("addToOutgoing", Array(singapore, val5))
    
    Dim itemlist As List
    itemlist.Initialize
    itemlist.AddAll(Array As Object(australia, india, china, japan, thailand, singapore))
    
    Dim w, h As Double
    w = 500
    h = 500
    
    Dim opacity As Double = 0.75
    Dim decimals As Int = 0
    
    For Each item As JavaObject In itemlist
        Dim e As JavaObject = item.createEvent("eu.hansolo.fx.charts.event.ItemEventListener","itemclick", False) 
        item.RunMethod("addItemEventListener", Array As Object(e))
    Next
    
    Dim circluarPlotBuilder As JavaObject
    circluarPlotBuilder.InitializeStatic("eu.hansolo.fx.charts.CircularPlotBuilder")
    
    chart = circluarPlotBuilder.RunMethodJO("create", Null) _
                               .RunMethodJO("prefSize", Array(w, h)) _
                               .RunMethodJO("items", Array(itemlist)) _
                               .RunMethodJO("connectionOpacity", Array(opacity)) _
                               .RunMethodJO("decimals", Array(decimals)) _
                               .RunMethodJO("minorTickMarksVisible", Array(True)) _
                               .RunMethodJO("build", Null)

    Pane1.AddNode(chart,Pane1.Width*0.025,Pane1.Height*0.025,Pane1.Width*0.95,Pane1.Height*0.95)

End Sub

Sub itemclick_Event (MethodName As String, Args() As Object)
    
    Dim e  As JavaObject = Args(0)
    Dim s As String = e.RunMethod("getEventType", Null)
    Log(s)

    Select s
        Case "CONNECTION_SELECTED_FROM"
            Log("From: " & e.RunMethodJO("getItem", Null).RunMethodJO("getName", Null))
            Log(australia.RunMethod("getValue", Null))
            Dim country As String = "" & e.RunMethodJO("getItem", Null).RunMethodJO("getName", Null)
            Log("COUNTRY = " & country)
        Case "CONNECTION_SELECTED_TO"
            Log("To: " & e.RunMethodJO("getItem", Null).RunMethodJO("getName", Null))
            Dim country As String = "" & e.RunMethodJO("getItem", Null).RunMethodJO("getName", Null)
            Log("COUNTRY = " & country)
        Case "SELECTED"
            Log("Selected: " & e.RunMethodJO("getItem", Null).RunMethodJO("getName", Null))
            Dim country As String = "" & e.RunMethodJO("getItem", Null).RunMethodJO("getName", Null)
            Log("COUNTRY = " & country)
    End Select
    
End Sub

It has an EventListener - check the logs and change the code in the Event Sub to what you want to log/view
 

Attachments

  • HansoloCircularPlot.zip
    2.7 KB · Views: 165

Johan Schoeman

Expert
Licensed User
Longtime User
Hansolo StreamChart with JavaObject:

stream.png

Sample code:

B4X:
#Region Project Attributes
    #MainFormWidth: 1200
    #MainFormHeight: 800
#End Region

#AdditionalJar: charts-11.2
'#AdditionalJar: javafx-graphics-11
'#AdditionalJar: javafx-base-11


Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form

    Private Pane1 As Pane
   
    Dim chart As JavaObject
   
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
   
    Dim DARK_ORCHID As JavaObject = fx.colors.RGB(0x95, 0x20, 0xc9)
    Dim DARK_PASTEL_GREEN As JavaObject = fx.colors.RGB(0x1f, 0xaf, 0x44)
    Dim SPICY_PINK As JavaObject = fx.colors.RGB(0xff, 0x02, 0xb2)
    Dim LIMA As JavaObject = fx.colors.RGB(0x74, 0xce, 0x28)
   
    Dim itemList As List
    itemList.Initialize
   
    itemList.Add(createChartItem("Gerrit", 8, 1, 1, LIMA))          'Name, value, day, month, color
    itemList.Add(createChartItem("Gerrit", 5, 2, 1, LIMA))
    itemList.Add(createChartItem("Gerrit", 3, 3, 1, LIMA))
    itemList.Add(createChartItem("Gerrit", 2, 4, 1, LIMA))
    itemList.Add(createChartItem("Gerrit", 1, 5, 1, LIMA))

    itemList.Add(createChartItem("Sandra", 6, 1, 1, DARK_ORCHID))
    itemList.Add(createChartItem("Sandra", 4, 2, 1, DARK_ORCHID))
    itemList.Add(createChartItem("Sandra", 3, 3, 1, DARK_ORCHID))
    itemList.Add(createChartItem("Sandra", 2, 4, 1, DARK_ORCHID))
    itemList.Add(createChartItem("Sandra", 2, 6, 1, DARK_ORCHID))
    itemList.Add(createChartItem("Sandra", 2, 7, 1, DARK_ORCHID))

    itemList.Add(createChartItem("Lilli", 4, 2, 1, SPICY_PINK))
    itemList.Add(createChartItem("Lilli", 3, 3, 1, SPICY_PINK))
    itemList.Add(createChartItem("Lilli", 3, 4, 1, SPICY_PINK))
    itemList.Add(createChartItem("Lilli", 2, 5, 1, SPICY_PINK))
    itemList.Add(createChartItem("Lilli", 1, 6, 1, SPICY_PINK))
    itemList.Add(createChartItem("Lilli", 2, 7, 1, SPICY_PINK))
   
    itemList.Add(createChartItem("Anton", 3, 4, 1, DARK_PASTEL_GREEN))
    itemList.Add(createChartItem("Anton", 4, 5, 1, DARK_PASTEL_GREEN))
    itemList.Add(createChartItem("Anton", 3, 6, 1, DARK_PASTEL_GREEN))
    itemList.Add(createChartItem("Anton", 2, 7, 1, DARK_PASTEL_GREEN))
   
    Dim streamChartBuilder As JavaObject
    streamChartBuilder.InitializeStatic("eu.hansolo.fx.charts.StreamChartBuilder")
   
    Dim category As JavaObject
    category.InitializeStatic("eu.hansolo.fx.charts.StreamChart.Category")
   
    Dim itemwidth As Int = 80
    Dim itemgap As Int = 10
   
    chart = streamChartBuilder.RunMethodJO("create", Null) _
                              .RunMethodJO("items", Array(itemList)) _
                              .RunMethodJO("category", Array(category.GetField("DAY"))) _
                              .RunMethodJO("autoItemWidth", Array(True)) _
                              .RunMethodJO("itemWidth", Array(itemwidth)) _
                              .RunMethodJO("itemGap", Array(itemgap)) _
                              .RunMethodJO("autoItemGap", Array(True)) _                            
                              .RunMethodJO("build", Null)

    Pane1.AddNode(chart,Pane1.Width*0.025,Pane1.Height*0.025,Pane1.Width*0.95,Pane1.Height*0.95)

End Sub

Sub createChartItem(name As String, value As Double, day As Int, month As Int, color As JavaObject) As JavaObject
   
    Dim chartItemBuilder As JavaObject
    chartItemBuilder.InitializeStatic("eu.hansolo.fx.charts.data.ChartItemBuilder")
   
    Dim zoneID As JavaObject
    zoneID.InitializeStatic("java.time.ZoneId")
    Dim zonedDateTime As JavaObject
    zonedDateTime.InitializeStatic("java.time.ZonedDateTime")
   
    Return chartItemBuilder.RunMethodJO("create", Null) _
                           .RunMethodJO("name", Array(name)) _
                           .RunMethodJO("timestamp",Array(zonedDateTime.RunMethod("of", Array(2018, month, day, 8, 0, 0, 0, zoneID.RunMethod("systemDefault", Null))))) _
                           .RunMethodJO("value", Array(value)) _
                           .RunMethodJO("fill", Array(color)) _
                           .RunMethodJO("build", Null)
   
End Sub
 

Attachments

  • HansoloStreamChart.zip
    2.5 KB · Views: 162

Johan Schoeman

Expert
Licensed User
Longtime User
Hansolo PolarChart with JavaObject:

PolarChart.gif


Sample Code:

B4J:
#Region Project Attributes
    #MainFormWidth: 800
    #MainFormHeight: 800
#End Region

#AdditionalJar: charts-11.2
'#AdditionalJar: javafx-graphics-11
'#AdditionalJar: javafx-base-11


Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form

    Private Pane1 As Pane
    
    Dim chart As JavaObject
    Dim xySeries1 As JavaObject
    Dim xyChartItem As JavaObject
    
    Dim t As Timer
    Dim x(), y() As Double
    
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    
    t.Initialize("t", 500)
    
    Dim num As JavaObject
    num.InitializeNewInstance("java.util.Random", Null)
    
    Dim category As JavaObject
    category.InitializeStatic("eu.hansolo.fx.charts.converter.Converter.Category")
    Dim order As JavaObject
    order.InitializeStatic("eu.hansolo.fx.charts.tools.Order")
    
    Dim xyItems1 As List
    xyItems1.Initialize
    
    
    x = Array As Double(0, 145, 90, 225)
    y = Array As Double(45, 120, 150, 60)
    
    For i = 0 To x.Length - 1
        xyItems1.add(xyChartItem.InitializeNewInstance("eu.hansolo.fx.charts.data.XYChartItem", Array(x(i), y(i))))
    Next   
    
    Dim helper As JavaObject
    helper.InitializeStatic("eu.hansolo.fx.charts.tools.Helper")
    
    helper.RunMethod("orderXYChartItemsByX", Array(xyItems1, order.GetField("ASCENDING")))
    
    Dim chartType As JavaObject
    chartType.InitializeStatic("eu.hansolo.fx.charts.ChartType")

    Dim color As JavaObject
    color.InitializeStatic("javafx.scene.paint.Color")
    
    Dim symbol As JavaObject
    symbol.InitializeStatic("eu.hansolo.fx.charts.Symbol")
    
    
    xySeries1.InitializeNewInstance("eu.hansolo.fx.charts.series.XYSeries", Array(xyItems1, chartType.GetField("POLAR"), color.RunMethod("rgb", Array(255, 0, 0, 0.5)), fx.Colors.Red))
    xySeries1.RunMethod("setStroke", Array(color.RunMethod("rgb", Array(90, 90, 90))))
    xySeries1.RunMethod("setSymbolStroke", Array(color.GetField("LIME")))
    xySeries1.RunMethod("setSymbolFill", Array(color.GetField("GREEN")))
    xySeries1.RunMethod("setSymbol", Array(symbol.GetField("SQUARE")))
    
    Dim polarObject As JavaObject
    polarObject.InitializeArray("eu.hansolo.fx.charts.series.XYSeries", Array(xySeries1))
    
    Dim polarPane As JavaObject
    polarPane.InitializeNewInstance("eu.hansolo.fx.charts.XYPane", Array(polarObject))
    polarPane.RunMethod("setLowerBoundY", Array(polarPane.RunMethod("getDataMinY", Null)))
    polarPane.RunMethod("setUpperBoundY", Array(polarPane.RunMethod("getDataMaxY", Null)))
    
    chart.InitializeNewInstance("eu.hansolo.fx.charts.PolarChart", Array(polarPane))

    Pane1.AddNode(chart,Pane1.Width*0.025,Pane1.Height*0.025,Pane1.Width*0.95,Pane1.Height*0.95)
    
    t.Enabled = True

End Sub


Sub t_tick
    
    Dim ol As JavaObject
    ol.InitializeStatic("javafx.collections.ObservableList")
    ol = xySeries1.RunMethod("getItems", Null)
    
    Dim random As JavaObject
    random.InitializeNewInstance("java.util.Random", Null)
    
    For i = 0 To x.Length - 1
        Dim val As Double = random.RunMethod("nextDouble", Null)
        val = val * 360
        ol.RunMethodJO("get", Array(i)).RunMethodJO("setX", Array(val))
        val = random.RunMethod("nextDouble", Null) * 150
        ol.RunMethodJO("get", Array(i)).RunMethodJO("setY", Array(val))
        chart.RunMethod("refresh", Null)
    Next

End Sub
 

Attachments

  • HansoloPolarChart.zip
    2.6 KB · Views: 158

Johan Schoeman

Expert
Licensed User
Longtime User
Hansolo RadarChart with JavaObject:

SMOOTH_RADAR_POLYGON
RadarChart.gif


RADAR_SECTOR
RadarChartSector.gif

RADAR_POLYGON
RadarPolygon.gif

Sample code:
B4J:
#Region Project Attributes
    #MainFormWidth: 800
    #MainFormHeight: 800
#End Region

#AdditionalJar: charts-11.2
'#AdditionalJar: javafx-graphics-11
'#AdditionalJar: javafx-base-11


Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form

    Private Pane1 As Pane
    
    Dim chart As JavaObject
    Dim item1, item2, item3 As List
    
    Dim series1, series2, series3 As JavaObject
    Dim random As JavaObject
    Dim dataPoint As JavaObject
    
    Dim t As Timer

End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    
    t.Initialize("t", 500)
    
    item1.Initialize
    item2.Initialize
    item3.Initialize
    
    random.InitializeNewInstance("java.util.Random", Null)
    
    For i = 0 To 29
        item1.Add(dataPoint.InitializeNewInstance("eu.hansolo.fx.charts.data.YChartItem", Array(random.RunMethod("nextDouble", Null) * 100, "P" & i)))
        item2.Add(dataPoint.InitializeNewInstance("eu.hansolo.fx.charts.data.YChartItem", Array(random.RunMethod("nextDouble", Null) * 100, "P" & i)))
        item3.Add(dataPoint.InitializeNewInstance("eu.hansolo.fx.charts.data.YChartItem", Array(random.RunMethod("nextDouble", Null) * 100, "P" & i)))
    Next

    Dim color As JavaObject
    color.InitializeStatic("javafx.scene.paint.Color")

    Dim opacity1 As Double = 0.25
    Dim opacity2 As Double = 0.5
    Dim opacity3 As Double = 0.75
    
    Dim offset1, offset2, offset3 As Double
    offset1 = 0
    offset2 = 0.5
    offset3 = 1
    
    Dim stp11, stp12, stp13 As JavaObject

    stp11.InitializeNewInstance("javafx.scene.paint.Stop", Array(offset1, color.RunMethod("rgb", Array(0, 255, 255, opacity1))))
    stp12.InitializeNewInstance("javafx.scene.paint.Stop", Array(offset2, color.RunMethod("rgb", Array(255, 255, 0, opacity2))))
    stp13.InitializeNewInstance("javafx.scene.paint.Stop", Array(offset3, color.RunMethod("rgb", Array(255, 0, 255, opacity3))))
    
    Dim stp21, stp22, stp23 As JavaObject
    stp21.InitializeNewInstance("javafx.scene.paint.Stop", Array(offset1, color.RunMethod("rgb", Array(255, 0, 0, opacity1))))
    stp22.InitializeNewInstance("javafx.scene.paint.Stop", Array(offset2, color.RunMethod("rgb", Array(255, 255, 0, opacity2))))
    stp23.InitializeNewInstance("javafx.scene.paint.Stop", Array(offset3, color.RunMethod("rgb", Array(0, 200, 0, opacity3))))
    
    Dim stp31, stp32, stp33 As JavaObject
    stp31.InitializeNewInstance("javafx.scene.paint.Stop", Array(offset1, color.RunMethod("rgb", Array(0, 255, 255, opacity1))))
    stp32.InitializeNewInstance("javafx.scene.paint.Stop", Array(offset2, color.RunMethod("rgb", Array(0, 255, 255, opacity2))))
    stp33.InitializeNewInstance("javafx.scene.paint.Stop", Array(offset3, color.RunMethod("rgb", Array(0, 0, 255, opacity3))))
    
    
    Dim arrayStop1, arrayStop2, arrayStop3 As JavaObject
    arrayStop1.InitializeArray("javafx.scene.paint.Stop", Array(stp11, stp12, stp13))
    arrayStop2.InitializeArray("javafx.scene.paint.Stop", Array(stp21, stp22, stp23))
    arrayStop3.InitializeArray("javafx.scene.paint.Stop", Array(stp31, stp32, stp33))
    
    Dim cyclemethod As JavaObject
    cyclemethod.InitializeStatic("javafx.scene.paint.CycleMethod")
    
    Dim focusAngle, focusDistance, centerX, centerY, radius As Double
    focusAngle = 0
    focusDistance = 0
    centerX = 0
    centerY = 0
    radius = 1
    
    Dim radialgradient1 As JavaObject
    radialgradient1.InitializeNewInstance("javafx.scene.paint.RadialGradient",  _
                                    Array(focusAngle, focusDistance, centerX, centerY, radius, True, cyclemethod.GetField("NO_CYCLE"), arrayStop1))

    Dim radialgradient2 As JavaObject
    radialgradient2.InitializeNewInstance("javafx.scene.paint.RadialGradient",  _
                                    Array(focusAngle, focusDistance, centerX, centerY, radius, True, cyclemethod.GetField("NO_CYCLE"), arrayStop2))

    Dim radialgradient3 As JavaObject
    radialgradient3.InitializeNewInstance("javafx.scene.paint.RadialGradient",  _
                                    Array(focusAngle, focusDistance, centerX, centerY, radius, True, cyclemethod.GetField("NO_CYCLE"), arrayStop3))

    
    Dim chartType As JavaObject
    chartType.InitializeStatic("eu.hansolo.fx.charts.ChartType")
    
    'RADAR_POLYGON, SMOOTH_RADAR_POLYGON, RADAR_SECTOR
    series1.InitializeNewInstance("eu.hansolo.fx.charts.series.YSeries",  _
                                    Array(item1, chartType.GetField("RADAR_POLYGON"), radialgradient1, fx.Colors.Transparent))

    series2.InitializeNewInstance("eu.hansolo.fx.charts.series.YSeries",  _
                                    Array(item2, chartType.GetField("RADAR_POLYGON"), radialgradient2, fx.Colors.Transparent))

    series3.InitializeNewInstance("eu.hansolo.fx.charts.series.YSeries",  _
                                    Array(item3, chartType.GetField("RADAR_POLYGON"), radialgradient3, fx.Colors.Transparent))
    
    Dim category As JavaObject
    
    Dim categories As List
    categories.Initialize
    
    For i = 0 To 29
        categories.Add(category.InitializeNewInstance("eu.hansolo.fx.charts.Category", Array("P" & i)))
    Next
    
    Dim seriesjavaobject As JavaObject
    seriesjavaobject.InitializeArray("eu.hansolo.fx.charts.series.YSeries", Array(series1, series2, series3))

    Dim yPane As JavaObject
    yPane.InitializeNewInstance("eu.hansolo.fx.charts.YPane", Array(categories, seriesjavaobject))
    
    chart.InitializeNewInstance("eu.hansolo.fx.charts.YChart", Array(yPane))
    Dim wdth, hght As Double
    wdth = 600
    hght = 600
    chart.RunMethod("setPrefSize", Array(wdth, hght))

    Pane1.AddNode(chart,Pane1.Width*0.025,Pane1.Height*0.025,Pane1.Width*0.95,Pane1.Height*0.95)
    
    t.Enabled = True

End Sub


Sub t_tick
    
    item1.Clear
    item2.Clear
    item3.Clear
    
    For i = 0 To 29
        item1.Add(dataPoint.InitializeNewInstance("eu.hansolo.fx.charts.data.YChartItem", Array(random.RunMethod("nextDouble", Null) * 100, "P" & i)))
        item2.Add(dataPoint.InitializeNewInstance("eu.hansolo.fx.charts.data.YChartItem", Array(random.RunMethod("nextDouble", Null) * 100, "P" & i)))
        item3.Add(dataPoint.InitializeNewInstance("eu.hansolo.fx.charts.data.YChartItem", Array(random.RunMethod("nextDouble", Null) * 100, "P" & i)))
    Next

    series1.RunMethod("setItems", Array(item1))
    series1.RunMethod("refresh", Null)
    
    series2.RunMethod("setItems", Array(item2))
    series2.RunMethod("refresh", Null)
    
    series3.RunMethod("setItems", Array(item3))
    series3.RunMethod("refresh", Null)

End Sub
 

Attachments

  • HansoloRadarChart.zip
    2.8 KB · Views: 130
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
Hansolo MatrixPlot with JavaObject:

MatrixPlot.gif


Sample Code:

B4J:
#Region Project Attributes
    #MainFormWidth: 800
    #MainFormHeight: 800
#End Region

#AdditionalJar: charts-11.2
'#AdditionalJar: javafx-graphics-11
'#AdditionalJar: javafx-base-11


Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form

    Private Pane1 As Pane
    
    Dim chart As JavaObject
    Dim cols, rows As Int
    
    Dim t As Timer

End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    
    t.Initialize("t", 300)
    
    Dim chart As JavaObject
    chart.InitializeNewInstance("eu.hansolo.fx.charts.PixelMatrix", Null)
    Dim pixelMatrixBuilder As JavaObject
    pixelMatrixBuilder.InitializeStatic("eu.hansolo.fx.charts.PixelMatrixBuilder")
    
    Dim wdth, hght As Double
    wdth = 600
    hght = 300
    
    cols = 108
    rows = 40
    
    Dim pixelShape As JavaObject
    pixelShape.InitializeStatic("eu.hansolo.fx.charts.PixelMatrix.PixelShape")
    
    chart = pixelMatrixBuilder.RunMethodJO("create", Null) _
                              .RunMethodJO("prefSize", Array(wdth, hght)) _
                              .RunMethodJO("colsAndRows", Array(cols, rows)) _
                              .RunMethodJO("pixelOnColor", Array(fx.Colors.Red)) _
                              .RunMethodJO("pixelOffColor", Array(fx.Colors.Transparent)) _
                              .RunMethodJO("pixelShape", Array(pixelShape.GetField("ROUND"))) _
                              .RunMethodJO("squarePixels", Array(True)) _
                              .RunMethod("build", Null)
                              
    createRandomData
    
    Sleep(100)
    
    Pane1.AddNode(chart,Pane1.Width*0.025,Pane1.Height*0.025,Pane1.Width*0.95,Pane1.Height*0.95)
    
    t.Enabled = True
    
End Sub

Sub createRandomData
    
    Dim random As JavaObject
    random.InitializeNewInstance("java.util.Random", Null)

    chart.RunMethod("setAllPixelsOff", Null)

    Dim MIN_VALUE As Int = -20
    Dim MAX_VALUE As Int = 20
        
    Dim OFF As JavaObject = fx.Colors.Transparent
    Dim DARK_RED As JavaObject = fx.Colors.RGB(0xD0, 0x46, 0x25)
    Dim RED As JavaObject = fx.Colors.RGB(0xF3, 0x52, 0x2C)
    Dim ORANGE As JavaObject = fx.Colors.RGB(0xFC, 0xA3, 0x00)
    Dim YELLOW As JavaObject = fx.Colors.RGB(0xFF, 0xD8, 0x24)
    Dim BEIGE As JavaObject = fx.Colors.RGB(0xEF, 0xE3, 0xBC)
    Dim LIGHT_GREEN As JavaObject = fx.Colors.RGB(0xC5, 0xE3, 0xB9)
    Dim GREEN As JavaObject = fx.Colors.RGB(0xA1, 0xD4, 0x90)
    Dim DARK_GREEN As JavaObject = fx.Colors.RGB(0x62, 0xBD, 0x4A)
    Dim BLUE As JavaObject = fx.Colors.RGB(0x01, 0x97, 0xDE)
        
    For x = 0 To cols - 1
        Dim high As Int  = random.RunMethod("nextInt", Array(MAX_VALUE))
        high = (high - MAX_VALUE) * -1
        Dim low As Int = random.RunMethod("nextInt", Array(MIN_VALUE * -1))
        low = low + (MIN_VALUE * -1)
        For y = 0 To rows - 1
            If (y >= high And y <= low) Then
                If y > 0 And y <= 4 Then
                    chart.RunMethod("setPixel", Array(x, y, IIf(high <= y, BLUE, OFF)))
                else if (y >= 4 And y < 8) Then
                    chart.RunMethod("setPixel", Array(x, y, IIf(high <= y, DARK_GREEN, OFF)))
                else if (y >= 8 And y < 12) Then
                    chart.RunMethod("setPixel", Array(x, y, IIf(high <= y, GREEN, OFF)))
                else if (y >= 12 And y < 20) Then
                    chart.RunMethod("setPixel", Array(x, y, IIf(high <= y, LIGHT_GREEN, OFF)))
                else if (y >= 20 And y < 28) Then
                    chart.RunMethod("setPixel", Array(x, y, IIf(high <= y, BEIGE, OFF)))
                else if (y >= 28 And y < 32) Then
                    chart.RunMethod("setPixel", Array(x, y, IIf(high <= y, YELLOW, OFF)))
                else if (y >= 32 And y < 36) Then
                    chart.RunMethod("setPixel", Array(x, y, IIf(high <= y, ORANGE, OFF)))
                else if (y >= 36 And y < 40) Then
                    chart.RunMethod("setPixel", Array(x, y, IIf(high <= y, RED, OFF)))
                Else   
                    chart.RunMethod("setPixel", Array(x, y, IIf(high <= y, DARK_RED, OFF)))
                End If
            End If   
        Next
    Next
        
    chart.RunMethod("drawMatrix", Null)
            
End Sub

Sub t_tick
    
    createRandomData
    
End Sub
 

Attachments

  • HansoloMatrixPlot.zip
    2.7 KB · Views: 146

Johan Schoeman

Expert
Licensed User
Longtime User
Hansolo SankeyPlot with JavaObject:

sankeyplot.png


Sample Code:
B4J:
#Region Project Attributes
    #MainFormWidth: 800
    #MainFormHeight: 800
#End Region

#AdditionalJar: charts-11.2
'#AdditionalJar: javafx-graphics-11
'#AdditionalJar: javafx-base-11


Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form

    Private Pane1 As Pane
    
    Dim chart As JavaObject
    
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    
    chart.InitializeNewInstance("eu.hansolo.fx.charts.SankeyPlot", Null)
    
'    Dim DARK_ORCHID As JavaObject = fx.colors.RGB(0x95, 0x20, 0xc9)
'    Dim DARK_PASTEL_GREEN As JavaObject = fx.colors.RGB(0x1f, 0xaf, 0x44)
'    Dim SPICY_PINK As JavaObject = fx.colors.RGB(0xff, 0x02, 0xb2)
'    Dim LIMA As JavaObject = fx.colors.RGB(0x74, 0xce, 0x28)
    Dim ORANGE As JavaObject = fx.Colors.RGB(0xfd, 0xbf, 0x6f)
'    Dim STARSHIP As JavaObject = fx.Colors.RGB(0xda, 0xfd, 0x38)
    
    Dim LIGHT_BLUE As JavaObject = fx.Colors.RGB(0xa6, 0xce, 0xe3)
    Dim LIGHT_RED As JavaObject = fx.Colors.RGB(0xfb, 0x9a, 0x99)
    Dim LIGHT_GREEN As JavaObject = fx.Colors.RGB(0xb2, 0xdf, 0x8a)
    Dim YELLOW As JavaObject = fx.Colors.RGB(0xff, 0xff, 0x99)
    Dim PURPLE As JavaObject = fx.Colors.RGB(0xca,0xb2, 0xd6)
    Dim BLUE As JavaObject = fx.Colors.RGB(0x1f, 0x78, 0xb4)
    Dim GREEN As JavaObject = fx.Colors.RGB(0x33, 0xa0, 0x2c)
    
    Dim PINK As JavaObject = fx.Colors.RGB(0xFF, 0x48, 0xC6)

    Dim brazil, mexico, usa, canada, GERMANY, portugal, spain, england, france, southAfrica, angola, morocco, senegal, mali, china, japan, india As JavaObject
    
    brazil.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("Brazil", LIGHT_BLUE))
    mexico.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("Mexico", ORANGE))
    usa.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("USA", ORANGE))
    canada.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("Canada", LIGHT_RED))
    GERMANY.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("Germany", PINK))
    portugal.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("Portugal", LIGHT_BLUE))
    spain.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("Spain", LIGHT_GREEN))
    england.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("England", LIGHT_RED))
    france.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("France", LIGHT_GREEN))
    southAfrica.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("South Africa", YELLOW))
    angola.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("Angola", PURPLE))
    morocco.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("Morocco", YELLOW))
    senegal.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("Senegal", PURPLE))
    mali.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("Mail", BLUE))
    china.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("China", BLUE))
    japan.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("Japan", GREEN))
    india.InitializeNewInstance("eu.hansolo.fx.charts.data.PlotItem", Array("India", GREEN))
    
    Dim ONE As Double = 1
    Dim TWO As Double = 2
    Dim THREE As Double = 3
    Dim FIVE As Double = 5
    Dim SEVEN As Double  = 7
    
    brazil.RunMethod("addToOutgoing", Array(portugal, FIVE))
    brazil.RunMethod("addToOutgoing", Array(france, ONE))
    brazil.RunMethod("addToOutgoing", Array(spain, ONE))
    brazil.RunMethod("addToOutgoing", Array(england, ONE))
    
    canada.RunMethod("addToOutgoing", Array(portugal, ONE))
    canada.RunMethod("addToOutgoing", Array(france, FIVE))
    canada.RunMethod("addToOutgoing", Array(england, ONE))
    
    mexico.RunMethod("addToOutgoing", Array(portugal, ONE))
    mexico.RunMethod("addToOutgoing", Array(france, ONE))
    mexico.RunMethod("addToOutgoing", Array(spain, FIVE))
    mexico.RunMethod("addToOutgoing", Array(england, ONE))
    
    usa.RunMethod("addToOutgoing", Array(portugal, ONE))
    usa.RunMethod("addToOutgoing", Array(france, ONE))
    usa.RunMethod("addToOutgoing", Array(spain, ONE))
    usa.RunMethod("addToOutgoing", Array(england, FIVE))
    
    GERMANY.RunMethod("addToOutgoing", Array(southAfrica, FIVE))
    
    portugal.RunMethod("addToOutgoing", Array(angola, TWO))
    portugal.RunMethod("addToOutgoing", Array(senegal, ONE))
    portugal.RunMethod("addToOutgoing", Array(morocco, ONE))
    portugal.RunMethod("addToOutgoing", Array(southAfrica, THREE))
    
    france.RunMethod("addToOutgoing", Array(angola, ONE))
    france.RunMethod("addToOutgoing", Array(senegal, THREE))
    france.RunMethod("addToOutgoing", Array(mali, THREE))
    france.RunMethod("addToOutgoing", Array(morocco, THREE))
    france.RunMethod("addToOutgoing", Array(southAfrica, ONE))
    
    spain.RunMethod("addToOutgoing", Array(senegal, ONE))
    spain.RunMethod("addToOutgoing", Array(morocco, THREE))
    spain.RunMethod("addToOutgoing", Array(southAfrica, ONE))
    
    england.RunMethod("addToOutgoing", Array(angola, ONE))
    england.RunMethod("addToOutgoing", Array(senegal, ONE))
    england.RunMethod("addToOutgoing", Array(morocco, TWO))
    england.RunMethod("addToOutgoing", Array(southAfrica, SEVEN))
    
    southAfrica.RunMethod("addToOutgoing", Array(china, FIVE))
    southAfrica.RunMethod("addToOutgoing", Array(india, ONE))
    southAfrica.RunMethod("addToOutgoing", Array(japan, THREE))
    
    angola.RunMethod("addToOutgoing", Array(china, FIVE))
    angola.RunMethod("addToOutgoing", Array(india, ONE))
    angola.RunMethod("addToOutgoing", Array(japan, THREE))
    
    senegal.RunMethod("addToOutgoing", Array(china, FIVE))
    senegal.RunMethod("addToOutgoing", Array(india, ONE))
    senegal.RunMethod("addToOutgoing", Array(japan, THREE))
    
    mali.RunMethod("addToOutgoing", Array(china, FIVE))
    mali.RunMethod("addToOutgoing", Array(india, ONE))
    mali.RunMethod("addToOutgoing", Array(japan, THREE))
    
    morocco.RunMethod("addToOutgoing", Array(china, FIVE))
    morocco.RunMethod("addToOutgoing", Array(india, ONE))
    morocco.RunMethod("addToOutgoing", Array(japan, THREE))
    
    Dim sankeyPlotBuilder As JavaObject
    sankeyPlotBuilder.InitializeStatic("eu.hansolo.fx.charts.SankeyPlotBuilder")
    
    Dim wdth, hght As Double
    wdth = 600
    hght = 400
    
    Dim plotItemArray As JavaObject
    plotItemArray.InitializeArray("eu.hansolo.fx.charts.data.PlotItem", Array(brazil, mexico, usa, canada, GERMANY, portugal, spain, england, france, southAfrica, angola, morocco, senegal, mali, china, japan, india))
    
    Dim streamFillMode As JavaObject
    streamFillMode.InitializeStatic("eu.hansolo.fx.charts.SankeyPlot.StreamFillMode")
    
    chart = sankeyPlotBuilder.RunMethodJO("create", Null) _
                             .RunMethodJO("prefSize", Array(wdth, hght)) _
                             .RunMethodJO("items", Array(plotItemArray)) _
                             .RunMethodJO("streamFillMode", Array(streamFillMode.GetField("GRADIENT"))) _
                             .RunMethodJO("build", Null)

    
    Pane1.AddNode(chart,Pane1.Width*0.025,Pane1.Height*0.025,Pane1.Width*0.95,Pane1.Height*0.95)
    
End Sub
 

Attachments

  • HansoloSankeyPlot.zip
    2.9 KB · Views: 145
Top