--- title: "Vision - Easy Chart Scripting Functions" --- # Vision - Easy Chart Scripting Functions > * Parameters > * String **filename** - The default file name for the Save dialog. ## Scripting Functions ### exportExcel(filename) * Description * This function saves the chart's datasets as an Excel file. Returns a String of the complete file path chosen by the user, or None if the user canceled the save. * Return * String ### print() * Description * This function will print the chart. * Parameters * None * Return * None ### setMode(mode) * Description * Sets the current mode for the chart. * Parameters * Integer **mode** - The mode to set the chart to. The mode options are as follows: * 0 : Zoom Mode. This is the default mode, where the user can draw a zoom rectangle with the mouse pointer. * 1 : Pan Mode. This mode lets the user use the mouse pointer to pan the chart to the left and right. * 3 : Mark mode. This mode lets the user click near a datapoint to annotate the point with its X and Y value. * 4 : X-Trace mode. This mode lets the user click and drag on the chart to see all values that fall along that X value. * Return * None ### exportDatasets() * Description * Returns an Array List of datasets, representing the time series data of each type of pen. * Parameters * None * Return * Array List of datasets. Each dataset represents timeseries data for set of pens. The order of the datasets are listed below. #### Index order of datasets | Index | Dataset | |----|----| | 0 | Tag Pens | | 1 | Calculated Pens | | 2 | Database Pens | ```py title="Python - Accessing the Tag Pens Dataset" # This example extracts the Easy Chart's Tag Pens dataset and pushes it to a Power Table. # Place this script on the Easy Chart's propertyChange event. if event.propertyName == 'tagPens': # Capture references up front. # This is safer than using `event` directly inside the delayed call, # since by the time the function executes, the event object may no longer be valid. chart = event.source table = chart.parent.getComponent('Power Table') # Wrap our dataset behavior in a function so we can pass it to invokeLater def update_table(): # Export datasets; index 0 contains Tag Pens series data datasets = chart.exportDatasets() table.data = datasets[0] # Delay until after the chart finishes loading the new tag system.vision.invokeLater(update_table, 1000) ``` ## Extension Functions ### configureChart * Description * Provides an opportunity to perform further chart configuration via scripting. Doesn't return anything. * Parameters * Component **self** - A reference to the component that is invoking this function. * JFreeChart **chart** - A JFreeChart object. Refer to the JFreeChart documentation for API details. * Return * None ### getXTraceLabel * Description * Provides an opportunity to configure the x-trace label. Return a string to override the default label. * Parameters * Component **self** - A reference to the component that is invoking this function. * JFreeChart **chart** - A JFreeChart object. Refer to the JFreeChart documentation for API details. * String **penName** - The name of the pen the x-trace label applies to. * Integer **yValue** - The y-value of the pen at the x-trace location. * Return * None ### onPowerTableRowsDropped * Description * Called when the user has dropped rows from a power table on the chart. The source table must have dragging enabled. * Parameters * Component **self** - A reference to the component that is invoking this function. * Component **sourceTable** - A reference to the table that the rows were dragged from. * List **rows** - An array of the row indicies that were dragged, in the order they were selected. * Dataset **rowData** - A dataset containing the rows that were dragged. * Return * None ### onTagsDropped * Description * Called when the user has dropped tags from the tag tree onto the chart. Normally, the chart will add pens automatically when tags are dropped, but this default behavior will be suppressed if this extension function is implemented. * Parameters * Component **self** - A reference to the component that is invoking this function. * List **paths** - A list of the tag paths that were dropped on the chart. * Return * None ```py title="Example - Pen Name Replacement" # This will take a tag that gets dropped from a Tag Browse Tree set in Realtime Tag Tree mode, # and will replace the underscores in the name of the tag "_" and replace them with spaces. tagPens = self.tagPens for tag in paths: tagPath = tag.replace("default", "~") splitTag = tag.split("/") name = splitTag[-1].replace("_", " ") newRow = [name, tagPath, "MinMax", "Default Axis", 1, 1, system.vision.color(255, 85, 85, 255), "", 1, 1, 0, 1, 0, "", 0, 0, 0, 1, 0, 0] self.tagPens = system.dataset.addRow(tagPens, newRow) ``` ```py title="Example - Group Name" # This will take a tag that gets dropped from a Tag Browse Tree set in Realtime Tag Tree mode, # and will place it into a Pen Group titled "My Group Name". tagPens = self.tagPens groupName = "My Group Name" for tag in paths: newRow = [name, tagPath, "MinMax", "Default Axis", 1, 1, system.vision.color(255, 85, 85, 255), "", 1, 1, 0, 1, 0, groupName, 0, 0, 0, 1, 0, 0] self.tagPens = system.dataset.addRow(tagPens, newRow) ```