SAV Charts was originally designed to build chart configurations through XML
tags instead of JavaScript. Markers can be introduced in templates. Data can also
be changed through XML either manually or using query managers.
Important
Starting with version 14.5.0 of SAV Charts, a new parser based solely on
Fluid and specific viewHelpers has been introduced.
Thanks to Fluid syntax, it simplifies writing complex charts and using references.
While generating charts is faster with the XML parser, writing complex code is much
simpler with the Fluid parser.
The following charts type are available :
Bar charts
Bubble charts
Doughnut charts
Line charts
Pie charts
Polar area charts
Radar charts
Stacked bar charts
Horizontal bar charts
Scatter Line Charts
Charts can also be combined (Combo charts), e.g. a
bar chart with a line chart
Tip
SAV Charts is provided with several basic templates and more advanced
templates which simplify the implementation of charts with several sets of data.
XML Templates are in the directory Resources/Private/Templates/ChartsExamples.
XML templates were also converted to Fluid templates and are available in
Resources/Private/Templates/ChartsExamples/FluidParser.
The following screenshots are obtained with the provided basic templates.
Screenshots
Bar Chart
Bubble Chart
Doughnut Chart
Horizontal Bar Chart
Horizontal Stacked Bar Chart
Line Chart
Pie Chart
Polar Area Chart
Radar Chart
Scatter Chart
Stacked Bar Chart
Combination Chart
Users Manual
Download and install the extension in your site's
dependencies. The extension comes with default site
settings.
Read the tutorial section.
Administration
Important
The flag Allow queries (Admin) must be set by an Admin user in the content
Flexform to execute queries.
Warning
This extension generates raw JavaScript codes from the chart configurations
in the backend.
Most often, simple configurations are taken from the Chart.js documentation.
However, more complex configurations can be entered. As stated in the TYPO3
Security Guide, "Even if editors do not insert malicious code intentionally,
sometimes the lack of knowledge, expertise or security awareness could put
your website under risk".
Admin users should be careful before granting the rights for backend users
to enter charts.
The SAV Charts is provided with an upgrade wizard
that converts the existing
Flexforms on your website. The upgrade wizard adds
three sheets to the Flexforms
(see Plugin Interface). It also duplicates existing
XML parser configurations as closely as possible
to Fluid parser configurations.
Reference
Starting with version 14.5.0, SAV Charts is provided with two template
parsers.
All tag attributes can take a value or be a reference to a specific tag.
The allowed syntaxes are:
tag#id. The attribute value will be replaced by the tag whose ID is id (tags can be any allowed tag as marker, data, barChart...).
See for example the provided template barCharts.xml in which there is the following line. The attribute value is replaced by the
marker whose ID is labelSet1.
<itemkey="label"value="marker#labelSet1" />
Copied!
tag#id:integer1. The tag whose ID is id must be an array. The attribute value will be replaced by the item at the position given by integer1.
tag#id:integer1-integer2. The tag whose ID is id must be an array. The attribute value will be replaced by the sub-array starting at integer1 and ending at integer2.
for#id:value. The tag is replaced by the curent value of the attribute each in the <for> tag.
for#id:key. The tag is replaced by the curent key of the attribute each in the <for> tag.
tag#id:for#idFor:key. The tag whose ID is id must be an array. The attribute value will be replaced by the item at the position given by key
of the current each attribute of the <for> tag whose ID is IdFor.
tag#id:for#idFor:value. The tag whose ID is id must be an array. The attribute value will be replaced by the item at the position given by value
of the current each attribute of the <for> tag whose ID is IdFor.
Tip
Examples of such syntaxes can be found in the file Resources/Private/ChartsExamples/BarChartAdvanced.xml
which builds a flexible template able to display upto 9 data sets with 9 different colors in the same charts as explained
in the tutorial section.
Sets the values from a comma separated list of data.
Attributes
values (required): comma separated list of data.
callback
callback
<callbackkey="callbackKey">callbackFileName.js</callback><callbackkey="callbackKey"><!-- JavaScript function --></callback>
Copied!
Type
Method
Description
Defines a callback. The javacript function can be provided by means of a file name or
inserted inserted inline inside an XML comment (see the FAQ section for an example).
Attributes
key (required): the key for the callback.
changeToPercentage
changeToPercentage
<changeToPercentage />
Copied!
Type
Method
Description
Changes the data to percentage.
Attributes
precision: the precision for rounding floats (default value is 1).
item
item
<itemkey="myKey"value="tag#id" /> or
<itemkey="myKey"value="5" /> or
<itemkey="myKey"values="1, 3, 5" /> or
<itemkey="myKey">5</item>
Copied!
Type
Method
Description
Sets a data item either by means of a reference, a value or a comma-separated list of values.
Attributes
key (required): the key for the item.
value: if set, the value is defined directly or by the reference, for example data#myDataId.
If value is equal to true or false then a boolean value is generated for this item.
type: if this attribute is equal to function, the value attribute is taken as
the name of a JavaScript function.
values: if set, a comma-sparated list of values is assumed.
if no value or values attribute is provided, the tag childs can be a value or other <item> tags.
field (required): the field to extract from the query result.
groupby: it set, either the size of the reference defined by the tag and the id, for example "data#myDataId",
or the given integer, will be used to group the data. It means that an new array element will be generated
each time the count is reached. This option is useful to display data when GROUP BY clause is used in the query.
Defines the markerby concatenating the attributes.
Attributes
Any attribute name can be used. The resulting marker is the concatenation of
all attribute values.
In the following exemple, the marker myMarkerId has the value
Number of pages created per year.
<markerid="myMarkerId"><setMarkerByPiecespart1="Number of "part2="pages created "part3="per year" /></marker>
Copied!
This method is useful when markers include information from a query, for example. In this case,
a part is a reference to the data generated by the query.
Tip
Using \n in an attribute value generates a newline break.
Defines the query manager associated with the query.
Attributes
name (required): Unless you have define you own query manager, use savcharts.
uid (required): The uid of your query. Queries are defined in the backend.
other attributes define markers that can be used in the query clauses. In these clauses ###myMarker### will be
replaced by the value of the marker myMarker. Any attribute
name, except name and uid can be used.
Markers can be directly defined as, for example, myMarker#myValue.
In that case, the marker name will be myMarker and its value is myValue.
Markers can be defined as a reference to a marker tag, for example marker#myMarker.
In that case, the marker name will be myMarker and its value is the value of the marker
whose id is myMarker.
Markers can also be defined as a reference to a specific element in a data or marker array,
for example myMarker#data#myData:0. In that case, the marker name will be myMarker
and its value is obtained from the data with index 0 and whose id is myData.
The following ViewHelpers may be used to build charts:
<c:barChart>
<c:bubbleChart>
<c:doughnutChart>
<c:horizontalBarChart>
<c:horizontalStackedBarChart>
<c:lineChart>
<c:pieChart>
<c:polarAreaChart>
<c:radarChart>
<c:scatterBarChart>
<c:stackedBarChart>
All of them have the same arguments.
Note
The types available in Charts.js are only bar, bubble, doughnut,
line, pie, polarArea, radar, and scatter.
Therefore, the horizontalBarChart, horizontalStackedBarChart
and stackedBarChart facilities were introduced to avoid
the need to configure the bar type.
The following arguments are available for the query ViewHelper:
id
id
Required
true
Type
string
Query ID
manager
manager
Type
string
Query manager
uid
uid
Type
string
UID of the query record
Note
The query will only be processed if the manager
and UID arguments are provided. These arguments
are not defined as required for compatibility
with the XML parser.
The plugin contains a Flexform for configuring
the XML and Fluid parsers. Both codes can exist
simultaneously.
If you already have XML code on your web
server, an updater will transfer the original
to the XML parser tab. An automatic conversion
will also be introduced to the Fluid parser
tab. A debug feature has been introduced
in the Fluid parser.
In layout mode, the SAV Charts plugins are displayed
with a modified header that provides additional
information about the parser in use and the possible
debug mode for the Fluid parser.
The plugin options contain three tabs. The first tab
is for general configuration. This includes selecting
the parser type and granting the right to use queries.
The latter must be granted by an admin user.
The second tab is for XML parser configuration.
It contains the same fields as the previous version
of the SAV Charts extension.
The third tab is for the Fluid parser configuration.
This contains the same fields as the second tab, plus
a debug feature.
Parsers
The XML parser is a parser that was developed
for TYPO3 6.2 and later versions. Based mainly
on the PHP class SimpleXMLElement, it provides
fast chart generation. However, the PHP code is
complex. XML templates lack readability when
iterative processing is required.
The new Fluid parser is entirely based on Fluid
syntax and viewHelpers. Since all Fluid viewHelpers
can be used (e.g. <f:for>, <f:if>, and <f:variable>)
the Fluid parser results in simpler templates when
iterative processing is required. It also provides
simpler PHP code and makes it possible to use or
develop other viewHelpers.
The SAV Charts extension includes templates for all chart types.
These templates can be found in
Resources/Private/Templates/ChartExamples for the XML parser
and Resources/Private/Templates/ChartExamples/FluidParser for the Fluid
parser.
To display a template, simply create an SAV Charts
plugin content element on a page.
Then click on the plugin tab and select the parser type.
Fill in the template field of the Flexform corresponding to the selected parser type, then save.
Important
Use the EXT: prefix to reference the template file from the extension.
Go to the front-end and you should see the following image.
Writing Templates
The templates provided with the extension were
adapted from the examples given in the
Chart.js documentation.
Let us illustrate the principle for the line chart.
The JavaScript code to display the line graph is
as follows:
The template is created by converting the JavaScript
code into an XML structure with the data tag.
Thanks to the data tag ID, references can be used
and applied.
These references provide an easy way to split the
data, making it possible to overload them in the
FlexForm data section or with queries.
The following codes are the XML or Fluid translations of the
previous JavaScript code. Data tags with the IDs
"labels," "dataSet1," and "dataSet2" can be easily
overloaded, as explained in the next section.
<?xml version="1.0" encoding="UTF-8"?><charts><lineChartid="1"data="data#lineChartData"options="data#lineChartOptions" ><markerid="labelSet0">My First dataset</marker><markerid="labelSet1">My Second dataset</marker><dataid="labels">
January, February, March, April, May, June, July
</data><dataid="dataSet0">
65, 59, 80, 81, 56, 55, 40
</data><dataid="dataSet1">
28, 48, 40, 19, 86, 27, 90
</data><dataid="set0"><itemkey="label"value="marker#labelSet0" /><itemkey="backgroundColor">rgba(220,220,220,0.2)</item><itemkey="pointColor">rgba(220,220,220,1)</item><itemkey="pointBackgroundColor">#fff</item><itemkey="pointHoverBackgroundColor">rgba(220,220,220,1)</item><itemkey="data"value="data#dataSet0" /></data><dataid="set1"><itemkey="label"value="marker#labelSet12" /><itemkey="backgroundColor">rgba(151,187,205,0.2)</item><itemkey="pointColor">rgba(151,187,205,1)</item><itemkey="pointBackgroundColor">#fff</item><itemkey="pointHoverBackgroundColor">rgba(151,187,205,1)</item><itemkey="data"value="data#dataSet1" /></data><dataid="dataSets"><itemkey="0"value="data#set0" /><itemkey="1"value="data#set1" /></data><dataid="lineChartData"><itemkey="labels"value="data#labels" /><itemkey="datasets"value="data#dataSets" /></data><dataid="lineChartOptions"></data></lineChart></charts>
Copied!
<c:charts><c:lineChartid="1"data="data__lineChartData"options="data__lineChartOptions" ><c:markerid="labelSet0">My First dataset</c:marker><c:markerid="labelSet1">My Second dataset</c:marker><c:dataid="labels">
January, February, March, April, May, June, July
</c:data><c:dataid="dataSet0">
65, 59, 80, 81, 56, 55, 40
</c:data><c:dataid="dataSet1">
28, 48, 40, 19, 86, 27, 90
</c:data><c:dataid="set0"><c:itemkey="label"value="{marker__labelSet0}" /><c:itemkey="backgroundColor">rgba(220,220,220,0.2)</c:item><c:itemkey="pointColor">rgba(220,220,220,1)</c:item><c:itemkey="pointBackgroundColor">#fff</c:item><c:itemkey="pointHoverBackgroundColor">rgba(220,220,220,1)</c:item><c:itemkey="data"value="{data__dataSet0}" /></c:data><c:dataid="set1"><c:itemkey="label"value="{marker__labelSet1}" /><c:itemkey="backgroundColor">rgba(151,187,205,0.2)</c:item><c:itemkey="pointColor">rgba(151,187,205,1)</c:item><c:itemkey="pointBackgroundColor">#fff</c:item><c:itemkey="pointHoverBackgroundColor">rgba(151,187,205,1)</c:item><c:itemkey="data"value="{data__dataSet1}" /></c:data><c:dataid="dataSets"><c:itemkey="0"value="{data__set0}" /><c:itemkey="1"value="{data__set1}" /></c:data><c:dataid="lineChartData"><c:itemkey="labels"value="{data__labels}" /><c:itemkey="datasets"value="{data__dataSets}" /></c:data><c:dataid="lineChartOptions"></c:data></c:lineChart></c:charts>
Copied!
Tip
<data> were inserted inside the <lineChart>
tag just by personal choice.
They could have been provided before
the <lineChart> tag. In that case, the tag
would have no content and would simply be written
as follows:
Go in the front-end and you should see the following figure.
In SAV Charts, the principle is that the first
definition is used for a given tag with a given ID.
In the previous example, for instance,
the dataSet0 and dataSet1 tags are defined in
the data section before the template section.
Consequently, they will not be replaced by the
same data tags in the template.
The tags in the data section overload the same
tags in the template.
This provides a simple way to work with generic
templates and adapt their behavior to your data.
For example, with the same "LineChart.xml"
template, you may want to display only one curve.
This can easily be achieved by defining the
"dataSets" tag in the data section, as shown
below.
Enter the previous code in the FlexForm Data section.
Then, save and go to the front end.
Note
In very specific cases, you can explicitly allow
overloading of a given tag by setting the Overload attribute
to 1. This feature is used to build a flexible XML template in the file
Resources/Private/Templates/ChartExamples/LineChartAdvanced.xml.
Overloading Markers
Markers are tags that can be used to create strings.
In the line chart template, two markers are used
to define the labels that are displayed in the legend.
You can overlay the markers in the Markers section
of the Flexform. Enter the following code in
the Markers and Data sections. Then, save and go to
the front-end.
Options are defined in the Chart.js documentation. They can be set by
overloading the <data> tag associated with the options
attribute of the chart.
In the LineChart.xml template, for example, the chart
is defined as follows:
The options attribute is a reference to the
<data> tag whose ID is lineChartOptions.
Overloading this tag in the Data section of the
Flexform will set the options.
Assume that the Data section is still configured
with a modified label.
Add the following code to the Data section
of the Flexform. This will cancel the animation,
set a linear interpolation between points, and display
the line a width of 10 points.
A linear interpolation is obtained by setting the
tension to 0 in Chart.defaults.global.elements.line
(see Chart.js documentation).
Since the global options are in the <data>
whose ID is lineChartOptions, nested items whose
keys are elements and line provide
access to Chart.defaults.global.elements.line.
Tip
To generate a Boolean value, set the attribute value
to true or false.
Using Advanced Templates
SAV Charts provides more complex templates.
They can display up to nine items on the same
chart.
The colors are defined in a specific template,
either DefaultColors.xml for the XML parser
or FluidParser/DefaultColors.fluid for the
Fluid parser. These colors were chosen to
provide contrast between items.
To illustrate the use of advanced templates,
consider the LineChartAdvanced.xml template or
the FluidParser/LineChartAdvanced.fluid
template.
Enter the following code in the template section,
then save and go to the front end.
Enter the following code in the marker section, then save and go to the front-end.
<markerid="title">A line chart with two curves</marker><markerid="labelSet0">Curve 1</marker><markerid="labelSet1">Curve 2</marker>
Copied!
<c:markerid="title">A line chart with two curves</c:marker><c:markerid="labelSet0">Curve 1</c:marker><c:markerid="labelSet1">Curve 2</c:marker>
Copied!
Using and Developing Query Managers
Query managers are used in <query> tags to execute
queries that can be used in charts.
The SAV Charts extension comes with an internal query
manager named savcharts that can
handle TYPO3 database queries as well as queries
from other databases.
Using the Query Manager
In the backend in Records mode create a new record
in a page or a folder.
Select Database if you need to access to an external database,
fill the different fields and save.
Tip
You do not need to create a new database access if you only need
to access to the current TYPO3 database.
Select Query to create a query. Select a database (default is
TYPO3 Database), fill the different clauses and save.
The following configuration is an example of how to obtain the
number of pages created per year.
In SELECT clause field
COUNT(*) AS Count,
YEAR(FROM_UNIXTIME(crdate)) AS Year
Copied!
In FROM clause field
pages
Copied!
In WHERE clause field
NOT deleted AND NOT hidden
Copied!
In GROUP BY clause field
year
Copied!
The following query is generated by this configuration.
The default query manager, savcharts, is used
in the Queries section. It calls the query
with the UID 1.
The Data section of the FlexForm overloads
the template to display a single bar chart
with data from the query, as explained
in Using Advanced Templates.
Go to the front-end to view the resulting chart.
Using Markers in Queries
Markers can be used in queries. For example,
assume that the previous query should return
the number of pages created between the
years yearMin and yearMax.
First, insert the syntax ###marker### into
the WHERE clause of the previous content element
in the query.
NOT deleted AND NOT hidden AND YEAR(FROM_UNIXTIME(crdate)) BETWEEN ###yearMin### AND ###yearMax###
Copied!
Add markers to the Flexform field of your chart,
then save and go to the front-end.
<markerid="title">Analysis of the site</marker><markerid="labelSet0">Pages per year</marker><markerid="yearMin">2010</marker><markerid="yearMax">2020</marker>
Copied!
<c:markerid="title">Analysis of the site</c:marker><c:markerid="labelSet0">Pages per year</c:marker><c:markerid="yearMin">2010</c:marker><c:markerid="yearMax">2020</c:marker>
Copied!
You can also introduce markers in TypoScript.
For example, add the following TypoScript to
your page to modify only the value of the
###yearMin### marker, then clear the cache and
go to the front-end. The syntax customQuery.1 refers
to the query with the UID of 1.
plugin.tx_savcharts.settings.customQuery.1 {
yearMin = TEXT
yearMin.value = 2009
}
Copied!
Developing Your Query Manager
Query managers are implemented by means of hooks.The hook for the internal query manager
is in Classes/Hooks/SavChartsQueryManager.php. This class extends the abstract class
AbstractQueryManager (Classes/Hooks/AbstractQueryManager.php)
which itself implements the interface QueryManagerInterface
(Classes/Hooks/QueryManagerInterface.php).
You can develop your own query manager by providing a hook which must
be added in the file ext_localconf.php
of your extension.
Assuming that your vendor name is MyVendorName and your extension
name is my_extension. Assuming also
that you have written your manager as the class MyQueryManager
in Classes/Hooks/MyQueryManager.php.
Finally, assuming that you want to name your query manager myManager, you should add
the following code in ext_localconf.php of your extension.
You can easily export data associated with any chart using the exportCSV method
associated with the <charts> tag (see Chart Tags).
Assuming that you want to export data associated with the line chart template with
a row header containing the x-axis labels and a column header containing the legend labels of
the two curves. Add the following code to the Templates field of the Flexform.
With the XML parser, the file name is
img_ContentId_ChartNumber, where ContentId
is the UID of the content element and ChartNumber
is the ID of the chart, starting from 0.
In the front-end you should see an icon to open the file.
With the Fluid parser, the file name is
provided in the argument fileName.
Note
No icon is displayed in the front-end.
Converting Basic XML Templates to Fluid Templates
Introduction
The conversion process is quite simple.
Prefix all tags with c:.
References are written as tag__id instead of tag#id.
This change is because the character # is not permitted in Fluid variable names.
To get the value associated with a reference, use the
conventional Fluid accessor for variables, i.e. {tag__id}.
Note
Parameters in chart tags (data, options, width, and height),
can be values or references.
If they are values, they must be specified directly, for example width="600",
or obtained using an accessor. For example
{data__width} can be used if <c:data id="width" value="600"/>
is called before the chart tag.
As references, the related tags can be defined before
or inside the chart tag. Therefore, the best
practice for data and options is to always
use references.
Converting Advanced XML Templates to Fluid Templates
Advanced templates are designed to display multiple
sets of data on the same chart. Between one and
nine sets of data can be displayed on the same chart.
As colour label sets and data sets are built
iteratively, a special "<for>" was introduced in
the XML parser. This leads to complex statements
and poor readability.
In Fluid-based templates, however, conventional
Fluid syntax and viewHelpers can be used. Therefore,
using the "<f:for>" viewHelper greatly improves
readability.
Let us illustrate this point with part of the
"LineChartsAdvanced.xml" template. The "<for>"
tags in the following excerpt contain data
with ids "data" and "labels", as well as
intermediate data tags with ids "initData"
and "initLabels", which are used to build them.
The Fluid-based version uses simpler code
thanks to the "<f:for>" viewHelper.
<!-- Defines the data --><forid="initData"each="data#lowIntensityColors"><dataid="initData"overload="1"><itemkey="for#initData:key"value="data#sampleData" /></data></for><dataid="data"><setDatavalues="data#initData" /></data><!-- Defines the labels --><forid="initLabels"each="data#data"><markerid="labelSetId"overload="1"><setMarkerByPiecespart1="labelSet"part2="for#initLabels:key" /></marker><markerid="marker#labelSetId"><setMarkerByPiecespart1="Label "part2="for#initLabels:key" /></marker></for>
Copied!
<!-- Defines the data --><c:dataid="data"><f:foreach="{data__lowIntensityColors}"as="color"key="key"><c:itemkey="{key}"value="{data__sampleData}" /></f:for></c:data><!-- Defines the labels for the set --><f:foreach="{data__data}"as="value"key="key"><c:markerid="labelSet{key}"value="labelSet {key}"/></f:for>
Copied!
Similarly, the following excerpt shows how data with the id "dataSets"
were set, using markers with ids "setId" and "labelSetId". They
are needed to generate new markers with ids "labelSet0", "labelSet1"...
and the items with ids 0, 1... for "dataSets".
Once again, Fluid syntax makes it simpler because accessors can
be used in accessors. For example, "{data__lowIntensityColors.{key}}"
returns the value at the position given by "key" in the data with the
id "lowIntensityColors".
SAV Charts viewHelpers can be used in any
HTML template processed by Fluid.
The following example illustrates how to
integrate a bar chart that displays
the number of pages created per year
(see Using and Developing Query Managers).
{namespace c=YolfTypo3\SavCharts\ViewHelpers}
<c:markerid="title">Analysis of the site</c:marker><c:markerid="labelSet0">Pages per year</c:marker><c:queryid="1"manager="savcharts"uid="1" /><c:dataid="labels"values="{query__1.Year}" /><c:dataid="data"><c:itemkey="0"value="{query__1.Count}" /></c:data><c:templateid="1">
EXT:sav_charts/Resources/Private/Templates/ChartsExamples/FluidParser/BarChartAdvanced.fluid
</c:template><canvasid="canvas{canvases.0.chartId}"width="{canvases.0.width}"height="{canvases.0.height}"></canvas>
Copied!
Note
The Fluid variable canvases contains information
on the created charts, starting from 0. Therefore,
canvases.0.chartId is the ID of the first chart
in EXT:sav_charts/Resources/Private/Templates/ChartsExamples/FluidParser/BarChartAdvanced.fluid.
Frequently Asked Questions
Warning
SAV Charts is now using Chart.js 4.x. Several breaking changes were made in
Chart.js 3.0 and Chart.js 4.0 (see 3.x Migration Guide
and 4.x Migration Guide).
All templates in Resources/Private/Templates/ChartsExamples
were modified to take these changes into consideration.
If you are upgrading Sav Charts, you may have to modify your templates.
You can change the default y-axis (or x-axis) properties using the options for the chart.
For example, assume that the y-axis for the lineChart example has to be changed so that
the minimum is 10, the maximum is 100 and the step is 5.
Add the following configuration in the data section or in your template.
You can easily adapt the previous configuration to other cases by translating
the JavaScript configuration examples given in the Charts.js documentation.
The translation is simple:
Replace options by a <data id="..."> ... </data> where the id is the identifier for the chart options (it is defined in the template).
Replace opening braces by <item> tags with attributes as keys.
Replace open brackets, if any, by <item> tags with keys equal to 0.
Replace simple attributes inside braces by <item /> tags with key and value attributes.
Replace closing braces or brackets by </item> tags.
Replace options by a <c:data id="..."> ... </c:data> where the id is the identifier for the chart options (it is defined in the template).
Replace opening braces by <c:item> tags with attributes as keys.
Replace open brackets, if any, by <c:item> tags with keys equal to 0.
Replace simple attributes inside braces by <c:item /> tags with key and value attributes.
Replace closing braces or brackets by </c:item> tags.
For example, the following code changes also the label style of the x-axis.
A callback is used to modify the tick labels.
In Chart.js 3.0 , the former xAxes and yAxes arrays in scales were removed.
How to Modify the Tooltip Format?
The tooltip format can be modified using callbacks that are provided with Chart.js.
For example let us assume that data provided with the Pie Chart example
are in €. Let us also assume that we want to change the tiptool content
in order to have label - value € instead of the defaut format label:value.
Chart.js library allows to modify several behaviors by means of callbacks.
Please consult the Chart.js documentation for details.
The tooltip label can been changed by means of the label callback in tooltip options.
Inline JavaScript Function
Add the following configuration in the data section or in your template.
In Chart.js 3.0 tooltips was renamed tooltip and
is now in the plugins item of the options. A tooltip item context is avaible in callbacks.
For more information see the tooltip section
in Chart.js documentation.
JavaScript Function in a File
When the JavaScript function associated with the callback is more complex,
you can also put it in a file and call that file in the callback
as shown in the following configuration.
An example which combines a bar chart and a line chart is provided in the directory
Resources/Private/Templates/ChartsExamples. Create a new graph then, in the template
section, enter the following code, save and go to the front-end.
The file ComboChart.xml is very similar to the file BarChart.xml. Only slight changes were made.
The type attribute of the second dataset is set to line and the fill attribute to false.
New tables with their fields are represented with a Black border.
Existing tables are represented with a Dark green border. Only existing fields
uid and pid are shown. If new fields are created, they are shown
in Light blue.
1-n relations are in Dark blue.
n-n relationships are in Dark red with the name of the associated mm table.
Changelog
Version
Changes
14.5.0
New parser based on Fluid and viewHelpers added.
Version of Chart.js changed to 4.5.1.
14.4.0
Compatibility changed to TYPO3 13.4.x and 14.3.x.
13.4.0
Compatibility changed to TYPO3 12.4.x and 13.4.x.
Version of Chart.js changed to 4.4.5.
11.5.0
Compatibility changed to TYPO3 11.5.x.
Version of Chart.js changed to 3.6.0.
11.2.0
Compatibility changed to TYPO3 11.2.x.
Version of Chart.js changed to 3.2.1.
Scatter graph added with example.
Combination graph example added.
10.4.0
Compatibility changed to TYPO3 10.4.x.
10.3.0
Compatibility changed to TYPO3 10.3.x.
Version of Chart.js changed to 2.9.3.
True or false values and use of functions outside callbacks added (issue #1).
9.5.0
Version of Chart.js changed to 2.9.2.
Compatibility changed to TYPO3 9.5.x.
Documentation updated to docker.
0.5.0
Version of Chart.js changed to 2.7.0.
Compatibility to TYPO3 6.2 removed.
Compatibility changed to TYPO3 9.0.
0.4.0
Version of Chart.js changed to 2.7.0.
composer.json added.
Vendor name changed.
0.3.2
Default type for stacked option changed to boolean.
0.3.1
Small bug corrected in the use of file callback functions (thanks to Holger Birkner for reporting this bug).
0.3.0
Processing of callback functions and plugins added.
Documentation updated.
Version of Chart.js changed to 2.5.0.
0.2.1
Documentation updated.
Version of Chart.js changed to 2.4.0.
Compatibility changed to TYPO3 8.9.
0.2.0
BeginAtZero becomes the default option for line charts.
Subitems may contain data items like setDataFromQuery.
New templates added for horizontal bar charts, horizontal stacked bar charts and
bubble bar charts.
Compatibility changed to TYPO3 8.3.
Version of Chart.js changed to 2.2.2
0.1.0
SAV Charts modified for Version 2.1.6 of Chart.js
Advanced templates added.
0.0.2
Small changes to remove the use of deprecated methods.
Compatibility changed to TYPO3 8.0.
0.0.1
1st public release.
Sitemap
Reference to the headline
Copy and freely share the link
This link target has no permanent anchor assigned.The link below can be used, but is prone to change if the page gets moved.