Processing of graphical query via javascript

Asked

Viewed 74 times

1

Good afternoon, I have a query in my system where it generates a chart. inserir a descrição da imagem aqui


In the first chart caption is as Undefined, I was trying to redo my query only that it was not coming with the same values.
I wanted to remove the Undefined option that is in my caption leave only the last three options on my chart.

I was wondering if someone could help me get a treatment via javascript, I will post my code below.
Controller.Cs

 [HttpPost]
        public async Task<JsonResult> GetProcessosByDeslocamentoPedidoMedico()
        {
            SetaTipos();
            var dados = string.Empty;

            if (_tipo == 2)
                dados = $"AND p.RegiaoId = {_dado}";
            else if (_tipo == 3)
                dados = $"AND p.UserId = {_dado}";

            var query = $@"SELECT Title, SUM(Count) AS Count
                        FROM (
                            SELECT
                            CASE WHEN EstadoId = EstadoIdAutor AND EstadoId = Meddoc1 AND EstadoId = Meddoc2 AND EstadoId = Meddoc3 THEN
                                 'Sem deslocamento'
                                 ELSE CASE WHEN EstadoId = EstadoIdAutor AND (EstadoId = Meddoc1 OR EstadoId = Meddoc2 OR EstadoId = Meddoc3) THEN
                                    'Fora de domicílio do autor'
                                    ELSE CASE WHEN EstadoId <> EstadoIdAutor OR (EstadoId = EstadoIdAutor AND (EstadoId <> Meddoc1 AND EstadoId <> Meddoc2 AND EstadoId <> Meddoc3)) THEN
                                        'Mais de um deslocamento'
                                    END
                                 END 
                            END AS Title,
                            COUNT(*) AS Count
                            FROM jud_Processos
                            WHERE Status = 1 AND Trancado = 1 {dados}
                            GROUP BY EstadoId, EstadoIdAutor, Meddoc1, Meddoc2, Meddoc3
                        ) Sub
                        GROUP BY Title;";

            var total = await _graficosService.GetProcessos(query);

            return Json(total, JsonRequestBehavior.AllowGet);
        }


my javascript


case "9":
  Post("GetProcessosByDeslocamentoPedidoMedico", "", text);
  break;


I wanted to remove the Undefined option that is in my caption

  • the information of JavaScript that you have provided are insufficient for a response.

  • So that’s all there is in js no way to do it by query? I did one of each one I used a Union all however different results

1 answer

0


You can filter the results with a higher query

SELECT TOP 3 * FROM (
SELECT Title, SUM(Count) AS Count
                        FROM (
                            SELECT
                            CASE WHEN EstadoId = EstadoIdAutor AND EstadoId = Meddoc1 AND EstadoId = Meddoc2 AND EstadoId = Meddoc3 THEN
                                 'Sem deslocamento'
                                 ELSE CASE WHEN EstadoId = EstadoIdAutor AND (EstadoId = Meddoc1 OR EstadoId = Meddoc2 OR EstadoId = Meddoc3) THEN
                                    'Fora de domicílio do autor'
                                    ELSE CASE WHEN EstadoId <> EstadoIdAutor OR (EstadoId = EstadoIdAutor AND (EstadoId <> Meddoc1 AND EstadoId <> Meddoc2 AND EstadoId <> Meddoc3)) THEN
                                        'Mais de um deslocamento'
                                    END
                                 END 
                            END AS Title,
                            COUNT(*) AS Count
                            FROM jud_Processos
                            WHERE Status = 1 AND Trancado = 1 {dados}
                            GROUP BY EstadoId, EstadoIdAutor, Meddoc1, Meddoc2, Meddoc3
                        ) Sub
                        GROUP BY Title
) TB_AUX;
  • It worked man, thank you very much

Browser other questions tagged

You are not signed in. Login or sign up in order to post.