Search code examples
csvlocalzingchart

Please help to display chart with csv


I am trying to display temperature chart depending on time.

That's an extract of my csv file 'temperature1.csv' from my ressources diurectory:

Date heure,Chambre d'amis,salon,Salle de Bain,Chambre,Dehors 07/10/15 151006,24,23.299999237061,22.799999237061,22.39999961853,28.89999961853 07/10/15 151506,24,23.299999237061,22.89999961853,22.5,28.89999961853 07/10/15 152006,24,23.299999237061,22.89999961853,22.5,28.89999961853 07/10/15 152506,24,23.299999237061,22.89999961853,22.5,28.89999961853 07/10/15 153006,24,23.299999237061,22.89999961853,22.60000038147,29.5 07/10/15 153506,24.10000038147,23.39999961853,22.89999961853,22.60000038147,29.60000038147 07/10/15 154006,24.10000038147,23.39999961853,22.89999961853,22.60000038147,29.700000762939 07/10/15 154506,24.10000038147,23.39999961853,22.89999961853,22.60000038147,29.89999961853 07/10/15 155006,24.10000038147,23.39999961853,23,22.700000762939,29.799999237061 07/10/15 155506,24.10000038147,23.5,23,22.700000762939,30.10000038147 07/10/15 160010,24.10000038147,23.5,23,22.700000762939,30.299999237061 07/10/15 160506,24.10000038147,23.5,23,22.799999237061,30.39999961853

The first line represent header, and the following line represent datas.

That's the html code :

<!DOCTYPE html>
<html>
<head>
<!--Script Reference[1]-->
<script src="./zingchart/zingchart.min.js"></script>
<script>
    var chartData={
        "csv":{
        "url":"./ressources/temperature1.csv",
        "horizontal-labels":true
    };
    window.onload=function(){  // Render Method[2]
        zingchart.render({ 
            id:'chartDiv',
            data:chartData,
            height:400,
            width:600
        });
    };
</script>
</head>
<body>
<!--Chart Placement[3]-->
<div id ='chartDiv'></div>
</body>
</html>

I see the chartDiv but nothing displayed on chart :(

Can you help me ?


Solution

  • Your chart is not displaying because there is no chart type set in your chart JSON. I'll use "type":"line" for my example.

    var chartData = {
      "type": "line", 
      "csv":{
          "url":"./ressources/temperature1.csv",
          "smart-scales":true
        }
    };