jqplot设置表中的数据系列

时间:2022-02-13 20:05:25

I am using jqplot to create a pie chart from an HTML table.

我正在使用jqplot从HTML表创建饼图。

However, when attempting to set a var the chart doesn't plot.

但是,在尝试设置var时,图表不会绘制。

If i simply set a number for the var, such as:

如果我只是为var设置一个数字,例如:

var DataTest = 22;

then the chart works fine.

然后图表工作正常。

However, when I get the value from the table it doesn't, as below:

但是,当我从表中获取值时,它没有,如下所示:

var DataTest = $(dataID + ' td:nth-child(46)').text();

The pie chart wont display.

饼图不会显示。

The pie chart series is being set through a var also:

饼图系列也通过var设置:

var PieChartS1 = [ ['Label', DataTest] ];

Then included in the chart code as follows:

然后在图表代码中包含如下:

 var PieChartPlot = $.jqplot('PieChart', [PieChartS1, PieChartS2 ], {
 seriesDefaults: {
    renderer:$.jqplot.DonutRenderer,
    rendererOptions:{
    sliceMargin: 1,
    startAngle: -145,
    showDataLabels: true,
    dataLabels: 'label',
    padding: '5',
    ringMargin: '5',
    dataLabelThreshold: '1',
    highlightMouseOver: true,
  }   
},
grid: {background: 'transparent', borderWidth: '0', cursor: 'pointer',},

});

I'm wondering whether it is a format issue?

我想知道它是否是格式问题?

Thanks for any help

谢谢你的帮助

Richard

Update:

Am wondering whether the graph is being formed by the script before the data has been obtained, so it is just showing blank as it is finding no data. Perhaps I need to delay the graph formation until the 'get data' scripts are fully executed?

我想知道在获取数据之前图表是否由脚本形成,所以它只显示空白,因为它没有找到数据。也许我需要延迟图形的形成,直到“获取数据”脚本完全执行?

1 个解决方案

#1


Had some help from elsewhere.

得到了其他地方的帮助。

It needs to be specified as an integer, so the change needs to be:

它需要指定为整数,因此更改需要:

var DataTest = parseInt($(dataID + ' td:nth-child(46)').text());

This works fine.

这很好用。

#1


Had some help from elsewhere.

得到了其他地方的帮助。

It needs to be specified as an integer, so the change needs to be:

它需要指定为整数,因此更改需要:

var DataTest = parseInt($(dataID + ' td:nth-child(46)').text());

This works fine.

这很好用。