function chartdiv2() { var chart;
var chartData = [ { "month" : "2015-08", "网损率" : 7.28,
}, { "month" : "2015-09", "网损率" : 6.76,
}, { "month" : "2015-10", "网损率" : 6.54,
}, { "month" : "2015-11", "网损率" : 6.95,
}, { "month" : "2015-12", "网损率" : 6.63,
}, { "month" : "2016-01", "网损率" : 6.89,
}, { "month" : "2016-02", "网损率" : 6.87,
}, { "month" : "2016-03", "网损率" : 7.12,
}, { "month" : "2016-04", "网损率" : 7.12,
}, { "month" : "2016-05", "网损率" : 6.56,
}, { "month" : "2016-06", "网损率" : 7.55,
}, { "month" : "2016-07", "网损率" : 7.09,
} ]; //数据源
// SERIAL CHART
chart = new AmCharts.AmSerialChart();
chart.dataProvider = chartData; //获取数据
chart.categoryField = "month"; 横坐标
chart.color = "#000000"; //标题颜色
chart.fontSize = 12; //标题大小
chart.startDuration = 1;//动画
chart.angle = 50; //倾斜角度
chart.columnWidth = 0.6; //柱状图宽度
chart.depth3D = 8;//3D厚度
// AXES
// category
var categoryAxis = chart.categoryAxis;
categoryAxis.gridAlpha = 0; //网格线透明度
categoryAxis.gridPosition = "start";
categoryAxis.gridColor = "#000000"; //网格线颜色
categoryAxis.axisColor = "#000000"; //横坐标轴颜色
categoryAxis.axisAlpha = 0.5; //坐标轴透明度
categoryAxis.dashLength = 0.5; //当这个值为1时网格线为实线
categoryAxis.fontSize=9; //横坐标坐标轴字体大小
categoryAxis.labelRotation = 30; //横坐标倾斜角度
var legend = new AmCharts.AmLegend(); //图例
legend.useGraphSettings = true;
legend.position = "top";
legend.align = "right";
legend.markerSize = 12;
legend.fontSize = 12;
legend.equalWidths = false;
legend.valueWidth = 0;
chart.addLegend(legend); var valueAxis = new AmCharts.ValueAxis(); //纵坐标轴
valueAxis.gridAlpha = 0.5;
valueAxis.gridColor = "#000000";
valueAxis.axisColor = "#000000";
valueAxis.axisAlpha = 0.5;
valueAxis.dashLength = 5;
chart.addValueAxis(valueAxis); // GRAPHS
// first graph
var graph1 = new AmCharts.AmGraph();
graph1.title = "网损率(%)";
graph1.valueField = "网损率"; //数据源
graph1.type = "column"; //表示柱状图
graph1.lineAlpha = 1;
graph1.lineColor = "#438eb9";
graph1.columnWidth = 0.5; //柱子的宽度
graph1.fillAlphas = 0.7; //透明度
graph1.balloonText = " [[category]] 网损率(%): <b>[[value]]</b>"; //浮泡 chart.addGraph(graph1);
chart.write("chartdiv-serial");
}
export const createCircle3D = (dom: any, data: any[]) => {
// Themes begin
am4core.useTheme(am4themes_animated);
// Themes end
const chart = am4core.create(dom, am4charts.PieChart3D);
chart.hiddenState.properties.opacity = 0; // this creates initial fade-in
chart.data = data;
chart.innerRadius = am4core.percent(50);
chart.angle = 50; //倾斜角度
chart.legend = new am4charts.Legend();
chart.legend.fontSize = 12;
chart.legend.position = 'right';
var pieSeries = chart.series.push(new am4charts.PieSeries3D());
pieSeries.dataFields.value = 'litres';
pieSeries.dataFields.depthValue = 'litres';
pieSeries.dataFields.category = 'country';
pieSeries.slices.template.cornerRadius = 5;
pieSeries.colors.step = 3;
pieSeries.legendSettings.labelText = '[#fff]{name}[#fff]';
pieSeries.labels.template.disabled = true;
//设置颜色
pieSeries.colors.list = [am4core.color('#E8D82B'), am4core.color('#E9764C'), am4core.color('#329BEB'), am4core.color('#039F9E'), am4core.color('#D654F1')];
//设置图例大小
let markerTemplate = chart.legend.markers.template;
markerTemplate.width = 16;
markerTemplate.height = 8;
return chart;
};
文章版权声明:除非注明,否则均为
譬如朝露_策温技术开发工作室博客原创文章,转载或复制请以超链接形式并注明出处。
发表评论
侧栏公告
寄语
譬如朝露博客是一个分享前端知识的网站,联系方式11523518。
热评文章
标签列表
热门文章
友情链接