DgsCreateChart: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}
{{Client function}}
{{Needs Example|dgsCreateChart}}
This function creates a data chart.
This function creates a data chart.



Latest revision as of 13:50, 10 January 2023

This function creates a data chart.

Syntax

element dgsCreateChart ( float x, float y, float width, float height, string chartType, bool relative [, element parent = nil ] )

Required Arguments

Chart Example.
  • x: A float of the 2D x position of the chart on a player's screen. This is affected by the relative argument.
  • y: A float of the 2D y position of the chart on a player's screen. This is affected by the relative argument.
  • width: A float of the width of the chart. This is affected by the relative argument.
  • height: A float of the height of the chart. This is affected by the relative argument.
  • chartType: A string of chart type. The available values are:
    • line
  • relative: This is whether sizes and positioning are relative. If this is true, then all x,y,width,height floats must be between 0 and 1, representing sizes/positions as a fraction of the screen size. If false, then the size and co-ordinates are based on client's resolution, accessible using guiGetScreenSize.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • parent: This is the parent that the DGS Chart is attached to. If the relative argument is true, sizes and positioning will be made relative to this parent. If the relative argument is false, positioning will be the number of offset pixels from the parent's origin. If no parent is passed, the parent will become the screen - causing positioning and sizing according to screen positioning.

Returns

Returns a dgs chart plugin element if it was created successfully, false otherwise.

Example

DGS = exports.dgs --get exported functions from dgs

local chart = DGS:dgsCreateChart(100,100,600,300,"line",false)
DGS:dgsChartSetLabels(chart,"Month",{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"})
DGS:dgsSetProperty(chart,"axisYScaler",{0,100})
DGS:dgsSetProperty(chart,"gridLineWidth",2)
DGS:dgsSetProperty(chart,"axisLineWidth",4)
DGS:dgsSetProperty(chart,"axisTextOffsetFromGrid",10)
DGS:dgsSetProperty(chart,"chartPadding",{40,40,40,40,false}) --Top Botton Left Right
local datasetID = DGS:dgsChartAddDataset(chart,"Counts")
DGS:dgsChartDatasetSetStyle(chart,datasetID,{
		color = tocolor(255,0,0,255),
		width = 2,
	}
)
local setdata = {}
for i=1,12 do
	setdata[i] = math.random()
end
DGS:dgsChartDatasetSetData(chart,datasetID,setdata)

local datasetID = DGS:dgsChartAddDataset(chart,"Counts")
DGS:dgsChartDatasetSetStyle(chart,datasetID,{
		color = tocolor(255,255,0,255),
		width = 2,
	}
)
local setdata = {}
for i=1,12 do
	setdata[i] = math.random(1,10)
end
DGS:dgsChartDatasetSetData(chart,datasetID,setdata)

See Also

Custom Cursor Functions

Multi Language Supports

Animation

3D Element

3D Interface

3D Line

3D Image

3D Text

Browser

Button

Check Box

Combo Box

Custom Renderer

Edit

Detect Area

Drag'N Drop

Grid List

Image

Memo

Menu

Label

Layout

Line

Progress Bar

Radio Button

Scale Pane

Scroll Bar

Scroll Pane

Selector

Style

Switch Button

Tab Panel

Window

Basic Shape Plugins

Circle

Quadrilateral

Rounded Rectangle

Other Plugins

Blur Box

Canvas

Chart

Color Picker

Effect 3D

Gradient

Mask

Media Browser

Nine Slice

Object Preview Supports

Paste Handler

QRCode

Remote Image

Screen Source

SVG

Tooltips