FVANCOP / ChartNew.js

MIT License
420 stars 143 forks source link

Incorrect position of SpecialInChartData #482

Closed luna2761 closed 7 years ago

luna2761 commented 7 years ago

Hello, Francois!

I'm trying to use SpecialInChartData.js and create special InChartData with image for Bar chart. However the position of those date and image is incorrect.

<script>
        var charJSPersonnalDefaultOptions = { decimalSeparator: ",", thousandSeparator: ".", roundNumber: "none", graphTitleFontSize: 2 };
        defCanvasWidth = 800;
        defCanvasHeight = 400;
        var mydata = {
            labels: ["First","Second","Third","Fourth"],
            datasets: [
                {
                    fillColor: "rgba(220,220,220,0.5)",
                    strokeColor: "rgba(220,220,220,1)",
                    pointColor: "rgba(220,220,220,1)",
                    pointStrokeColor: "#fff",
                    data: [3, 2, 3, 0.5],
                    title: "Team #1",
                    axis: 1
                }
             ]   
        };
        var image = new Image();
        image.src = "../content/info-5-16.png";

        var newopts = {
            animation: false,
            datasetFill: false,
            canvasBorders: true,
            canvasBordersWidth: 3,
            canvasBordersColor: "black",
            graphTitle: "Graph Title",
            graphTitleFontFamily: "'Arial'",
            graphTitleFontSize: 24,
            graphTitleFontStyle: "bold",
            graphTitleFontColor: "#666",
            legend: false,
            legendBlockSize: 30,
            bezierCurveTension: 0.2,
            legendPosX: 2,
            legendPosY: 0,
            yAxisMinimumInterval: 1,
            scaleXGridLinesStep: 9999,
            inGraphDataShow: false,
            endDrawDataFunction: drawShapes
        };
        pushInGraphData("Bar", mydata, newopts, { text: "<j>", imageLoad: image, imagePos : 0, avoidOverwrite: true });
    </script>

and

<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")).Bar(mydata,newopts);
                }
            }
    </script>

Result: incorrect

Please, advice, how to fix it. Thank you.

FVANCOP commented 7 years ago

Sorry, I forgot to document that this add-ins works only for Pie and Doughnut charts. For other charts it is not implemented. The purpose of this add-ins is to avoid that "inChartData" overlaps each others. It can be the case in Pie and Doughnuts when you have small slices. It can not happens in (normal) Bar charts; So it has not been implemented there (nor for line charts).