android – Code to plot chart with data

I am working on a program that the user can use to track the parameters of his body (such as weight, waist size). I have a code that builds a chart based on these data. I would like to hear criticism on my code. What I don’t like :

  1. MeasurementCHartHelperю – It seems to me that this is not a very good name.
  2. Also I do not like that I mixed business logic and code for draw chart. But I do not know how it would be better to separate, what is the best way to name the classes
  3. Measurement.kt. I want to know if it is correct to have my extension functions there


class MeasurementCHartHelper @Inject constructor(private val appPreferencesHelper: AppPreferencesHelper) {

    private val now = Date(

    fun getChartData(measurements: List<Measurement>): LineChartData? {
        val points = getChartPoints(measurements)
        if(points.isNotEmpty()) {
            val seriesData = listOf(LineChartData.SeriesData("", points, Green,gradientFill = true))
            return LineChartData(seriesData,autoYLabels = true,horizontalLines = true)
        return null

    private fun getChartPoints(measurements: List<Measurement>): List<LineChartData.SeriesData.Point> {
        return getMeasurementValuesForTimeInterval(measurements.sortByDate()).map { LineChartData.SeriesData.Point(it.key,it.value.toFloat()) }

    private fun getMeasurementValuesForTimeInterval(measurements: List<Measurement>): Map<Int, Double> {
        return measurements
            .groupBy { getMeasurementTimeIntervalNumber(it, appPreferencesHelper.getTimeInterval(it.measurementType)) }
            .filterKeys { it != -1 }
            .mapValues { { measurement -> measurement.value }.average() }

    private fun getMeasurementTimeIntervalNumber(measurement: Measurement, timeInterval: TimeInterval): Int {
        val timeDifference = now -
        val daysDifference = (timeDifference.epochMillis / (TimeUnit.DAYS.toSeconds(1) * 1000)).toInt()
        if (daysDifference <= timeInterval.days)
            return timeInterval.days - (daysDifference / timeInterval.daysInInterval)
        return -1



class Measurement(
    @PrimaryKey(autoGenerate = true) var id: Int = 0,
    var measurementType: MeasurementType,
    var value: Float,
    var date: Date

fun List<Measurement>.byMeasurementType(): Map<MeasurementType, List<Measurement>> {
    return this.sortByDate().groupBy(Measurement::measurementType)

fun List<Measurement>.sortByDate(): List<Measurement> {
    return this.sortedBy { measurement -> }


enum class MeasurementType(
    val measurement: String,
    @StringRes val measurementDescription: Int,
    @StringRes val measurementFullDescription: Int
) {

    companion object {
        fun getMeasurementType(measurementName: String): MeasurementType {
            try {
                return values().find { it.measurement == measurementName }!!
            } catch (ex: Exception) {
                throw EnumConstantNotPresentException(, measurementName)

        fun getAllMeasurements(): List<MeasurementType> {
            return values().toList()


enum class TimeInterval(val id: Int, val days: Int, val daysInInterval: Int) {
    LastWeek(0, 7, 1),
    LastMonth(1, 30, 3),
    LastTwoMonths(2, 60, 6),
    LastYear(3, 365, 30),
    AllTime(4, 1000000, 1);

    companion object {
        fun findTimeIntervalById(id: Int): TimeInterval {
            return values().firstOrNull { == id }
                ?: error("Cant find TimeInterval with id - $id")

google chart – Uncaught TypeError: Cannot read property ‘results’ of null – when reading SharePoint list with JS

I am using an ajax call to get elements of multiple sharepoint list choice(checkboxes) columns called “Orbit”, “SD”,…. to create google pie charts for each column:

data.d.results.forEach(function(row) {
    // each row
    row.Orbit.results.forEach(function(choiceOrbit) {
        // each choice of Orbit of single row
        if (countOrbit.hasOwnProperty(choiceOrbit)) {
            countOrbit(choiceOrbit) += 1;
        } else {
            countOrbit(choiceOrbit) = 1;

But if one row in the column is empty, I get an error:

Uncaught TypeError: Cannot read property 'results' of null
at Statistics.aspx:658
at Array.forEach (<anonymous>)
at Object.success (Statistics.aspx:632)
at i (jquery.min.js:2)
at Object.fireWith (as resolveWith) (jquery.min.js:2)
at A (jquery.min.js:4)
at XMLHttpRequest.<anonymous> (jquery.min.js:4)

How can i add an if(), so that an empty item will be neglected in the counting? Something like:



 if(data.d.results.length > 0)
    // Add your code




doesnt work

EDIT: my full code is:


<script src="" type="text/javaScript"></script>
<script src="" type="text/javaScript"></script>
<script type="text/javaScript">
    $(document).ready(function () {
    var tempArray = ();
    var chartObj = (('Orbit', 'Number'));

AjaxCall(_spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('list')/items", function (data) {

    var countOrbit = {};
    var countSD = {}; 
    var countMT = {}; 
    var countIT = {}; 
    var countAI = {}; 

    data.d.results.forEach(function(row) {
        // each row
        row.Orbit.results.forEach(function(choiceOrbit) {
            // each choice of Orbit of single row
            if (countOrbit.hasOwnProperty(choiceOrbit)) {
                countOrbit(choiceOrbit) += 1;
            } else {
                countOrbit(choiceOrbit) = 1;
        row.SD.results.forEach(function(choiceSD) {
            // each choice of Orbit of single row
            if (countSD.hasOwnProperty(choiceSD)) {
                countSD(choiceSD) += 1;
            } else {
                countSD(choiceSD) = 1;
        row.MT.results.forEach(function(choiceMT) {
            // each choice of MT of single row
            if (countMT.hasOwnProperty(choiceMT)) {
                countMT(choiceMT) += 1;
            } else {
                countMT(choiceMT) = 1;
        row.IT.results.forEach(function(choiceIT) {
            // each choice of IT of single row
            if (countIT.hasOwnProperty(choiceIT)) {
                countIT(choiceIT) += 1;
            } else {
                countIT(choiceIT) = 1;
        row.AI.results.forEach(function(choiceAI) {
            // each choice of IT of single row
            if (countAI.hasOwnProperty(choiceAI)) {
                countAI(choiceAI) += 1;
            } else {
                countAI(choiceAI) = 1;

    // Load Charts and the corechart package.
    google.charts.load('current', {packages:('corechart')});
    google.charts.setOnLoadCallback(function(){drawAllCharts(countOrbit, 'Orbit')});
    google.charts.setOnLoadCallback(function(){drawAllCharts(countSD, 'SD')});
    google.charts.setOnLoadCallback(function(){drawAllCharts(countMT, 'MT')});
    google.charts.setOnLoadCallback(function(){drawAllCharts(countIT, 'IT')});
    google.charts.setOnLoadCallback(function(){drawAllCharts(countAI, 'AI')});

    // Function for all Charts

    function drawAllCharts(countChoices, name) {
        var rows = ();
        for (var property in countChoices) {
            if (countChoices.hasOwnProperty(property)) {
                rows.push((property, countChoices(property)));

        var datatable = new google.visualization.DataTable();
        datatable.addColumn('string', 'Type');
        datatable.addColumn('number', 'Quantity');
        var options = {
            title: String(name),
            is3D: 'true'
        var chart = new google.visualization.PieChart(document.getElementById(String(name)));
        chart.draw(datatable, options);
    // End of function to draw charts

                function AjaxCall(url, success) {
                        url: url,
                        type: "GET",
                        headers: {
                            "accept": "application/json;odata=verbose",
                        success: success,
                        error: function (error) {
                            alert('Something Went Wrong');
    <!--Table and divs that hold the pie charts-->
    <table class="columns">
        <td><div id="Orbit" style="width:700px;height:500px;"></div></td>
        <td><div id="SD" style="width:700px;height:500px;"></div></td>
        <td><div id="MT" style="width:700px;height:500px;"></div></td>
        <td><div id="IT" style="width:700px;height:500px;"></div></td>
        <td><div id="AI" style="width:700px;height:500px;"></div></td>

How to create an “overlapping interest chart” with Javascript or Python

I’m trying to create a chart that looks more-or-less like this:

Overlapping interests chart

Doing this manually in Inkscape is… ok, but I’d like to put this into a git repo to allow others to add their interests and even add new people. I’m thinking that this needs to be defined as data and rendered with software. As my team and I are proficient in Python & Javascript, these are my go-to tools.

There’s a lot of information and even handy libraries online for creating venn diagrams, but in all the cases I’ve found so far, you’re operating on the circles and adjusting the sizes & overlap directly. Critical to this task is the ability to add those interests: Dogs, Cats, Cars, etc. and have the sizes of the circles change automatically to fit what’s inside.

Surely this is a thing already right? Can someone please point me in the right direction? I’m even happy to go with some online tool that will do the job. My primary need is to be able to specify this stuff as data.

Why can’t one calibrate a monitor with a DSLR & a color chart?

There’s some good detail in the other answers but I wanted to point out the challenges belied by your approach:

  1. Take a RAW photo of a real color chart outside to get a white point of D65.

How are you measuring the D65 light, to know that it’s actually D65? If you’ve got a spectrophotometer to measure the light, surely that can be used to calibrate the display. I suspect it would be easier to shoot indoors with D65-balanced lights (well, assuming you’ve measured the lights to know their color output and any correction necessary for them).

  1. Use that to get an accurate color correction matrix for the camera sensor.

If you’ve got the software to generate a color profile (exactly what a “color correction matrix” is), then you’ve probably also got a colorimeter or spectophotometer. So I will instead assume that you are thinking of simply adjusting curves to a set of numbers to make the DSLR image match the color chart.

It’s worth pointing out that a ColorChecker Classic chart (such as I’d guess you’re shooting) has 24 colors, whereas software meant to do this will instead make hundreds of color measurements. Your result will be significantly less accurate.

  1. Use the same camera to take a picture of the chart as displayed on the screen.

The first problem you’ll encounter here: how do you know what color temperature you’re working with? Sure, the monitor says “6500” or “D65,” but how have you measured this to verify it’s what it claims?

How are you setting and adjusting the brightness, contrast, and red, green, and blue values of the monitor to maximize what the monitor is actually capable of creating?

When we talk about calibrating a display, there are actually two parts to be done: calibration and profiling. Calibration is the process of setting the monitor to its best values to maximize what the display is capable of, and the colorimeter or spectrophotometer is doing the hard work here of analyzing the color coming off the screen and determining how to eek out just that little bit more, turning a good display into a great one, or even a mediocre display into a good one.

By simply “using the same camera to take a picture of the chart as displayed on the screen” you are completely bypassing this part of the process, which obviously means you’re going to get an inferior result.

The second part, profiling, is effectively mapping what the monitor is producing to what the ideal result is. Here, again, a colorimeter or spectrophotometer is going to take hundreds of measurements to determine exactly what the monitor is capable of producing. A comprehensive look at what the monitor can produce creates a profile with a far more comprehensive result.

  1. Find the color correction matrix of the monitor, and load it into an ICC profile

How are you reading your color correction data to build an ICC profile? It’s been years since I seriously worked with color management software, but I suspect it’s still true that you’ll need to spend some big bucks to manipulate and use external data to build a new profile. And though my experience with profile manipulation is minimal, what I found and what other experts recommend is that if the profile isn’t providing the results you expect it’s because the profile was created incorrectly; going through the process again is far more likely to yield success than trying to fix a bad profile.

In other words, to build a good profile you need a good calibration. To get a good calibration you need a spectrophotometer or colorimeter.

Chart points are getting hidden by other points

Chart points are getting hidden by other points – User Experience Stack Exchange

plotting – labeling pie chart — between radial center and radial outer

is there a way to put the labels on this pie chart (e.g. {“c1”, “c2”, “c3”}) at a distance from the origin on the slices between “RadialCenter” and “RadialOuter”?
E.g. is there a way to tune the precise location of the location of ChartLabels by specifying some distance from the origin? I considered attempting to use Placed , but for pie charts in Mathematical it looks like there are only three options.

PieChart({{1, 2, 3}}, 
 ChartLabels -> {Placed({"c1", "c2", "c3"}, "RadialOuter")}, 
 SectorSpacing -> 0.5)


applescript – In Numbers can a chart follow a table’s increasing range?

I’m growing a table and also have a chart associated with it but when I add columns I have to go back to the chart and “edit data references”. When I was growing the chart from right to left, I didn’t have this issue. The chart would continue to grow because I was adding rows within the range. Wondering if this can be automated or handled differently.

This is the way I was doing it and graph didn’t need to be edited.

tell application "Numbers"
    tell the table 1 of sheet 1 of document "The Doc"
        delay 1
        add column before the range "E1:E2"
        set the value of cell "E1" to time string of (current date)
        repeat with i from 2 to the count of cells of column "E"
            set the value of cell i of column "E" to (the value of cell i of column "C")
        end repeat

    end tell
end tell

This is the way I’m doing it now but I have to always edit the data references.

tell application "Numbers"
    tell the table 1 of sheet 1 of document "The Doc"
        set column count to column count + 1
        set myLastColumn to column count
        set the value of cell 1 of column myLastColumn to time string of (current date)
        repeat with i from 2 to the count of cells of column "A"
            set the value of cell i of column myLastColumn of rows to (the value of cell i of column "D")
        end repeat
    end tell
end tell

php – ¿Cómo hago un chart dinamico en visual code?

<div class="container"><canvas id="myChart"></canvas><br>


<script src="" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="" integrity="sha512-/LczcxNfO+qylbrIEe4Ajnd+d5sc+HEhxENC0ym7pqjUflXBdP59kxr+r5QVEY0BPhHd/OtcqRwR6fEEYiWVeA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="" integrity="sha512-h0dSZkvjBWllHan49Ajy8Tk9UVa27kFrqUyQl652qZAwHBJw4lvszsqxWS+A3VcS4QJreD1n9QN2/TYIHHiQpw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="" ></script>
<script src=""></script>



include "../Conexion.php";

$sql = "SELECT
SUM(IF (edad BETWEEN 11 AND 14, 1, 0)) as Secundaria,
SUM(IF (edad BETWEEN 15 AND 17, 1, 0)) as Bachiller,
SUM(IF (edad BETWEEN 18 AND 24, 1, 0)) as Universidad,
SUM(IF (edad >= 24, 1, 0)) as Egresado
FROM alumnos;


$sql2 = "SELECT * from grado";

echo "const labels = (";
    echo "'".utf8_encode($row('categoroia'))."',";
echo ");";
echo "const edad = (";
    echo "'".$row('Aspirante')."','".$row('Secundaria')."','".$row('Bachiller')."','".$row('Universidad')."','".$row('Egresado')."',";
echo ");";



var color = ('#F1948A', '#C39BD3', '#76D7C4', '#F7DC6F', '#82E0AA', '#F5B041', '#5DADE2', '#FA8072', '#925DE2', '#E25DAD');
var bordercolor = ('#FFFFFF');

const data = {
  labels: labels,
  datasets: ({
    backgroundColor: color,
    borderColor: bordercolor,
    data: alumnos,
const config = {
  type: 'line',
  data: data,
  options: {}
  var myChart = new Chart(

How to make an overlaid column chart in LibreOffice Calc?

I want to make a bar/column chart that looks like so:
enter image description here
(credit to Matlab documentation for the image)

In my case I’m representing a snap-shot in a solution state: I have some variables and each have an associated upper-bound constraint. The variables can actually be above their upper-bound in this case (it’d imply we haven’t found a constraint-abiding solution yet).

The above style has each skinny bar overlaid on-top of its corresponding wider one, which seems like the perfect solution to communicate my data. Is there a way to do this with LibreOffice Calc?

The only options I see are styles: normal, stacked, percent stacked and (3-D) deep. Each of these options aren’t as good as the simple style above.

I’m okay with a complicated/hacky solution if necessary, so long as the image produced looks professional – and so long as I can edit my data easily and see its changes reflected in the chart (not having to re-do a bunch of work each time).

info visualisation – Displaying overlapping user data reflecting the status of an inventory in a horizontal stacked bar chart

I have an app in which users can track items. The app will flag when there are issues with items:

Warnings (orange UI colour)

  • Low stock
  • Expiring this month

Problems (red UI colour)

Items may have both a warning and a problem (e.g. an item with low stock that is expired).

There is a simple summary chart to summarise their inventory to the user.

Chart 1

This summarises 15 items; 1 has only a problem, 3 have only a warning, and 2 have both. The rest have no issues. Here the items with both are shown with overlapping orange and red lines. I am concerned that it looks confusing to have a separate number for the combined section, even though the numbers all add to the total.

Another option is to simplify it and show any items that have a problem as red (including those that also have a warning), and then show in orange those that only have warnings.

Chart 2

I think this is simpler and easier to see at a glance, but does not convey the full information. This might be acceptable as problems (red) are likely to be of more interest to the user than warnings (orange).

I would be grateful for advice on which provides the best user experience, or ways in which either could be improved.

DreamProxies - Cheapest USA Elite Private Proxies 100 Cheapest USA Private Proxies Buy 200 Cheap USA Private Proxies 400 Best Private Proxies Cheap 1000 USA Private Proxies 2000 USA Private Proxies 5000 Cheap USA Private Proxies - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies