Home Forums Chart Support cannot use databiding to create a chart when xVal is date

cannot use databiding to create a chart when xVal is date

Viewing 2 posts - 1 through 2 (of 2 total)
  • #39519

    Gson gsonObj = new Gson();
    Map<Object, Object> map = null;
    List<Map<Object, Object>> list = new ArrayList<Map<Object, Object>>();
    String dataPoints = null;
    try {
    Connection connection = DriverManager.getConnection(“jdbc:sqlserver://localhost:1433;databaseName=NestF;instanceName=SQLEXPRESS”, “sa”, “123”);
    Statement statement = connection.createStatement();
    String xVal, yVal;
    ResultSet resultSet = statement.executeQuery(“SELECT FORMAT (b.time, ‘yyyy-MM-dd’) as date, SUM(b.total) as total FROM tblBill b JOIN tblStatus s ON b.statusID = s.statusID WHERE b.statusID = 4 GROUP BY FORMAT (b.time, ‘yyyy-MM-dd’) Order by FORMAT (b.time, ‘yyyy-MM-dd’) asc”);
    while (resultSet.next()) {
    xVal = resultSet.getString(“date”);
    yVal = resultSet.getString(“total”);
    map = new HashMap<Object, Object>();
    map.put(“x”, java.util.Date.parse(xVal));
    map.put(“y”, Float.parseFloat(yVal));
    dataPoints = gsonObj.toJson(list);
    } catch (SQLException e) {



    X-Value can either be numeric or JavaScript date-time. In your case, it seems to be Java date-object. Passing it as timestamp as shown in this Gallery Example should work fine in this scenario.

    If you are still facing issue, kindly create a sample project reproducing the issue & share it with us over Google-Drive or Onedrive so that we can run the sample locally to understand the scenario better and help you out.

    From what we have observed, sometimes things get delayed mostly when we are not able to reproduce the issue or not able to understand the exact scenario, or the solution that we provide may not work properly due to the variation in chart options being used by you and us.

    Having a sample project helps us in figuring out the issue and suggesting an appropriate solution accordingly.

    Vishwas R
    Team CanvasJS

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

You must be logged in to reply to this topic.