Home

Legend Chart Code

You only need this lines in order to see a legend in the chart.

<head>
    <title>My A-Frame Scene</title>
    <script src="https://aframe.io/releases/1.4.0/aframe.min.js"></script>
    <script src="https://unpkg.com/aframe-charts-component/dist/aframe-charts-component.min.js"></script>
</head>
<body>
    <!-- Aframe scene -->
    <a-scene background="color: grey">
        <!-- Aframe light -->
        <a-light type="point" intensity="1" position="-2 10 10"></a-light>

        <!-- Declaring chart component -->
        <a-entity charts="type: pie; dataPoints: ../data/dataLegend.json; pie_radius: 3; show_legend_info: true; show_legend_position: -2 5 7;
            show_legend_rotation: 0 35 0" position="5 0 0"></a-entity>

        <!-- Aframe camera -->
        <a-entity position="2 10 14" rotation="-30 15 0">
            <a-camera position="3 -1 4" rotation="0 -1 0">
                <a-cursor></a-cursor>
            </a-camera>
        </a-entity>
    </a-scene>
</body>
Check the visual example See our API for more options

JSON input example

            
[
  {"size": 1, "color": "#ff0000", "label": "USA"},
  {"size": 1, "color": "#00ff00", "label": "Spain"},
  {"size": 2, "color": "#0000ff", "label": "Mexico"},
  {"size": 1.5, "color": "#000000", "label": "Japan"},
  {"size": 4, "color": "#4CC3D9", "label": "India"}
]