Home Forums Chart Support Transform jstl view code to thymeleaf code

Transform jstl view code to thymeleaf code

Viewing 4 posts - 1 through 4 (of 4 total)
  • #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"
    	pageEncoding="ISO-8859-1"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <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}";
    		dps[parseInt("${loop.index}")].push({
    			label : label,
    			y : yValue,
    		});
    	</c:forEach>
    </c:forEach>
     
    chart.render();
     
    }
    </script>
    </head>
    <body>
    <div id="chartContainer" style="height: 370px; width: 100%;"></div>
    <script src="https://cdn.canvasjs.com/canvasjs.min.js"></script>
    </body>
    </html>
    #21957

    #21960

    @taszta,

    Please take a look at this sample project for integrating CanvasJS in Spring MVC web-project that uses Thymeleaf template engine as view layer.

    CanvasJS Chart in Thymeleaf

    Also, check out this thread for more information.

    __
    Priyanka M S
    Team CanvasJS

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

You must be logged in to reply to this topic.