Class: STXSocial

STXSocial


new STXSocial()

Manages chart sharing and uploading.

Version:
  • ChartIQ plug-in

Classes

Decoration

Methods


<static> brandMyChart(stx, imageURL, positioning, size)

Places a watermark image on the chart for branding. This method should only be called once after you create your chart object -new STXChart()-.

Parameters:
Name Type Description
stx object

The chart

imageURL string

The URL of the image

positioning array

A tuple. The first item of the tuple is the X offset from the edge of the chart. The second item is the Y offset from the top of the chart. Use negative numbers to offset from right of chart or bottom of chart.

size array

A tuple. The first item of the tuple is the width. The second item is the height. Leave out to use actual size.

Version:
  • ChartIQ plug-in
Since:
  • 2016-03-11 Image size can now be specified using the new `size` argument
Example
function runSampleUI(){
		// put your code to establish the behavior of your UI.
		STXSocial.brandMyChart(stxx, "logo.png",[10,-30],[50,50]);
}

<static> createImage(stx [, widthPX] [, heightPX] [, decorationObj], cb)

Create a png image based on the current chart. If widthPX and heightPX are passed in then the image will be scaled to the requested dimensions. This function is asynchronous and requires a callback function. The callback will be passed a data object which can be sent to a server or converted to an image. decorationObj can be used to "decorate" the canvas. For instance, you can add a header or footer to the canvas, or even brand it with an image if you only want the branding done on the shared image but not on the chart itself.

Parameters:
Name Type Argument Default Description
stx object

Chart object

widthPX number <optional>

Width of image to create. If passed then height will adjust to maintain ratio.

heightPX number <optional>

Height of image to create. If passed then width will adjust to maintain ratio.

decorationObj object <optional>
defaultDecorator

A decorator to add custom branding. Pass {} to not use the defaultDecorator.

cb function

Callback when image is available fc(data) where data is the serialized image object

Version:
  • ChartIQ plug-in

<static> uploadImage(dataImage, url [, payload], cb)

Uploads an image to a server. See Python chart-sharing server example for a comple server code. on the server side. The callback will take two parameters. The first parameter is an error condition (server status), or null if there is no error. The second parameter (if no error) will contain the response from the server. 'payload' is an optional object that contains meta-data for the server. If payload exists then the image will be added as a member of the payload object, otherwise an object will be created 'dataImage' should be a data representation of an image created by the call canvas.toDataURL such as is returned by STXSocial.createImage If you are getting a status of zero back then you are probably encountering a cross-domain ajax issue. Check your access-control-allow-origin header on the server side

Parameters:
Name Type Argument Description
dataImage string

Serialized data for image

url string

URL to send the image

payload object <optional>

Any additional data to send to the server should be sent as an object.

cb function

Callback when image is uploaded

Version:
  • ChartIQ plug-in

<static> watermarkPanels(stx)

The panel names in charts are div tags which will not render as images. This method will draw the panel names on the canvas itself. It is called temporarily when creating an image.

Parameters:
Name Type Description
stx object

The chart

Version:
  • ChartIQ plug-in

Class: STXSocial

STXSocial


new STXSocial()

Manages chart sharing and uploading.

Version:
  • ChartIQ plug-in

Classes

Decoration

Methods


<static> brandMyChart(stx, imageURL, positioning, size)

Places a watermark image on the chart for branding. This method should only be called once after you create your chart object -new STXChart()-.

Parameters:
Name Type Description
stx object

The chart

imageURL string

The URL of the image

positioning array

A tuple. The first item of the tuple is the X offset from the edge of the chart. The second item is the Y offset from the top of the chart. Use negative numbers to offset from right of chart or bottom of chart.

size array

A tuple. The first item of the tuple is the width. The second item is the height. Leave out to use actual size.

Version:
  • ChartIQ plug-in
Since:
  • 2016-03-11 Image size can now be specified using the new `size` argument
Example
function runSampleUI(){
		// put your code to establish the behavior of your UI.
		STXSocial.brandMyChart(stxx, "logo.png",[10,-30],[50,50]);
}

<static> createImage(stx [, widthPX] [, heightPX] [, decorationObj], cb)

Create a png image based on the current chart. If widthPX and heightPX are passed in then the image will be scaled to the requested dimensions. This function is asynchronous and requires a callback function. The callback will be passed a data object which can be sent to a server or converted to an image. decorationObj can be used to "decorate" the canvas. For instance, you can add a header or footer to the canvas, or even brand it with an image if you only want the branding done on the shared image but not on the chart itself.

Parameters:
Name Type Argument Default Description
stx object

Chart object

widthPX number <optional>

Width of image to create. If passed then height will adjust to maintain ratio.

heightPX number <optional>

Height of image to create. If passed then width will adjust to maintain ratio.

decorationObj object <optional>
defaultDecorator

A decorator to add custom branding. Pass {} to not use the defaultDecorator.

cb function

Callback when image is available fc(data) where data is the serialized image object

Version:
  • ChartIQ plug-in

<static> uploadImage(dataImage, url [, payload], cb)

Uploads an image to a server. See Python chart-sharing server example for a comple server code. on the server side. The callback will take two parameters. The first parameter is an error condition (server status), or null if there is no error. The second parameter (if no error) will contain the response from the server. 'payload' is an optional object that contains meta-data for the server. If payload exists then the image will be added as a member of the payload object, otherwise an object will be created 'dataImage' should be a data representation of an image created by the call canvas.toDataURL such as is returned by STXSocial.createImage If you are getting a status of zero back then you are probably encountering a cross-domain ajax issue. Check your access-control-allow-origin header on the server side

Parameters:
Name Type Argument Description
dataImage string

Serialized data for image

url string

URL to send the image

payload object <optional>

Any additional data to send to the server should be sent as an object.

cb function

Callback when image is uploaded

Version:
  • ChartIQ plug-in

<static> watermarkPanels(stx)

The panel names in charts are div tags which will not render as images. This method will draw the panel names on the canvas itself. It is called temporarily when creating an image.

Parameters:
Name Type Description
stx object

The chart

Version:
  • ChartIQ plug-in