Home forums Chart Support Transform jstl view code to thymeleaf code

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #21956

    Hello everybody,

    I’m using Thymeleaf template in place of jsp and i woul like to convert this code of the view in thymeleaf code .

    thank you in advance for any advice

    <!– chart.jsp–>
    <%@ page language=”java” contentType=”text/html; charset=ISO-8859-1″
    <%@taglib prefix=”c” uri=”http://java.sun.com/jsp/jstl/core”%&gt;
    <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”&gt;
    <meta http-equiv=”Content-Type” content=”text/html; charset=ISO-8859-1″>
    <script type=”text/javascript”>
    window.onload = function() {

    var dps = [[]];
    var chart = new CanvasJS.Chart(“chartContainer”, {
    exportEnabled: true,
    animationEnabled: true,
    theme: “light2”, // “light1”, “dark1”, “dark2”
    title: {
    text: “Visitor Demographics of a Website”
    subtitles: [{
    text: “Age Groups of Visitors”
    data: [{
    type: “pie”,
    yValueFormatString: “#,##0\”%\””,
    indexLabel: “{label} – {y}”,
    dataPoints: dps[0]

    var yValue;
    var label;

    <c:forEach items=”${dataPointsList}” var=”dataPoints” varStatus=”loop”>
    <c:forEach items=”${dataPoints}” var=”dataPoint”>
    yValue = parseFloat(“${dataPoint.y}”);
    label = “${dataPoint.label}”;
    label : label,
    y : yValue,


    <div id=”chartContainer” style=”height: 370px; width: 100%;”></div>
    <script src=”https://canvasjs.com/assets/script/canvasjs.min.js”></script&gt;




    Passing dataPoints to charts in the above thymeleaf code should work fine in your case.

    Here is a thread which might be of help.

    Priyanka M S
    Team CanvasJS


    Try here another solution

    Spring MVC with Thymeleaf

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.