MPAndroidChart sets the spacing (offset) between the two sides of the icon to prevent the text from being blocked by too long Author: Chuwen Time: 2020-10-30 Classification: Android 1 comment #Code ``` LineChart linechart2=(LineChart)findViewById(R.id.linechart2); linechart2.setExtraLeftOffset(100f);// Left Spacing linechart2.setExtraRightOffset(80f);// space on right ``` ! [Untitled Picture. png] [1] [1]: https://cdn.nowtime.cc/2020/10/30/2262053361.png
Linux related exercises Author: Chuwen Time: 2020-10-30 Classification: Linux comment #The line beginning with # is a comment and does not need to be run #The line beginning with # is a comment and does not need to be run #The line beginning with # is a comment and does not need to be run 1. # # Create an ECS and provide a public IP that can be effectively connected-- 5 points (if not established, there will be no score in the exam) 2. # # Create a 'jjcpxp' user and set the password to '12345678' -- 5 points (if it is not established, you will fail the exam) ```bash #Do not create a directory under/home when specifying the - M parameter useradd jjcpxp -p 12345678 #Small extension, which can be used by deleted users Userdel - r username ``` 3. # # Create a 'test' user and set the user directory to '/home/jjcpxp' and the password to '123456'-- 5 points ```bash # -d /home/jjcpxp # -m useradd test -p 123456 #Modify directory chown -R test.test /home/jjcpxp ``` 4. # # Use the 'test' user to create a 'TXT.sh' file in the '/home/jjcpxp' directory. The file contents are batch created 'TXT1. txt', 'TXT2. txt', and 'TXT3. txt' files. The content of the 'del_TXT. sh' file is to delete the three txt files created above, and the 'jjcpxp' user can execute the operation-- 10 points ```bash #Log in to the test account su - test #Enter the/home/jjcpxp directory cd /home/jjcpxp #Create TXT.sh file touch TXT.sh #Set TXT.sh file content: create TXT1.txt TXT2.txt, TXT3.txt files echo touch TXT1.txt >> TXT.sh echo touch TXT2.txt >> TXT.sh echo touch TXT3.txt >> TXT.sh #################################################### #Re create del_TXT.sh file touch del_TXT.sh #The file content is to delete the above three txt files echo rm -rf TXT1.txt >> del_TXT.sh echo rm -rf TXT2.txt >> del_TXT.sh echo rm -rf TXT3.txt >> del_TXT.sh #Set execution permissions ##First switch to root su - root cd /home/jjcpxp #Then set file permissions (jjcpxp users can operate and execute) chown jjcpxp del_TXT.sh ``` 5. # # Use the 'jjcpxp' user to create a 'Dir.sh' file in the '/home/jjcpxp' directory. The file content is to create three folders of 'dir1', 'dir2', and 'dir3', and create a 'del_Dir. sh' file. The file content is to delete the above created file directory at the same time-- 10 points ```bash su - jjcpxp touch Dir.sh echo mkdir dir1 >> Dir.sh echo mkdir dir2 >> Dir.sh echo mkdir dir3 >> Dir.sh touch del_Dir.sh echo rm -rf dir1 >> del_Dir.sh echo rm -rf dir2 >> del_Dir.sh echo rm -rf dir3 >> del_Dir.sh ``` 6. # # The content created is "!!! Welcome to [own name] CentOS server!!!" login display-- 5 points ```bash su - root vi /etc/motd #Press the i key on the keyboard to enter editing #Then delete the text #Then press Esc, enter: wq #Then press Enter to save and close the file ``` 7. # # Create a 'xuehao' file whose owner is' root 'in'/home/jjcpxp '. The file content is' own name/student number'. At the same time, create the same file in the '/tmp' directory and 'jjcpxp' is readable by users -- 8 points ```bash su - root touch /home/jjcpxp/xuehao Echo Chen Wenzhou/10086>/home/jjcpxp/xuehao cp /home/jjcpxp/xuehao /tmp #Reference https://blog.51cto.com/qingmiao/2069603 setfacl -m u:jjcpxp:r /tmp/xuehao ``` 8. # # Count the contents of the first 10 lines of the '/tmp/linux_test. txt' file and output the contents to the 'grep' file in the '/home/jjcpxp' directory -- 8 points ```bash touch /tmp/linux_test.txt #Press the i key on the keyboard to enter editing #Write 15 lines in it yourself #Then press Esc, enter: wq #Then press Enter to save and close the file vi /tmp/linux_test.txt head -10 /tmp/linux_test.txt > /home/jjcpxp/grep ``` 9. # # Count the service results of ECS in the running '. service' and output the results to the 'service' file in the '/home/jjcpxp' directory -- 8 points ```bash ps auxw > /home/jjcpxp/service ``` 10. # # Output the tree structure results under the '/etc/sysconfig/' directory to the 'tree' file under the '/home/jjcpxp' directory -8 points ```bash #Install tree command yum install -y tree tree /etc/sysconfig/ > /home/jjcpxp/tree ``` 11. # # Count the file file lines of '/etc/sysconfig/network scripts/ifcfg-eth0' and output them to '/home/jjcpxp/' the current 'wc'. Then output the contents of the above file to the 'ifcfg-eth0' file -- 8 points ```bash wc -l /etc/sysconfig/network-scripts/ifcfg-eth0 > /home/jjcpxp/wc cat /home/jjcpxp/wc > /home/jjcpxp/ifcfg-eth0 ``` 12. # # Write the shutdown command and restart command into the 'shut' file in the '/home/jjcpxp' directory -- 5 points ```bash #Shutdown command echo shutdown -h now >> /home/jjcpxp/shut ## # Restart Command echo shutdown -r now >> /home/jjcpxp/shut ``` 13. # # Test the connectivity of www.163.com website and output the results to the 'ping' file in the '/home/jjcpxp' directory -- 10 points ```bash #- c parameter, specify the number of times #>/home/jjcpxp/ping Redirect the results to/home/jjcpxp/ping and overwrite the written file ping -c 10 www.163.com > /home/jjcpxp/ping ``` 14. # # Copy all files in the '/home/jjcpxp' directory to the 'test' directory in the '/tmp' directory, and set all files to the 'test' * * read-only * * attribute -- 10 points ```bash mkdir /tmp/test cp /home/jjcpxp/* /tmp/test setfacl -m u:jjcpxp:r /tmp/test/* ```
Example of MPAndrodChart drawing group histogram Author: Chuwen Time: 2020-10-29 Classification: Android comment #Example of MPAndrodChart drawing group histogram I have tried for a long time to write it myself. I only give examples of dead methods. There are comments in some places. If I don't know what to say, I can leave comments in the comment area #Layout file ``` <? xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" http://schemas.android.com/apk/res/android " android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.github.mikephil.charting.charts. BarChart android:id="@+id/barchart1" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout> ``` #Java code >I shared the method directly >You can call this method directly in the 'onCreate()' method of 'XXXXXActivity' ``` //I shared the method directly //You can call this method directly from the onCreate() method of Activity private void drawBarChart() { //There's no need to explain this BarChart barChart = findViewById(R.id.barchart1); barChart.getLegend().setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER); barChart.getLegend().setVerticalAlignment(Legend.LegendVerticalAlignment.TOP); final Description description = new Description(); description.setPosition(200, 60); Description. setText ("Road Congestion")// Introduction to Settings description.setTextSize(10f); barChart.setDescription(description); List<BarEntry> barEntryList = new ArrayList<>(); barEntryList.add(new BarEntry(1, 4)); barEntryList.add(new BarEntry(2, 5)); barEntryList.add(new BarEntry(3, 4)); barEntryList.add(new BarEntry(4, 3)); barEntryList.add(new BarEntry(5, 2)); barEntryList.add(new BarEntry(6, 1)); barEntryList.add(new BarEntry(7, 3)); List<BarEntry> barEntryList2 = new ArrayList<>(); barEntryList2.add(new BarEntry(1, 5)); barEntryList2.add(new BarEntry(2, 4)); barEntryList2.add(new BarEntry(3, 3)); barEntryList2.add(new BarEntry(4, 2)); barEntryList2.add(new BarEntry(5, 1)); barEntryList2.add(new BarEntry(6, 2)); barEntryList2.add(new BarEntry(7, 3)); List<BarEntry> barEntryList3 = new ArrayList<>(); barEntryList3.add(new BarEntry(1, 4)); barEntryList3.add(new BarEntry(2, 2)); barEntryList3.add(new BarEntry(3, 3)); barEntryList3.add(new BarEntry(4, 2)); barEntryList3.add(new BarEntry(5, 4)); barEntryList3.add(new BarEntry(6, 1)); barEntryList3.add(new BarEntry(7, 1)); List<BarEntry> barEntryList4 = new ArrayList<>(); barEntryList4.add(new BarEntry(1, 2)); barEntryList4.add(new BarEntry(2, 1)); barEntryList4.add(new BarEntry(3, 5)); barEntryList4.add(new BarEntry(4, 2)); barEntryList4.add(new BarEntry(5, 3)); barEntryList4.add(new BarEntry(6, 4)); barEntryList4.add(new BarEntry(7, 4)); List<BarEntry> barEntryList5 = new ArrayList<>(); barEntryList5.add(new BarEntry(1, 1)); barEntryList5.add(new BarEntry(2, 2)); barEntryList5.add(new BarEntry(3, 2)); barEntryList5.add(new BarEntry(4, 3)); barEntryList5.add(new BarEntry(5, 5)); barEntryList5.add(new BarEntry(6, 4)); barEntryList5.add(new BarEntry(7, 3)); List<BarEntry> barEntryList6 = new ArrayList<>(); barEntryList6.add(new BarEntry(1, 2)); barEntryList6.add(new BarEntry(2, 1)); barEntryList6.add(new BarEntry(3, 1)); barEntryList6.add(new BarEntry(4, 2)); barEntryList6.add(new BarEntry(5, 4)); barEntryList6.add(new BarEntry(6, 3)); barEntryList6.add(new BarEntry(7, 3)); List<BarEntry> barEntryList7 = new ArrayList<>(); barEntryList7.add(new BarEntry(1, 4)); barEntryList7.add(new BarEntry(2, 1)); barEntryList7.add(new BarEntry(3, 2)); barEntryList7.add(new BarEntry(4, 2)); barEntryList7.add(new BarEntry(5, 3)); barEntryList7.add(new BarEntry(6, 2)); barEntryList7.add(new BarEntry(7, 1)); BarDataSet barDataSet=new BarDataSet (barEntryList, "Xueyuan Road"); BarDataSet barDataSet2=new BarDataSet (barEntryList2, "Lenovo Road"); BarDataSet barDataSet3=new BarDataSet (barEntryList3, "Hospital Road"); BarDataSet barDataSet4=new BarDataSet (barEntryList4, "Happy Road"); BarDataSet barDataSet5=new BarDataSet (barEntryList5, "Ring Expressway"); BarDataSet barDataSet6=new BarDataSet (barEntryList6, "Ring Expressway"); BarDataSet barDataSet7=new BarDataSet (barEntryList7, "parking lot"); barDataSet.setColor(Color.parseColor("#bf382d")); barDataSet2.setColor(Color.parseColor("#2f4455")); barDataSet3.setColor(Color.parseColor("#60a0a7")); barDataSet4.setColor(Color.parseColor("#d48164")); barDataSet5.setColor(Color.parseColor("#91c6af")); barDataSet6.setColor(Color.parseColor("#769e83")); barDataSet7.setColor(Color.parseColor("#c98624")); BarData barData = new BarData(barDataSet, barDataSet2, barDataSet3, barDataSet4, barDataSet5, barDataSet6, barDataSet7); barData.setDrawValues(false); barChart.getXAxis().setValueFormatter(new IAxisValueFormatter() { @Override public String getFormattedValue(float value, AxisBase axis) { switch ((int) value) { case 0: Return "Monday"; case 10: Return "Tuesday"; case 20: Return "Wednesday"; case 30: Return "Thursday"; case 40: Return "Friday"; case 50: Return "Saturday"; case 60: default: Return "Sunday"; } } }); barChart.getAxisLeft().setYOffset(25f);// This will offset 50% downward barChart.getAxisLeft().setAxisMinimum(0f); barChart.getAxisLeft().setAxisMaximum(5f); barChart.getAxisLeft().setLabelCount(6, True);//Set the spacing barChart.getAxisLeft().setValueFormatter(new IAxisValueFormatter() { @Override public String getFormattedValue(float value, AxisBase axis) { switch ((int) value) { case 1: Return "Smooth"; case 2: Return "Slow down"; case 3: Return "Normal congestion"; case 4: Return "Moderate congestion"; case 5: Return "Severe congestion"; default: return ""; } } }); barChart.getAxisRight().setAxisMinimum(0f); barChart.getAxisRight().setAxisMaximum(5f); barChart.getAxisRight().setLabelCount(6, True);//Set the spacing barChart.getXAxis().setTextSize(12f); barChart.getXAxis().setYOffset(-0); barChart.getXAxis().setAxisMinimum(1); barChart.getXAxis().setAxisMaximum(70); barChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM); barChart.getXAxis().setCenterAxisLabels(true); barChart.getXAxis().setDrawAxisLine(false);// Horizontal line barChart.getXAxis().setDrawGridLines(false);// vertical barChart.setData(barData);// Set data first float groupSpace = 2f;//0.3 * DaraSet float barSpace = 0.28f; //0.04 * DataSet //0.1 * DataSet //Then set the grouping histogram barChart.groupBars(.7f, groupSpace, barSpace); barChart.invalidate(); } ``` #Running screenshot ! [Snipaste_2020-10-29_20-30-36.jpg][1] [1]: https://cdn.nowtime.cc/2020/10/29/1302616410.jpg
MPAndroidChart histogram, the left (right) Y-axis label (value) is offset downward by 50% Author: Chuwen Time: 2020-10-29 Classification: Android comment #Code >The same goes for the right side of the Y axis. You just need to change 'barChart. getAxisLeft()' to 'barChart. getAxisRight()' ``` BarChart barChart = findViewById(R.id.barchart1); //... Some codes are omitted here barChart.getAxisLeft().setYOffset(25f);// This will offset 50% downward. I don't know why I tried it myself barChart.getAxisLeft().setAxisMinimum(0f);// Minimum scale value barChart.getAxisLeft().setAxisMaximum(5f);// Maximum scale value barChart.getAxisLeft().setLabelCount(6, True);//Set the number of tags ``` #Operation results ! [MPAndroidChart histogram, left Y-axis label (value) offset downward by 50%] [1] [1]: https://cdn.nowtime.cc/2020/10/29/2068874471.jpg
MPAndroid draws a histogram, displaying values on the top and setting text color and size Author: Chuwen Time: 2020-10-29 Classification: Android comment ###It took a long time to find that the AxisLeft minimum value needs to be set ``` HorizontalBarChart hBarChart = findViewById(R.id.two); YAxis lYAxis = hBarChart.getAxisLeft(); lYAxis.setAxisMinimum(0);// This must be set to display lYAxis.setAxisMaximum(100);// This can be set or not ``` #Results ! [Snipaste_2020-10-29_15-12-05.jpg][1] #Set text color and size ``` BarDataSet barDataSet = new BarDataSet(values, ""); barDataSet.setValueTextColor(Color. RED); barDataSet.setValueTextSize(20f); ``` #Effect ! [Snipaste_2020-10-29_15-16-45.jpg][2] [1]: https://cdn.nowtime.cc/2020/10/29/1644885309.jpg [2]: https://cdn.nowtime.cc/2020/10/29/217619350.jpg