真的希望你能帮忙! 我正在使用AMCharts,我通过一个简单的PHP函数添加了一些数据(从数据库中提取) 我使用以下功能
添加了一些上限和下限 // HORIZONTAL GREEN RANGE
var guide = new AmCharts.Guide();
guide.value =11.00;
guide.toValue = 11.80;
guide.fillColor = "#00CC00";
guide.inside = true;
guide.fillAlpha = 0.2;
guide.lineAlpha = 0;
valueAxis.addGuide(guide);
var guideRED = new AmCharts.Guide();
guideRED.value = 11.80;
guideRED.toValue = 11.90;
guideRED.fillColor = "orange";
guideRED.inside = true;
guideRED.fillAlpha = 0.2;
guideRED.lineAlpha = 0;
valueAxis.addGuide(guideRED);
var guideblue = new AmCharts.Guide();
guideblue.value = 11.00;
guideblue.toValue = 10.90;
guideblue.fillColor = "orange";
guideblue.inside = true;
guideblue.fillAlpha = 0.2;
guideblue.lineAlpha = 0;
valueAxis.addGuide(guideblue);
但我需要将Y(从上到下???)的显示范围分别设置为11.90和10.50,以便操作员可以看到绘制的线及其与红色和橙色区域的关系。目前,图表只是将图表呈现为+1最大值,而最小值则为值。
这是图函数
AmCharts.ready(function () {
// SERIAL CHART
chart = new AmCharts.AmSerialChart();
chart.dataProvider = chartData;
chart.dataDateFormat = "DD-MM-YY";
chart.categoryField = "date";
// AXES
// category
var categoryAxis = chart.categoryAxis;
// categoryAxis.parseDates = true; // as our data is date-based, we set parseDates to true
// categoryAxis.minPeriod = "DD"; // our data is daily, so we set minPeriod to DD
categoryAxis.gridAlpha = 0.1;
categoryAxis.minorGridAlpha = 0.1;
categoryAxis.axisAlpha = 0;
categoryAxis.minorGridEnabled = true;
categoryAxis.inside = true;
// value
var valueAxis = new AmCharts.ValueAxis();
valueAxis.tickLength = 4;
valueAxis.axisAlpha = 0;
valueAxis.showFirstLabel = false;
valueAxis.showLastLabel = false;
valueAxis.autoGridCount = true;
valueAxis.gridCount = 500;
chart.addValueAxis(valueAxis);
// GRAPH
var graph = new AmCharts.AmGraph();
graph.dashLength = 2;
graph.lineColor = "#00CC00";
graph.valueField = "value";
graph.dashLength = 3;
graph.bullet = "round";
graph.balloonText = "[[category]]<br><b><span style=\'font-size:14px;\'>value:[[value]]</span></b>";
chart.addGraph(graph);
(这都在一个标签内,因此是逃避字符
非常感谢。
答案 0 :(得分:4)
要将值轴强制为特定比例,请先设置minimum
和maximum
属性。该图表仍将尝试使用整数。要禁用该集strictMinMax
。
即:
var valueAxis = new AmCharts.ValueAxis();
valueAxis.minimum = 10.5;
valueAxis.maximum = 11.90;
valueAxis.strictMinMax = true;