Insert chart from extension into document

Purpose

To insert the chart from extension into the current writer document.

Syntax

WriterClient.dispatch("insertChart", <chart_data_variable>).then(function(response){console.log("response::"+response);

Data Parameters

ParameterData TypeDescription
Mandatory Parameters
typeString

Specify the type in which the chart needs to inserted.

 

Possible values: Column / Stacked Column / Bar / Stacked Bar / Line / Pie / Doughnut / Spider Web

seriesString

A series in a chart is a set of related data points that are plotted together to show trends, correlations, or comparisons. A chart can have one or more series.

 

Possible values: singleseries / multiseries

data{
  “labels”: [“user1”, “user2”, “user3”],
  “values”: [60, 76, 89],
  “colors” : ["#456790", "rgb(35,64,222)", "yellow"]
   },

Specify the data to be displayed in the inserted chart.

 

Note: 'colors' key is optional. It's value can be passed in 3 ways as shown in the sample using hexa code. 

Optional Parameters
heightIntegerSpecify the height of the chart to be inserted.
widthIntegerSpecify the width of the chart to be inserted.
legend{
"enabled" : <boolean_value>
},
A legend in a chart is a box that shows the data represented in the chart's Y-axis. 
axis{
"x" : {
    "labels" : <boolean_value>,
    "grid" : <boolean_value>
        },
"y" : {
    "labels" : <boolean_value>,
    "grid" : <boolean_value>
        }
}

In a chart, axes are lines that measure data and determine how data maps to a pixel value.

 

There are two types of axes;

1. Horizontal axis or X-axis

2. Vertical axis or Y-axis

Sample data with HTML

Copiedstudent_details =  { 
  "type" : "Bar" ,  
  "height" : 450, 
  "width" : 450, 
  "series" : "singleseries",  
  "data" : {
    “labels”: [“student1” , “student2” , “student3”],
    “values”: [60, 76, 89],
    “colors” : ["#456790", "rgb(35,64,222)", "yellow"]
   },
   "legend" : {
       "enabled" : true
   },
   "axis" : {
  "x" : {
         "labels" : false,
         "grid" : true
  },
  "y" : {
      "labels" : true,
      "grid" : true
   }
 }
}

The student details chart needs to be inserted from extension into the document as shown below;  

WriterClient.dispatch("insertChart", student_details).then(function(response){console.log("response::"+response);