Gráficos y visualización · jdashboardUI 23.5 · B4J / JavaFX
Gráfico de línea con curvas suaves, área de relleno, grid, valores, ejes, sufijo y exportación PNG.
La imagen mostrada en esta página es una referencia visual creada para la documentación. No pretende ser una captura pixel-perfect del control; el resultado real depende del tamaño, tema, colores y datos.
Características destacadas
- Exportación PNG
- Animación configurable
- Grid / ejes configurables
- Título configurable
- Interacción por clic
Cuándo usarlo
Gráfico de línea con curvas suaves, área de relleno, grid, valores, ejes, sufijo y exportación PNG.
Designer Properties
| Property | Type | Default | Description |
|---|---|---|---|
| LineColor | Color | #FF8A2BE2 |
Color of the line (purple as in the image) |
| ShowMarker | Boolean | True |
Shows the values above each point |
| MarkerText | String | API Calls |
|
| Animate | Boolean | True |
|
| Duration | Int | 1000 |
Duration in milliseconds |
| ShowFill | Boolean | True |
Shows or hides the fill under the chart line |
| ValueSuffix | String | `` | Suffix for point values (e.g., %, $, etc.) |
| SmoothCurves | Boolean | True |
Use cubic bezier curves instead of straight lines. |
| ShowGrid | Boolean | False |
Shows or hides the horizontal grid lines |
| GridColor | Color | 0xFF64748B |
Color of the horizontal grid lines |
| GridInterval | Float | 0 |
Interval between grid lines (0 for auto 4 steps) |
| GridTextColor | Color | 0xFF64748B |
Color of the grid Y-axis labels |
| GridTextBold | Boolean | False |
Set to True to make the Y-axis text bold |
Creación y ciclo de vida
Private JLineChart1 As JLineChart
JLineChart1.Initialize(Me, "JLineChart1")
JLineChart1.AddToParent(Root, 20dip, 20dip, 640dip, 360dip)
Ejemplo funcional
Dim Labels As List
Labels.Initialize2(Array As String("Jan", "Feb", "Mar", "Apr", "May"))
Dim Values As List
Values.Initialize2(Array As Double(18, 32, 29, 55, 70))
JLineChart1.setData(Labels, Values)
JLineChart1.TextTitle = "Monthly growth"
JLineChart1.ShowFill = True
JLineChart1.Curves = True
Propiedades B4X normalizadas
Los accesores públicos getX/setX compatibles se presentan como propiedades B4X normales. Los métodos parametrizados siguen documentándose como métodos.
| Propiedad | Acceso | Tipo |
|---|---|---|
| ShowAxes | read / write | Boolean |
| ShowYAxisValues | read / write | Boolean |
| ShowGrid | read / write | Boolean |
| GridColor | read / write | Int |
| GridInterval | read / write | Float |
| GridTextColor | read / write | Int |
| GridTextBold | read / write | Boolean |
| TitleFont | write | B4XFont |
| TitleColor | write | Int |
| XAxisTextColor | write | Int |
| TextTitle | write | String |
| ShowFill | write | Boolean |
| Color | write | Int |
| ShowValues | write | Boolean |
| Suffix | write | String |
| Curves | write | Boolean |
| ValuesFont | write | B4XFont |
| XAxisFont | write | B4XFont |
Eventos
MouseClicked
Exportación y renderizado
Cuando el módulo expone SaveAsPNG / SavePNG, puedes guardar el estado renderizado del control directamente a PNG. Comprueba el Boolean devuelto cuando exista.
Notas y comportamiento real de la versión analizada
- La API descrita se obtuvo del código fuente real del módulo.
Historial y datos en tiempo real
AddPoint permite agregar un nuevo dato sin reconstruir manualmente las listas:
JLineChart1.AddPoint(DateTime.Time(DateTime.Now), Rnd(20, 100), 24)
MaxPoints debe ser al menos 1. Cuando se supera el límite, el punto más antiguo se elimina automáticamente. El método devuelve True cuando el dato se agrega correctamente y False si la vista o los datos no son válidos. La actualización se dibuja inmediatamente y conserva el desplazamiento horizontal existente.
API pública completa
-
AddPoint(Label As String, Value As Double, MaxPoints As Int) As Boolean -
Initialize(Callback As Object, EventName As String) -
DesignerCreateView(Base As Object, Lbl As Label, Props As Map) -
AddToParent(Parent As B4XView, Left As Int, Top As Int, Width As Int, Height As Int) -
setData(PoinsX As List, Values As List) -
setTitleFont(Font As B4XFont) -
setTitleColor(Color As Int) -
setXAxisTextColor(Color As Int) -
setTextTitle(Title As String) -
setShowFill(Show As Boolean) -
setColor(color As Int) -
setShowValues(Show As Boolean) -
setSuffix(Suffix As String) -
SaveAsPNG(Dir As String, FileName As String, BackgroundColor As Int) As Boolean -
setCurves(Curves As Boolean) -
setValuesFont(Font As B4XFont) -
setXAxisFont(Font As B4XFont) -
setShowAxes(Show As Boolean) -
getShowAxes() As Boolean -
setShowYAxisValues(Show As Boolean) -
getShowYAxisValues() As Boolean -
setShowGrid(Show As Boolean) -
getShowGrid() As Boolean -
setGridColor(Color As Int) -
getGridColor() As Int -
setGridInterval(Interval As Float) -
getGridInterval() As Float -
setGridTextColor(Color As Int) -
getGridTextColor() As Int -
setGridTextBold(Bold As Boolean) -
getGridTextBold() As Boolean
Componentes relacionados
- JMultiLineChart
- JBarChart