0

Has anybody worked successfully with chartnew.js (https://github.com/FVANCOP/ChartNew.js/) and an external CSS file?

Essentially, I can't get it to run. A simple chart can successfully produced like so:

<SCRIPT src='ChartNew.js'></script>

<SCRIPT>

defCanvasWidth=1200;
defCanvasHeight=600;

var mydata1 = {
    labels : ["Jan","Feb","Mar","Apr","May","June","Jul","Aug","Sep","Oct","Nov","Dec"],
    datasets : [
        {
            fillColor : "blue",
            strokeColor : "rgba(220,220,220,1)",
            pointColor : "rgba(220,220,220,1)",
            pointStrokeColor : "#fff",
            data : [100,200,400,2000,4000,16000,20000,32000,45000,85000,95000,115000],
                title : "previous Month"
        },
        {
            fillColor : "red",
            strokeColor : "rgba(220,220,220,1)",
            pointColor : "rgba(220,220,220,1)",
            pointStrokeColor : "#fff",
            data : [100,200,1600,2000,12000,4000,12000,13000,40000,10000,20000,17000],
                title : "current month"
        },
        {
            type : "Line",
//          fillColor : "rgba(0,0,0,0)",
            strokeColor : "green",
            pointColor : "green",
            pointStrokeColor : "green",
            data : [200,400,2000,4000,16000,20000,32000,45000,85000,95000,115000,132000],
            title : "total"
        }
    ]
}

var newopts = {
    animation : false,
    datasetFill : false,
    canvasBorders : true,
    canvasBordersWidth : 3,
    canvasBordersColor : "black",
    graphTitle : "Graph Title",
    graphTitleFontFamily : "'Arial'",
    graphTitleFontSize : 24,
    graphTitleFontStyle : "bold",
    graphTitleFontColor : "#666",
    legend : true,
    legendBlockSize : 30,
    bezierCurveTension : 0.2 ,
    legendPosX : 2,
    legendPosY : 0,
    graphMax : 160000,
    yAxisMinimumInterval : 40000,
    scaleXGridLinesStep : 9999
}

</SCRIPT>



<body>
    <script>
        document.write("<canvas id=\"canvas_stackedbar\" height=\""+defCanvasHeight+"\" width=\""+defCanvasWidth+"\"></canvas>");
        window.onload = function() {
            if(1==1) {
            var myLine = new Chart(document.getElementById("canvas_stackedbar").getContext("2d")).StackedBar(mydata1,newopts);
            }
        }
    </script>
</body>

But as soon as I add a

<link rel="stylesheet" type="text/css" href="styles.css">

to this, no chart is rendered and it breaks with

Uncaught TypeError: Cannot read property 'length' of null at getCSSText (ChartNew.js:572) at getCSSWH (ChartNew.js:590) at resizeCtxFunction (ChartNew.js:605) at init_and_start (ChartNew.js:2467) at new StackedBar (ChartNew.js:3849) at window.Chart.StackedBar (ChartNew.js:1674) at window.onload (index.html:71)

in the middle of the Chartnew.JS script.

Almost appears like some sort of fundamental issue with the script itself.

Happysmithers
  • 733
  • 2
  • 8
  • 13

0 Answers0