我试图让mat-table排序在本地工作,虽然我可以按预期显示数据,但点击标题行不会像在线示例那样进行排序(根本不会发生任何事情).我试图让这个演示在本地工作:https
:
//material.angular.io/components/sort/overview https://plnkr.co/edit/XF5VxOSEBxMTd9Yb3ZLA?p=preview
我使用Angular CLI生成了一个新项目,然后按照以下步骤操作:https: //material.angular.io/guide/getting-started
这是我的本地文件:
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { MatSort, MatTableModule } from '@angular/material';
import { AppComponent } from './app.component';
import { TableSortingExample } from './table-sorting-example';
@NgModule({
declarations: [
AppComponent,
TableSortingExample,
MatSort
],
imports: [
BrowserModule,
MatTableModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: …Run Code Online (Sandbox Code Playgroud) 我正在 chart.js 中制作折线图,并且遇到了一个问题,我试图在线上绘制点数据,但它忽略了我提供的 x 值,而是将它们放在第一个可用标签上。
this.myLineChart = new Chart(this.ctx, {
type: 'line',
data: {
labels: [0,2,4,6,8,10],
datasets: [{
label: 'mylabel1',
fill: false,
backgroundColor: 'blue',
borderColor: 'blue',
data: [{
x: 2.5,
y: 85
}, {
x: 3.5,
y: 85
}]
}]
},
options: {
title: {
display: true,
text: 'mytitle1'
},
scales: {
yAxes: [{
display: true,
ticks: {
suggestedMin: 70,
suggestedMax: 100
}
}]
}
}
});
Run Code Online (Sandbox Code Playgroud)
但相反,我希望这条线位于 x 值 2.5 和 3.5 处,以便它位于 2 和 4 标签之间。
我应该在代码中更改什么以使其按照我的意愿运行?