관리-도구
편집 파일: chart.js
function create_new_Charts( saleslastthirtysalesarr, saleslastthirtydatearr, title ) { var array = saleslastthirtysalesarr.split(","); var last_dates = saleslastthirtydatearr.split(","); let flag = []; for (let index = 0; index < array.length; index++) { let flag2 = []; flag2.push(last_dates[index].replace(/[\[\]']+/g, "")); flag2.push(parseFloat(array[index])); flag.push(flag2); } anychart.onDocumentReady(function () { // create data set on our data var dataSet = anychart.data.set(getData()); // map data for the first series, take x from the zero column and value from the first column of data set var firstSeriesData = dataSet.mapAs({ x: 0, value: 1, }); // create line chart var chart = anychart.line(); // see https://docs.anychart.com/Axes_and_Grids/Scales#integer chart.yScale().ticks().allowFractional(false); // turn on chart animation chart.animation(true); // set chart padding chart.padding([10, 20, 5, 20]); // turn on the crosshair chart.crosshair().enabled(true).yLabel(false).yStroke(null); // set tooltip mode to point chart.tooltip().positionMode("point"); // set yAxis title chart.yAxis().title("Total Sales"); chart.xAxis().labels().padding(5); // create first series with mapped data var firstSeries = chart.line(firstSeriesData); firstSeries.name("Sales"); firstSeries.hovered().markers().enabled(true).type("circle").size(4); firstSeries .tooltip() .position("right") .anchor("left-center") .offsetX(5) .offsetY(5); // turn the legend on chart.legend().enabled(true).fontSize(13).padding([0, 0, 10, 0]); // set container id for the chart chart.container(title); // initiate chart drawing chart.draw(); }); function getData() { return flag; } } function create_new_membership( lastthirtydaysmembersdatearr, lastthirtydaysmemberscountarr, title ) { var array = lastthirtydaysmemberscountarr.split(","); var last_dates = lastthirtydaysmembersdatearr.split(","); let flag = []; for (let index = 0; index < array.length; index++) { let flag2 = []; flag2.push(last_dates[index].replace(/[\[\]']+/g, "")); flag2.push(parseFloat(array[index])); flag.push(flag2); } anychart.onDocumentReady(function () { // create data set on our data var dataSet = anychart.data.set(getData()); // map data for the first series, take x from the zero column and value from the first column of data set var firstSeriesData = dataSet.mapAs({ x: 0, value: 1, }); // create line chart var chart = anychart.line(); // see https://docs.anychart.com/Axes_and_Grids/Scales#integer chart.yScale().ticks().allowFractional(false); // turn on chart animation chart.animation(true); // set chart padding chart.padding([10, 20, 5, 20]); // turn on the crosshair chart.crosshair().enabled(true).yLabel(false).yStroke(null); // set tooltip mode to point chart.tooltip().positionMode("point"); // set yAxis title chart.yAxis().title("Membership report"); chart.xAxis().labels().padding(5); // create first series with mapped data var firstSeries = chart.line(firstSeriesData); firstSeries.name("Members"); firstSeries.hovered().markers().enabled(true).type("circle").size(4); firstSeries .tooltip() .position("right") .anchor("left-center") .offsetX(5) .offsetY(5); // turn the legend on chart.legend().enabled(true).fontSize(13).padding([0, 0, 10, 0]); // set container id for the chart chart.container(title); // initiate chart drawing chart.draw(); }); function getData() { return flag; } }