将 angular 2 数据绑定到 predix ui 组件
binding angular 2 data to predix ui component
我正在尝试在 angular 2 中开发一个页面,它使用 predix UI 组件来绘制图表。目前我正在尝试使用静态 json 数据显示在图表中。但是我无法绑定数据,因此图表没有显示在页面中。在控制台中,它们也不是错误。当我将 chartData json 值直接赋给 px-vis-timeseries 标签时,它会显示图表。所以这是将数据绑定到 predix 组件的问题。我是 angular 2 和 predix UI 的新手。所以我不确定如何绑定 this.Can 有人请帮助我吗?
@jenny 你知道吗?我看到你也有类似的 Post 如果你有答案请帮助我
提前致谢...
app.component.ts 文件
@Component({
selector: 'my-app',
template: `
<div>
<h2 id="title_tag" >Timeseries - Chart</h2>
<px-vis-timeseries
prevent-resize
width = "1200"
height = "800"
include-all-series
render-to-canvas
selection-type= "xy"
chart-data='{{chartData}}'
series-config='{{seriesConfig}}'
x-axis-config='{"title":"Date"}'
y-axis-config='{"title":"Single","titleTruncation":false,"unit":"F","axis1":{"title":"Temperature","titleTruncation":false,"unit":"C"}}'
disable-navigator>
</px-vis-timeseries>
</div>
`
})
export class AppComponent{
var chartData = '[{"x":1397102460000,"y0":11.4403,"y1":96.5,"y2":0.56,"y3":0.56},{"x":1397139660000,"y0":13.1913,"y1":96.5,"y2":0.4,"y3":0.4},{"x":1397177400000,"y0":12.8485,"y1":96.5,"y2":0.43,"y3":0.43},{"x":1397228040000,"y0":10.975,"y1":96.5,"y2":0.33,"y3":0.33},{"x":1397248260000,"y0":12.9377,"y1":96.5,"y2":0.47,"y3":0.47},{"x":1397291280000,"y0":13.3795,"y1":96.5,"y2":0.41,"y3":0.41},{"x":1397522940000,"y0":16.4446,"y1":96.5,"y2":0.32,"y3":0.32},{"x":1397542800000,"y0":12.2771,"y1":96.5,"y2":0.35,"y3":0.35},{"x":1397640960000,"y0":13.0709,"y1":96.5,"y2":0.34,"y3":0.34},{"x":1397663100000,"y1":88.8,"y2":0.28,"y3":0.28},{"x":1397700000000,"y0":12.6198,"y1":95.2,"y2":0.49,"y3":0.49},{"x":1397753040000,"y0":11.0486,"y1":96.5,"y2":0.35,"y3":0.35},{"x":1397772540000,"y0":14.6892,"y1":96.5,"y2":0.21,"y3":0.21},{"x":1397794860000,"y0":14.3738,"y1":96.5,"y2":0.42,"y3":0.42},{"x":1397813580000,"y0":10.4259,"y1":76.5,"y2":0.58,"y3":0.58},{"x":1397890680000,"y0":13.4261,"y1":96.5,"y2":0.37,"y3":0.37},{"x":1397932020000,"y0":13.0062,"y1":96.5,"y2":0.27,"y3":0.27},{"x":1397973480000,"y0":14.475,"y1":96.5,"y2":0.35,"y3":0.35}]';
}
这是因为ng-reflect属性加上angular2绑定,这样绑定不会成功,为了去掉ng-reflect绑定数据如下,
[attr.chart-数据]='chartData'
我正在尝试在 angular 2 中开发一个页面,它使用 predix UI 组件来绘制图表。目前我正在尝试使用静态 json 数据显示在图表中。但是我无法绑定数据,因此图表没有显示在页面中。在控制台中,它们也不是错误。当我将 chartData json 值直接赋给 px-vis-timeseries 标签时,它会显示图表。所以这是将数据绑定到 predix 组件的问题。我是 angular 2 和 predix UI 的新手。所以我不确定如何绑定 this.Can 有人请帮助我吗? @jenny 你知道吗?我看到你也有类似的 Post 如果你有答案请帮助我 提前致谢...
app.component.ts 文件
@Component({
selector: 'my-app',
template: `
<div>
<h2 id="title_tag" >Timeseries - Chart</h2>
<px-vis-timeseries
prevent-resize
width = "1200"
height = "800"
include-all-series
render-to-canvas
selection-type= "xy"
chart-data='{{chartData}}'
series-config='{{seriesConfig}}'
x-axis-config='{"title":"Date"}'
y-axis-config='{"title":"Single","titleTruncation":false,"unit":"F","axis1":{"title":"Temperature","titleTruncation":false,"unit":"C"}}'
disable-navigator>
</px-vis-timeseries>
</div>
`
})
export class AppComponent{
var chartData = '[{"x":1397102460000,"y0":11.4403,"y1":96.5,"y2":0.56,"y3":0.56},{"x":1397139660000,"y0":13.1913,"y1":96.5,"y2":0.4,"y3":0.4},{"x":1397177400000,"y0":12.8485,"y1":96.5,"y2":0.43,"y3":0.43},{"x":1397228040000,"y0":10.975,"y1":96.5,"y2":0.33,"y3":0.33},{"x":1397248260000,"y0":12.9377,"y1":96.5,"y2":0.47,"y3":0.47},{"x":1397291280000,"y0":13.3795,"y1":96.5,"y2":0.41,"y3":0.41},{"x":1397522940000,"y0":16.4446,"y1":96.5,"y2":0.32,"y3":0.32},{"x":1397542800000,"y0":12.2771,"y1":96.5,"y2":0.35,"y3":0.35},{"x":1397640960000,"y0":13.0709,"y1":96.5,"y2":0.34,"y3":0.34},{"x":1397663100000,"y1":88.8,"y2":0.28,"y3":0.28},{"x":1397700000000,"y0":12.6198,"y1":95.2,"y2":0.49,"y3":0.49},{"x":1397753040000,"y0":11.0486,"y1":96.5,"y2":0.35,"y3":0.35},{"x":1397772540000,"y0":14.6892,"y1":96.5,"y2":0.21,"y3":0.21},{"x":1397794860000,"y0":14.3738,"y1":96.5,"y2":0.42,"y3":0.42},{"x":1397813580000,"y0":10.4259,"y1":76.5,"y2":0.58,"y3":0.58},{"x":1397890680000,"y0":13.4261,"y1":96.5,"y2":0.37,"y3":0.37},{"x":1397932020000,"y0":13.0062,"y1":96.5,"y2":0.27,"y3":0.27},{"x":1397973480000,"y0":14.475,"y1":96.5,"y2":0.35,"y3":0.35}]';
}
这是因为ng-reflect属性加上angular2绑定,这样绑定不会成功,为了去掉ng-reflect绑定数据如下,
[attr.chart-数据]='chartData'