google 图表:时间线比例尺
google charts: timeline Scale
我使用 angular 6. 在 google 图表时间线中,如何设置时间线的比例以仅显示周或月,而不显示日期。
我是这样设置图表的:
Basegraph 服务
declare var google: any;
export class GoogleChartsBaseService {
constructor() {
google.charts.load('current', {'packages':["timeline"], 'language': 'fr'});
}
protected buildChart(data: any[], chartFunc: any, options: any) : void {
var func = (chartFunc, options) => {
var datatable = google.visualization.arrayToDataTable(data);
chartFunc().draw(datatable, options);
};
var callback = () => func(chartFunc, options);
google.charts.setOnLoadCallback(callback);
}
}
时间线服务
import { GoogleChartsBaseService } from './google-charts-base.service';
import { Injectable } from '@angular/core';
import { GanttChartConfig } from './../models/GanttChartConfig.model';
declare var google: any;
@Injectable()
export class GoogleGanttChartService extends GoogleChartsBaseService {
constructor() { super(); }
public BuildPieChart(elementId: string, data: any[], config: GanttChartConfig) : void {
var chartFunc = () => { return new google.visualization.Timeline(document.getElementById(elementId)); };
var rowHeight = 41;
var chartHeight = data.length * rowHeight + 50;
var options = {
traitement: config.traitement,
datedebut: config.datedebut,
datefin: config.datefin,
chartArea:{},
height: chartHeight
};
this.buildChart(data, chartFunc, options);
}
}
只需设置 hAxis。
var options = {
traitement: config.traitement,
datedebut: config.datedebut,
datefin: config.datefin,
chartArea:{},
height: chartHeight,
hAxis: {
format: 'dd MMMM yyyy',
}
我使用 angular 6. 在 google 图表时间线中,如何设置时间线的比例以仅显示周或月,而不显示日期。
我是这样设置图表的:
Basegraph 服务
declare var google: any;
export class GoogleChartsBaseService {
constructor() {
google.charts.load('current', {'packages':["timeline"], 'language': 'fr'});
}
protected buildChart(data: any[], chartFunc: any, options: any) : void {
var func = (chartFunc, options) => {
var datatable = google.visualization.arrayToDataTable(data);
chartFunc().draw(datatable, options);
};
var callback = () => func(chartFunc, options);
google.charts.setOnLoadCallback(callback);
}
}
时间线服务
import { GoogleChartsBaseService } from './google-charts-base.service';
import { Injectable } from '@angular/core';
import { GanttChartConfig } from './../models/GanttChartConfig.model';
declare var google: any;
@Injectable()
export class GoogleGanttChartService extends GoogleChartsBaseService {
constructor() { super(); }
public BuildPieChart(elementId: string, data: any[], config: GanttChartConfig) : void {
var chartFunc = () => { return new google.visualization.Timeline(document.getElementById(elementId)); };
var rowHeight = 41;
var chartHeight = data.length * rowHeight + 50;
var options = {
traitement: config.traitement,
datedebut: config.datedebut,
datefin: config.datefin,
chartArea:{},
height: chartHeight
};
this.buildChart(data, chartFunc, options);
}
}
只需设置 hAxis。
var options = {
traitement: config.traitement,
datedebut: config.datedebut,
datefin: config.datefin,
chartArea:{},
height: chartHeight,
hAxis: {
format: 'dd MMMM yyyy',
}