var chart = new Cosfire.Chart("chart-div",{width:500,
height:300});
/* Create instance of Titles */
var title1 = new Chart.Title({text: 'Main Title', fontSize:44});
var title2 = new Chart.Title('Subtitle');
var title3 = new Chart.Title({ text: 'Subtitle', fontSize: 12 });
/* Add the titles to chart */
chart.titles.add(title1);
chart.titles.add(title2);
chart.titles.add(title3);
var data = [{
plotAs: 'column',
points: [
{y: 15, xLabel: "A"},
{y: 15, xLabel: "B"},
{y: 26, xLabel: "C"},
{y: 55, xLabel: "D"},
{y: 42, xLabel: "E"},
{y: 70, xLabel: "F"},
{y: 50, xLabel: "G"},
{y: 95, xLabel: "H"}
]
}
];
chart.setData(data);
chart.render();
var chartJSON = {
width: 500,
height: 300,
titles :[{ text: 'Main Title', fontSize:44 },
{ text: 'Subtitle' },
{ text: 'Subtitle', fontSize: 12 }],
data: [{plotAs: 'column',
points: [{ y: 15, xLabel: "A" },
{ y: 15, xLabel: "B" },
{ y: 26, xLabel: "C" },
{ y: 55, xLabel: "D" },
{ y: 42, xLabel: "E" },
{ y: 70, xLabel: "F" },
{ y: 50, xLabel: "G" },
{ y: 95, xLabel: "H" }]
}]
};
var chart = new Cosfire.Chart("chart-div", chartJSON);
chart.render();
| Title Properties | ||||
| Property | Type | Default | Possible Values | Description |
|---|---|---|---|---|
| text | String |
auto | Any positive number | Text of the title. |
| hAlign | String |
center | • left • center • right | Horizontal Alignment of the Title. |
| vAlign | String |
center | • top • center • bottom | Vertical Alignment of the Title. |
| margin | Array(Number) |
[0,5,5,0] | [left, top, right, bottom] | Margin of the title. All values must be defined in the array. |
| background | String |
white | Colors are specified using predefined color names, or RGB, HEX, HSL, RGBA, HSLA values. | code Background of the chart. |
| fontSize | Number |
24 | Number > 0 | Size of the font in pixel. |
| fontColor | String |
#000000 | Colors are specified using predefined color names, or RGB, HEX, HSL, RGBA, HSLA values. | The fontColor property is used to set the color of the text. |
| fontStyle | String |
normal |
|
Style of the title font. |
| fontFamily | String |
Arial |
|
Any browser supported font family or installed google font. |
| fontWeight | String |
normal |
|
--- |