0

我已经尝试在我的 ASP.Net Web 应用程序中使用Canvas JavaScript 饼图,并且我的 Web 表单方向是从右到左,但label图表legend无序。

4

3 回答 3

1

这是我的代码

        window.onload = function () {
            var chart = new CanvasJS.Chart("chartContainer",
            {
                title: {
                    text: "Top Categoires of New Year's Resolution"
                },
                exportFileName: "Pie Chart",
                exportEnabled: true,
                animationEnabled: true,
                legend: {
                    verticalAlign: "bottom",
                    horizontalAlign: "center",
                    fontFamily: "tahoma"
                },
                data: [
                {
                    type: "pie",
                    showInLegend: true,
                    toolTipContent: "{legendText}: <strong>{y}%</strong>",
                    indexLabel: "{label} {y}%",
                    dataPoints: [
                        { y: 35, legendText: "Mahan Company for Mines & Industries Developmentشركت گسترش صنايع و معادن ماهان(سهامي خاص) ", exploded: true, label: "Mahan Company for Mines & Industries Developmentشركت گسترش صنايع و معادن ماهان(سهامي خاص)" },
                        { y: 20, legendText: "OILMICOشركت بين المللي طراحي و مهندسي ساخت صنايع نفت (سهامي خاص)", label: "OILMICOشركت بين المللي طراحي و مهندسي ساخت صنايع نفت (سهامي خاص)" },
                        { y: 18, legendText: "شركت مهندسي ايساتيس پوياي ايرانيان(اركان رويان كوير)", label: "شركت مهندسي ايساتيس پوياي ايرانيان(اركان رويان كوير)" },
                        { y: 15, legendText: "شركت صنايع لمينت و بسته بندي نفيس كار افرين", label: "شركت صنايع لمينت و بسته بندي نفيس كار افرين" },
                        { y: 5, legendText: "سازمان صنايع دريايي-گروه شناورهاي زير سطحي", label: "سازمان صنايع دريايي-گروه شناورهاي زير سطحي" },
                        { y: 7, legendText: "ايسيكو(شركت مهندسي خدمات صنعتي ايران خودرو", label: "ايسيكو(شركت مهندسي خدمات صنعتي ايران خودرو" }
                    ]
                }
                ]
            });
            chart.render();
        }
<script src="http://canvasjs.com/assets/script/canvasjs.min.js"></script>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body dir="rtl">
    <div id="chartContainer" style="height: 300px; width: 100%;"></div>
</body>
</html>

于 2015-06-13T07:23:57.977 回答
0

在您的文件中设置此类

<style>
.canvasjs-chart-container{float:right;}
<style>
于 2017-12-23T06:14:17.427 回答
0

改变

<div id="chartContainer" style="height: 300px; width: 100%;"></div>

<div id="chartContainer" style="height: 300px; width: 100%;direction: ltr;"></div>

它的工作非常好

于 2017-12-23T06:49:14.537 回答