Highstock 和 Highcharts:我如何在同一页面上使用 StockChart 和饼图

发布于 2024-12-27 02:37:13 字数 1055 浏览 1 评论 0原文

我对在同一页面上使用 highstock stockchart 和 highcharts 饼图感到困惑。在这两种方式中,我都使用 JSON 获取数据。浏览器在呈现 Highcharts.Chart 类型饼图时无法正确呈现 Highcharts.StockChart。

这是我使用的代码段:

<script type="text/javascript">
$("document").ready(function() {
$.getJSON('http://localhost:3000/reports/hits?callback=?', function(data) {
     var chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container'
        },
        ...
        },
        series: [{
            name: 'Name',
            data: data,
            tooltip: {
                yDecimals: 0
            }
        }]
     });
  })

    $.getJSON('http://localhost:3000/reports/daily_hit?callback=?', function(data) {
     var chart = new Highcharts.Chart({
        chart: {
           renderTo: 'container1',
           plotBackgroundColor: null,
           plotBorderWidth: null,
           plotShadow: false
        },
       ...
         series: [{
           type: 'pie',
           name: 'Hit',
           data: data
        }]
     });
  })
 }
);
</script>

I have a confusion about using the highstock stockchart and highcharts pie-chart on the same page. In both ways, I am getting the data using JSON. The browser cannot render the Highcharts.StockChart properly whereas it renders Highcharts.Chart type pie.

Here is the code segment that I use:

<script type="text/javascript">
$("document").ready(function() {
$.getJSON('http://localhost:3000/reports/hits?callback=?', function(data) {
     var chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container'
        },
        ...
        },
        series: [{
            name: 'Name',
            data: data,
            tooltip: {
                yDecimals: 0
            }
        }]
     });
  })

    $.getJSON('http://localhost:3000/reports/daily_hit?callback=?', function(data) {
     var chart = new Highcharts.Chart({
        chart: {
           renderTo: 'container1',
           plotBackgroundColor: null,
           plotBorderWidth: null,
           plotShadow: false
        },
       ...
         series: [{
           type: 'pie',
           name: 'Hit',
           data: data
        }]
     });
  })
 }
);
</script>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

对风讲故事 2025-01-03 02:37:13

当我尝试使用 Highstock 图表和 Angular Gauge 时,我遇到了同样的问题,
当我尝试像这样重新排列 highstock highchart javascript 库时,问题就解决了

<script type="text/javascript" src="jQuery/Highcharts/highcharts.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highstock.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highcharts-more.js"></script>

,或者(如果您不想使用额外的图形)

<script type="text/javascript" src="jQuery/Highcharts/highcharts.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highstock.js"></script>

我希望它有用

I have experienced the same problem when I tried to use Highstock chart and Angular Gauge,
And the problem was solved when I try to rearrange highstock highchart javascript library like this

<script type="text/javascript" src="jQuery/Highcharts/highcharts.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highstock.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highcharts-more.js"></script>

or (if you don't want to use additional graphics)

<script type="text/javascript" src="jQuery/Highcharts/highcharts.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highstock.js"></script>

I hope it can be useful

孤独陪着我 2025-01-03 02:37:13

解决方案很简单,首先放置 highstock,然后放置 highchart,如下所示:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highstock.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highcharts.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highcharts-more.js"></script>

不要忘记放置 jQuery!

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

这解决了我的问题,希望能帮到你

The solution is easy, put first highstock and then highchart like this:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highstock.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highcharts.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highcharts-more.js"></script>

Dont's forget put the jQuery!!

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

This solve my problem, I hope can help you

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文